The following issues were found

src/mongo/util/assert_util_test.cpp
1 issues
syntax error
Error

Line: 81

              MONGO_STATIC_ASSERT(!std::is_base_of<ExceptionForCat<ErrorCategory::Interruption>,
                                     ExceptionFor<ErrorCodes::BadValue>>());

TEST(AssertUtils, UassertNamedCodeWithoutCategories) {
    ASSERT_CATCHES(ErrorCodes::BadValue, DBException);
    ASSERT_CATCHES(ErrorCodes::BadValue, AssertionException);
    ASSERT_CATCHES(ErrorCodes::BadValue, ExceptionFor<ErrorCodes::BadValue>);
    ASSERT_NOT_CATCHES(ErrorCodes::BadValue, ExceptionFor<ErrorCodes::DuplicateKey>);
    ASSERT_NOT_CATCHES(ErrorCodes::BadValue, ExceptionForCat<ErrorCategory::NetworkError>);

            

Reported by Cppcheck.

src/mongo/util/background_job_test.cpp
1 issues
syntax error
Error

Line: 75

                  Notification<void>* const _destructorInvoked;
};

TEST(BackgroundJobBasic, NormalCase) {
    AtomicWord<bool> flag(false);
    TestJob tj(false, &flag);
    tj.go();
    ASSERT(tj.wait());
    ASSERT_EQUALS(true, flag.load());

            

Reported by Cppcheck.

src/mongo/util/background_thread_clock_source_test.cpp
1 issues
syntax error
Error

Line: 85

                  size_t _lastTimesPaused = 0;
};

TEST_F(BTCSTest, CreateAndTerminate) {
    setUpClocks(Milliseconds(1));
    _btcs.reset();  // destroys the clock source

    setUpClocks(Hours(48));
    _btcs.reset();

            

Reported by Cppcheck.

src/mongo/util/base64_test.cpp
1 issues
syntax error
Error

Line: 79

              
static constexpr bool kSuperVerbose = false;  // devel instrumentation

TEST(Base64Test, encodeAllPossibleGroups) {
    std::string buf;
    for (int sz = 1; sz < 3; ++sz) {
        buf.resize(sz);
        for (std::uint32_t q = 0; q < (1u << (8 * sz)); ++q) {
            for (int k = 0; k < sz; ++k) {

            

Reported by Cppcheck.

src/mongo/util/cancellation_test.cpp
1 issues
syntax error
Error

Line: 52

                  ASSERT_TRUE(ran);
}

TEST(CancelTest, CancelTokenIsCanceledIsFalseBeforeCancellation) {
    CancellationSource source;
    ASSERT_FALSE(source.token().isCanceled());
}

TEST(CancelTest, CancelTokenOnCancelFutureIsNotReadyBeforeCancellation) {

            

Reported by Cppcheck.

src/mongo/util/checksum.h
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 39 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

              /** a simple, rather dumb, but very fast checksum.  see perftests.cpp for unit tests. */
struct Checksum {
    union {
        unsigned char bytes[16];
        unsigned long long words[2];
    };

    // if you change this you must bump dur::CurrentVersion
    void gen(const void* buf, unsigned len) {

            

Reported by FlawFinder.

src/mongo/util/clock_source_mock_test.cpp
1 issues
syntax error
Error

Line: 43

                  ASSERT(!cs.tracksSystemClock());
}

TEST(ClockSourceMockTest, ExpiredAlarmExecutesWhenSet) {
    ClockSourceMock cs;
    int alarmFiredCount = 0;
    const Date_t alarmDate = cs.now();
    const auto alarmAction = [&] { ++alarmFiredCount; };
    ASSERT_OK(cs.setAlarm(alarmDate, alarmAction));

            

Reported by Cppcheck.

src/mongo/util/concepts_test.cpp
1 issues
syntax error
Error

Line: 167

              static_assert(!isCallable<void(StringData), StringData, StringData>);

// The unittest framework gets angry if you have no tests.
TEST(Concepts, DummyTest) {}

}  // namespace
}  // namespace mongo

            

Reported by Cppcheck.

src/mongo/util/concurrency/mutex.h
1 issues
InitializeCriticalSection - Exceptions can be thrown in low-memory situations
Security

Line: 56 Column: 9 CWE codes:
Suggestion: Use InitializeCriticalSectionAndSpinCount instead

              
public:
    SimpleMutex() {
        InitializeCriticalSection(&_cs);
    }

    ~SimpleMutex() {
        DeleteCriticalSection(&_cs);
    }

            

Reported by FlawFinder.

src/mongo/util/concurrency/spin_lock_test.cpp
1 issues
syntax error
Error

Line: 144

              };


TEST(Concurrency, ConcurrentIncs) {
    SpinLockTester tester;
    tester.run<LockTester>("ConcurrentIncs");
}

TEST(Concurrency, ConcurrentIncsWithTryLock) {

            

Reported by Cppcheck.