The following issues were found
src/mongo/db/storage/flow_control_test.cpp
1 issues
Line: 89
bool _stashedEnableMajorityReadConcern;
};
TEST_F(FlowControlTest, AddingSamples) {
// Create a sample entry for every five operations. This better simulates reality than the
// testing value of one. The timestamp is incremented by one for each operation.
gFlowControlSamplePeriod.store(5);
int nextTimestamp = 1;
Reported by Cppcheck.
src/mongo/db/storage/index_entry_comparison_test.cpp
1 issues
Line: 97
ASSERT_BSONOBJ_EQ(parsedDuplicatedErrorInfo->getDuplicatedKeyValue(), keyValueWithFieldName);
}
TEST(IndexEntryComparison, BuildDupKeyErrorSerializeAndParseReturnTheSameObjectWithCollation) {
auto keyPattern = BSON("a" << 1 << "b" << 1);
auto str = "abc";
auto keyValue = BSON("" << 10 << "" << str);
auto collation = BSON("x"
<< "y");
Reported by Cppcheck.
src/mongo/db/storage/key_string_to_bson_fuzzer.cpp
1 issues
Line: 34
CWE codes:
758
#include "mongo/db/storage/key_string.h"
const mongo::Ordering kAllAscending = mongo::Ordering::make(mongo::BSONObj());
const mongo::Ordering kOneDescending = mongo::Ordering::make(BSON("a" << -1));
const auto kV1 = mongo::KeyString::Version::V1;
const auto kV0 = mongo::KeyString::Version::V0;
uint8_t getZeroType(char val) {
switch (val % 10) {
Reported by Cppcheck.
src/mongo/db/storage/kv/durable_catalog_test.cpp
1 issues
Line: 210
OptionalCollectionUUID _collectionUUID;
};
TEST_F(DurableCatalogTest, MultikeyPathsForBtreeIndexInitializedToVectorOfEmptySets) {
auto indexEntry = createIndex(BSON("a" << 1 << "b" << 1));
auto collection = getCollection();
{
MultikeyPaths multikeyPaths;
ASSERT(!collection->isIndexMultikey(
Reported by Cppcheck.
src/mongo/db/storage/kv/kv_drop_pending_ident_reaper_test.cpp
1 issues
Line: 192
return cc().makeOperationContext();
}
TEST_F(KVDropPendingIdentReaperTest, GetEarliestDropTimestampReturnsBoostNoneOnEmptyIdents) {
KVDropPendingIdentReaper reaper(nullptr);
ASSERT_FALSE(reaper.getEarliestDropTimestamp());
}
TEST_F(KVDropPendingIdentReaperTest, AddDropPendingIdentAcceptsNullDropTimestamp) {
Reported by Cppcheck.
src/mongo/db/storage/kv/kv_engine_test_harness.cpp
1 issues
Line: 155
const std::unique_ptr<ClockSource> clock = std::make_unique<ClockSourceMock>();
TEST_F(KVEngineTestHarness, SimpleRS1) {
std::unique_ptr<KVHarnessHelper> helper(KVHarnessHelper::create(getServiceContext()));
KVEngine* engine = helper->getEngine();
ASSERT(engine);
std::string ns = "a.b";
Reported by Cppcheck.
src/mongo/db/storage/kv/kv_engine_timestamps_test.cpp
1 issues
Line: 224
} // namespace
TEST_F(SnapshotManagerTests, ConsistentIfNotSupported) {
if (snapshotManager)
return; // This test is only for engines that DON'T support SnapshotManagers.
auto op = makeOperation();
auto ru = op->recoveryUnit();
Reported by Cppcheck.
src/mongo/db/storage/kv/storage_engine_test.cpp
1 issues
Line: 93
ASSERT_EQUALS(ErrorCodes::UnrecoverableRollbackError, reconcileStatus.getStatus());
}
TEST_F(StorageEngineTest, LoadCatalogDropsOrphansAfterUncleanShutdown) {
auto opCtx = cc().makeOperationContext();
const NamespaceString collNs("db.coll1");
auto swCollInfo = createCollection(opCtx.get(), collNs);
ASSERT_OK(swCollInfo.getStatus());
Reported by Cppcheck.
src/mongo/db/storage/record_data.h
1 issues
Line: 87
Column: 9
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
if (isOwned())
return *this;
auto buffer = SharedBuffer::allocate(_size);
memcpy(buffer.get(), _data, _size);
return RecordData(buffer, _size);
}
void makeOwned() {
if (isOwned())
Reported by FlawFinder.
src/mongo/db/storage/record_store_test_datafor.cpp
1 issues
Line: 49
// Insert a record and verify its contents by calling dataFor()
// on the returned RecordId.
TEST(RecordStoreTestHarness, DataFor) {
const auto harnessHelper(newRecordStoreHarnessHelper());
unique_ptr<RecordStore> rs(harnessHelper->newNonCappedRecordStore());
{
ServiceContext::UniqueOperationContext opCtx(harnessHelper->newOperationContext());
Reported by Cppcheck.