The following issues were found

src/mongo/db/repl/initial_syncer.cpp
1 issues
Shifting by a negative value is undefined behaviour
Error

Line: 1890 CWE codes: 758

              Status InitialSyncer::_scheduleLastOplogEntryFetcher_inlock(
    Fetcher::CallbackFn callback, LastOplogEntryFetcherRetryStrategy retryStrategy) {
    BSONObj query =
        BSON("find" << NamespaceString::kRsOplogNamespace.coll() << "sort" << BSON("$natural" << -1)
                    << "limit" << 1 << ReadConcernArgs::kReadConcernFieldName
                    << ReadConcernArgs::kImplicitDefault);

    _lastOplogEntryFetcher = std::make_unique<Fetcher>(
        *_attemptExec,

            

Reported by Cppcheck.

src/mongo/db/repl/initial_syncer_test.cpp
1 issues
syntax error
Error

Line: 690

                  net->runReadyNetworkOperations();
}

TEST_F(InitialSyncerTest, InvalidConstruction) {
    InitialSyncerInterface::Options options;
    options.getMyLastOptime = []() { return OpTime(); };
    options.setMyLastOptime = [](const OpTimeAndWallTime&) {};
    options.resetOptimes = []() {};
    options.syncSourceSelector = this;

            

Reported by Cppcheck.

src/mongo/db/repl/isself_test.cpp
1 issues
syntax error
Error

Line: 48

              
using std::string;

TEST_F(ServiceContextTest, DetectsSameHostIPv4) {
#if defined(_WIN32) || defined(__linux__) || defined(__APPLE__)
    bool wasEnabled = IPv6Enabled();
    enableIPv6(false);
    ON_BLOCK_EXIT([&] { enableIPv6(wasEnabled); });
    // first we get the addrs bound on this host

            

Reported by Cppcheck.

src/mongo/db/repl/member_config_test.cpp
1 issues
syntax error
Error

Line: 62

                  ASSERT_FALSE(mc.hasTags());
}

TEST(MemberConfig, ParseFailsWithIllegalFieldName) {
    ReplSetTagConfig tagConfig;
    ASSERT_THROWS_CODE(MemberConfig(BSON("_id" << 0 << "host"
                                               << "localhost"
                                               << "frim" << 1),
                                    &tagConfig),

            

Reported by Cppcheck.

src/mongo/db/repl/multiapplier_test.cpp
1 issues
syntax error
Error

Line: 90

                                            boost::none)};  // needsRetryImage
}

TEST_F(MultiApplierTest, InvalidConstruction) {
    const std::vector<OplogEntry> operations{makeOplogEntry(123)};
    auto multiApply = [](OperationContext*, std::vector<OplogEntry>) -> StatusWith<OpTime> {
        return Status(ErrorCodes::InternalError, "not implemented");
    };
    auto callback = [](const Status&) {};

            

Reported by Cppcheck.

src/mongo/db/repl/oplog_applier_impl_test.cpp
1 issues
syntax error
Error

Line: 117

              typedef SetSteadyStateConstraints<OplogApplierImplTest, true>
    OplogApplierImplTestEnableSteadyStateConstraints;

TEST_F(OplogApplierImplTest, applyOplogEntryOrGroupedInsertsInsertDocumentDatabaseMissing) {
    NamespaceString nss("test.t");
    auto op = makeOplogEntry(OpTypeEnum::kInsert, nss, {});
    ASSERT_THROWS(_applyOplogEntryOrGroupedInsertsWrapper(
                      _opCtx.get(), &op, OplogApplication::Mode::kSecondary),
                  ExceptionFor<ErrorCodes::NamespaceNotFound>);

            

Reported by Cppcheck.

src/mongo/db/repl/oplog_applier_test.cpp
1 issues
syntax error
Error

Line: 108

              
constexpr auto dbName = "test"_sd;

TEST_F(OplogApplierTest, GetNextApplierBatchGroupsCrudOps) {
    std::vector<OplogEntry> srcOps;
    srcOps.push_back(makeInsertOplogEntry(1, NamespaceString(dbName, "foo")));
    srcOps.push_back(makeInsertOplogEntry(2, NamespaceString(dbName, "bar")));
    _applier->enqueue(_opCtx.get(), srcOps.cbegin(), srcOps.cend());


            

Reported by Cppcheck.

src/mongo/db/repl/oplog_buffer_collection_test.cpp
1 issues
syntax error
Error

Line: 120

                                   << "o" << BSON("_id" << t << "a" << t));
}

TEST_F(OplogBufferCollectionTest, DefaultNamespace) {
    ASSERT_EQUALS(OplogBufferCollection::getDefaultNamespace(),
                  OplogBufferCollection(_storageInterface).getNamespace());
}

TEST_F(OplogBufferCollectionTest, GetNamespace) {

            

Reported by Cppcheck.

src/mongo/db/repl/oplog_buffer_proxy_test.cpp
1 issues
syntax error
Error

Line: 152

                  _mock = nullptr;
}

DEATH_TEST_REGEX_F(OplogBufferProxyTest,
                   NullTargetOplogBufferAtConstructionTriggersInvariant,
                   "Invariant failure.*_target") {
    OplogBufferProxy(nullptr);
}


            

Reported by Cppcheck.

src/mongo/db/repl/oplog_entry_test.cpp
1 issues
syntax error
Error

Line: 44

              const NamespaceString nss{"foo", "bar"};
const int docId = 17;

TEST(OplogEntryTest, Update) {
    const BSONObj doc = BSON("_id" << docId);
    const BSONObj update = BSON("$set" << BSON("a" << 4));
    const auto entry = makeUpdateDocumentOplogEntry(entryOpTime, nss, doc, update);

    ASSERT_FALSE(entry.isCommand());

            

Reported by Cppcheck.