The following issues were found
src/mongo/db/s/config/sharding_catalog_manager_add_shard_test.cpp
1 issues
Line: 338
OID _clusterId;
};
TEST_F(AddShardTest, CreateShardIdentityUpsertForAddShard) {
std::string shardName = "shardName";
BSONObj expectedBSON =
BSON("update"
<< "system.version"
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_add_shard_to_zone_test.cpp
1 issues
Line: 47
using AddShardToZoneTest = ConfigServerTestFixture;
TEST_F(AddShardToZoneTest, AddSingleZoneToExistingShardShouldSucceed) {
ShardType shard;
shard.setName("a");
shard.setHost("a:1234");
setupShards({shard});
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_assign_key_range_to_zone_test.cpp
1 issues
Line: 131
}
};
TEST_F(AssignKeyRangeToZoneTestFixture, BasicAssignKeyRange) {
const ChunkRange newRange(BSON("x" << 0), BSON("x" << 10));
ShardingCatalogManager::get(operationContext())
->assignKeyRangeToZone(operationContext(), shardedNS(), newRange, zoneName());
assertOnlyZone(shardedNS(), newRange, zoneName());
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_bump_collection_version_and_change_metadata_test.cpp
1 issues
Line: 113
}
};
TEST_F(ShardingCatalogManagerBumpCollectionVersionAndChangeMetadataTest,
BumpsOnlyMinorVersionOfNewestChunk) {
const auto collEpoch = OID::gen();
const auto collTimestamp = boost::none;
const auto shard0Chunk0 = generateChunkType(kNss,
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_clear_jumbo_flag_test.cpp
1 issues
Line: 99
const NamespaceString _nss2{"TestDB.TestColl2"};
};
TEST_F(ClearJumboFlagTest, ClearJumboShouldBumpVersion) {
auto test = [&](const NamespaceString& nss, const boost::optional<Timestamp>& collTimestamp) {
const auto collUuid = UUID::gen();
const auto collEpoch = OID::gen();
makeCollection(nss, collUuid, collEpoch, collTimestamp);
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_commit_chunk_migration_test.cpp
1 issues
Line: 52
const NamespaceString kNamespace("TestDB.TestColl");
const KeyPattern kKeyPattern(BSON("x" << 1));
TEST_F(CommitChunkMigrate, ChunksUpdatedCorrectly) {
const auto collEpoch = OID::gen();
const auto collTimestamp = boost::none;
ShardType shard0;
shard0.setName("shard0");
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_config_initialization_test.cpp
1 issues
Line: 102
std::unique_ptr<AutoGetDb> _autoDb;
};
TEST_F(ConfigInitializationTest, UpgradeNotNeeded) {
VersionType version;
version.setClusterId(OID::gen());
version.setCurrentVersion(CURRENT_CONFIG_VERSION);
version.setMinCompatibleVersion(MIN_COMPATIBLE_CONFIG_VERSION);
ASSERT_OK(
Reported by Cppcheck.
src/mongo/db/s/config/sharding_catalog_manager_ensure_chunk_version_is_greater_than_test.cpp
1 issues
Line: 95
ASSERT(chunkTypeBefore.getHistory() == chunkTypeAfter.getHistory());
}
TEST_F(EnsureChunkVersionIsGreaterThanTest, IfNoCollectionFoundReturnsSuccess) {
const auto requestedChunkType =
generateChunkType(_nss,
_collUuid,
ChunkVersion(10, 2, OID::gen(), boost::none /* timestamp */),
ShardId(_shardName),
Reported by Cppcheck.
src/third_party/wiredtiger/test/utility/test_util.h
1 issues
Line: 195
Column: 18
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
static inline void
u64_to_string(uint64_t n, char **pp)
{
static const char hundred_lookup[201] =
"0001020304050607080910111213141516171819"
"2021222324252627282930313233343536373839"
"4041424344454647484950515253545556575859"
"6061626364656667686970717273747576777879"
"8081828384858687888990919293949596979899";
Reported by FlawFinder.
src/third_party/zstandard-1.4.4/zstd/tests/datagencli.c
1 issues
Line: 35
Column: 30
CWE codes:
134
Suggestion:
Use a constant for the format specification
/*-************************************
* Macros
**************************************/
#define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
#define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
static unsigned displayLevel = 2;
/*-*******************************************************
Reported by FlawFinder.