SERVER-90594 Add `bugprone-too-small-loop-variable` to clang-tidy (#22286)

GitOrigin-RevId: cf54d27c154af8d269c2f9159466d1ffb6b67e91
This commit is contained in:
Gregory Noma 2024-05-21 18:20:06 -04:00 committed by MongoDB Bot
parent e8e0c79927
commit 56e5510928
5 changed files with 5 additions and 4 deletions

View File

@ -24,6 +24,7 @@ Checks: '-*,
bugprone-suspicious-string-compare,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-too-small-loop-variable,
bugprone-undelegated-constructor,
bugprone-unused-raii,
bugprone-unused-return-value,

View File

@ -258,7 +258,7 @@ public:
}
static uint64_t deltaDouble(BSONElement val, BSONElement prev, double scaleFactor) {
uint8_t scaleIndex = 0;
size_t scaleIndex = 0;
for (; scaleIndex < Simple8bTypeUtil::kScaleMultiplier.size(); ++scaleIndex) {
if (Simple8bTypeUtil::kScaleMultiplier[scaleIndex] == scaleFactor)
break;

View File

@ -105,7 +105,7 @@ boost::optional<uint8_t> Simple8bTypeUtil::calculateDecimalShiftMultiplier(doubl
}
// Try multiplying by selected powers of 10 until we do not have any decimal digits. If we
// always have leftover digits, return none.
for (uint8_t i = 0; i < kScaleMultiplier.size(); ++i) {
for (size_t i = 0; i < kScaleMultiplier.size(); ++i) {
double scaleMultiplier = kScaleMultiplier[i];
double valTimesMultiplier = val * scaleMultiplier;
// Checks for both overflows

View File

@ -329,7 +329,7 @@ StringData FieldRef::dottedSubstring(FieldIndex startPart, FieldIndex endPart) c
bool FieldRef::equalsDottedField(StringData other) const {
StringData rest = other;
for (FieldIndex i = 0; i < _parts.size(); i++) {
for (size_t i = 0; i < _parts.size(); i++) {
StringData part = getPart(i);
if (!rest.startsWith(part))

View File

@ -159,7 +159,7 @@ void applyChild(const UpdateNode& child,
// If the child is an internal node, it may have created 'pathToCreate' and moved 'pathToCreate'
// to the end of 'pathTaken'. We should advance 'element' to the end of 'pathTaken'.
if (updateNodeApplyParams->pathTaken->size() > pathTakenSizeBefore) {
for (auto i = pathTakenSizeBefore; i < updateNodeApplyParams->pathTaken->size(); ++i) {
for (size_t i = pathTakenSizeBefore; i < updateNodeApplyParams->pathTaken->size(); ++i) {
applyParams->element = getChild(
applyParams->element, updateNodeApplyParams->pathTaken->fieldRef().getPart(i));
invariant(applyParams->element.ok());