summaryrefslogtreecommitdiff
path: root/src/mongo/scripting/bson_template_evaluator.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-08-25 17:17:39 -0400
committerMathias Stearn <mathias@10gen.com>2015-08-28 15:23:54 -0400
commit1c5fdf89ee6fd377096b9369b94ee490792a22b8 (patch)
tree661e7a672e417375cc7685c0d11c98b7f1442c2d /src/mongo/scripting/bson_template_evaluator.cpp
parent1eca10057d98aa46e9adf3b06edac74c437edfd3 (diff)
downloadmongo-1c5fdf89ee6fd377096b9369b94ee490792a22b8.tar.gz
SERVER-20121 Use unsigned arithmetic in PsuedoRandom
Diffstat (limited to 'src/mongo/scripting/bson_template_evaluator.cpp')
-rw-r--r--src/mongo/scripting/bson_template_evaluator.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mongo/scripting/bson_template_evaluator.cpp b/src/mongo/scripting/bson_template_evaluator.cpp
index 73efc05891c..6a1e15a644f 100644
--- a/src/mongo/scripting/bson_template_evaluator.cpp
+++ b/src/mongo/scripting/bson_template_evaluator.cpp
@@ -167,7 +167,7 @@ BsonTemplateEvaluator::Status BsonTemplateEvaluator::evalRandInt(BsonTemplateEva
if (max <= min)
return StatusOpEvaluationError;
// range of max-min
- int randomNum = min + (btl->rng.nextInt32() % (max - min));
+ int randomNum = min + (btl->rng.nextInt32(max - min));
if (range.nFields() == 3) {
if (!range[2].isNumber())
return StatusOpEvaluationError;
@@ -189,7 +189,7 @@ BsonTemplateEvaluator::Status BsonTemplateEvaluator::evalRandPlusThread(BsonTemp
const int max = range["1"].numberInt();
if (max <= min)
return StatusOpEvaluationError;
- int randomNum = min + (btl->rng.nextInt32() % (max - min));
+ int randomNum = min + (btl->rng.nextInt32(max - min));
randomNum += ((max - min) * btl->_id);
out.append(fieldName, randomNum);
return StatusSuccess;
@@ -267,7 +267,7 @@ BsonTemplateEvaluator::Status BsonTemplateEvaluator::evalRandString(BsonTemplate
"0123456789+/";
static const size_t alphaNumLength = sizeof(alphanum) - 1;
static_assert(alphaNumLength == 64, "alphaNumLength == 64");
- int32_t currentRand = 0;
+ uint32_t currentRand = 0;
std::string str;
for (int i = 0; i < length; ++i, currentRand >>= 6) {
if (i % 5 == 0)