The following issues were found

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

Line: 51

              // DifferentType tests. As such, the DifferentType tests only use ASSERT_{GT,LT,LTE,GTE,EQ,NE} and
// never do an ASSERT_FALSE.

TEST(DurationComparisonSameType, CompareEqual) {
    ASSERT_EQ(Microseconds::zero(), Microseconds::zero());
    ASSERT_EQ(Microseconds::max(), Microseconds::max());
    ASSERT_EQ(Microseconds::min(), Microseconds::min());
    ASSERT_FALSE(Microseconds::zero() == Microseconds{-1});
}

            

Reported by Cppcheck.

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

Line: 92

                  }
};

TEST_F(DynamicCatchTest, NoHandlers) {
    try {
        struct Uncatchable {};
        throw Uncatchable{};
    } catch (...) {
        std::ostringstream os;

            

Reported by Cppcheck.

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

Line: 45

              
const std::string kUnknownError = "Unknown error";

TEST(ErrnoWithDescription, CommonErrors) {
#if defined(_WIN32)
    // Force error messages to be returned in en-US.
    LANGID lang = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
    ASSERT_EQ(SetThreadUILanguage(lang), lang);


            

Reported by Cppcheck.

src/mongo/util/fail_point.h
1 issues
random - This function is not sufficiently random for security-related functions such as key and nonce creation
Security

Line: 121 Column: 32 CWE codes: 327
Suggestion: Use a more secure technique for acquiring random values

              class FailPoint {
public:
    using ValType = unsigned;
    enum Mode { off, alwaysOn, random, nTimes, skip };

    struct ModeOptions {
        Mode mode;
        ValType val;
        BSONObj extra;

            

Reported by FlawFinder.

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

Line: 54

                                      });
}

TEST(Executor_Future, Reject_getAsync) {
    FUTURE_SUCCESS_TEST([] {},
                        [](/*Future<void>*/ auto&& fut) {
                            auto exec = RejectingExecutor::make();
                            auto pf = makePromiseFuture<void>();
                            std::move(fut).thenRunOn(exec).getAsync(

            

Reported by Cppcheck.

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

Line: 47

                                      [](/*Future<int>*/ auto&& fut) { ASSERT_EQ(fut.get(), 1); });
}

TEST(Future, Success_getConstLvalue) {
    FUTURE_SUCCESS_TEST([] { return 1; },
                        [](const /*Future<int>*/ auto& fut) { ASSERT_EQ(fut.get(), 1); });
}

TEST(Future, Success_getRvalue) {

            

Reported by Cppcheck.

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

Line: 84

                  return stream << "Widget(" << widget.val << ')';
}

TEST(Future_MoveOnly, Success_getLvalue) {
    FUTURE_SUCCESS_TEST([] { return Widget(1); },
                        [](/*Future<Widget>*/ auto&& fut) { ASSERT_EQ(fut.get(), 1); });
}

TEST(Future_MoveOnly, Success_getConstLvalue) {

            

Reported by Cppcheck.

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

Line: 47

                  FUTURE_SUCCESS_TEST([] {}, [](/*Future<void>*/ auto&& fut) { fut.get(); });
}

TEST(Future_Void, Success_getConstLvalue) {
    FUTURE_SUCCESS_TEST([] {}, [](const /*Future<void>*/ auto& fut) { fut.get(); });
}

TEST(Future_Void, Success_getRvalue) {
    FUTURE_SUCCESS_TEST([] {}, [](/*Future<void>*/ auto&& fut) { std::move(fut).get(); });

            

Reported by Cppcheck.

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

Line: 49

              static_assert(canSetFrom<Promise<int>, StatusWith<int>>);
static_assert(canSetFrom<Promise<int>, Future<int>>);

TEST(Promise, Success_setFrom_future) {
    FUTURE_SUCCESS_TEST<kNoExecutorFuture_needsPromiseSetFrom>(
        [] { return 1; },
        [](/*Future<int>*/ auto&& fut) {
            auto pf = makePromiseFuture<int>();
            pf.promise.setFrom(std::move(fut));

            

Reported by Cppcheck.

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

Line: 47

              static_assert(canSetFrom<Promise<void>, Status>);
static_assert(canSetFrom<Promise<void>, Future<void>>);

TEST(Promise_void, Success_setFrom_future) {
    FUTURE_SUCCESS_TEST<kNoExecutorFuture_needsPromiseSetFrom>(
        [] {},
        [](/*Future<void>*/ auto&& fut) {
            // This intentionally doesn't work with ExecutorFuture.
            auto pf = makePromiseFuture<void>();

            

Reported by Cppcheck.