The following issues were found
src/mongo/logv2/logv2_component_test.cpp
1 issues
Line: 46
const LogComponent componentD = LogComponent::kStorage;
const LogComponent componentE = LogComponent::kJournal;
TEST(LogV2ComponentSettingsTest, MinimumLogSeverity) {
LogComponentSettings settings;
ASSERT_TRUE(settings.hasMinimumLogSeverity(LogComponent::kDefault));
ASSERT_TRUE(settings.getMinimumLogSeverity(LogComponent::kDefault) == LogSeverity::Log());
for (int i = 0; i < int(LogComponent::kNumLogComponents); ++i) {
LogComponent component = static_cast<LogComponent::Value>(i);
Reported by Cppcheck.
src/mongo/logv2/logv2_test.cpp
1 issues
Line: 297
std::vector<boost::shared_ptr<boost::log::sinks::sink>> _attachedSinks;
};
TEST_F(LogV2Test, Basic) {
auto lines = makeLineCapture(PlainFormatter());
BSONObjBuilder builder;
fmt::memory_buffer buffer;
Reported by Cppcheck.
src/mongo/logv2/ramlog.cpp
1 issues
Line: 196
* ensuring that _namedLock and _named are initialized safely.
*/
MONGO_INITIALIZER(RamLogCatalogV2)(InitializerContext*) {
if (!_namedLock) {
if (_named) {
uasserted(ErrorCodes::InternalError, "Inconsistent intiailization of RamLogCatalog.");
}
_namedLock = new stdx::mutex(); // NOLINT
Reported by Cppcheck.
src/mongo/logv2/redaction_test.cpp
1 issues
Line: 45
const std::string kMsg = "Not initialized";
using BSONStringPair = std::pair<BSONObj, std::string>;
TEST(RedactStringTest, NoRedact) {
logv2::setShouldRedactLogs(false);
std::string toRedact[] = {"", "abc", "*&$@!_\\\\\\\"*&$@!_\"*&$@!_\"*&$@!_"};
for (auto s : toRedact) {
ASSERT_EQ(redact(s), s);
Reported by Cppcheck.
src/mongo/platform/atomic_proxy_test.cpp
1 issues
Line: 52
}
TEST(AtomicProxyTests, BasicOperationsDouble) {
testAtomicProxyBasicOperations<AtomicDouble>();
AtomicDouble d(3.14159);
ASSERT_EQUALS(3.14159, d.load());
}
Reported by Cppcheck.
src/mongo/platform/bits_test.cpp
1 issues
Line: 50
ASSERT_EQUALS(countTrailingZeros64((0x1234ull << 32) | 0x1234ull), 2);
}
TEST(BitsTest_CountZeros, EachBit) {
for (int i = 0; i < 64; i++) {
unsigned long long x = 1ULL << i;
ASSERT_EQUALS(countLeadingZeros64(x), 64 - 1 - i);
ASSERT_EQUALS(countTrailingZeros64(x), i);
}
Reported by Cppcheck.
src/mongo/platform/decimal128.cpp
1 issues
Line: 610
Column: 5
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
return "NaN";
}
BID_UINT128 dec128 = decimal128ToLibraryType(_value);
char decimalCharRepresentation[1 /* mantissa sign */ + 34 /* mantissa */ +
1 /* scientific E */ + 1 /* exponent sign */ + 4 /* exponent */ +
1 /* null terminator */];
std::uint32_t idec_signaling_flags = 0;
/**
* Use the library's defined to_string method, which returns a string composed of a
Reported by FlawFinder.
src/mongo/platform/decimal128_bson_test.cpp
1 issues
Line: 75
return result;
}
TEST(Decimal128BSONTest, TestsConstructingDecimalWithBsonDump) {
BSONObj allData = fromjson(testData);
BSONObj data = allData.getObjectField("valid");
BSONObjIterator it(data);
while (it.moreWithEOO()) {
Reported by Cppcheck.
src/mongo/platform/decimal128_test.cpp
1 issues
Line: 298
}
TEST(Decimal128Test, TestLiteral) {
#define ASSERT_LITERAL128(x) ASSERT_TRUE((x##_dec128).isBinaryEqual(Decimal128(#x)))
ASSERT_LITERAL128(5);
ASSERT_LITERAL128(-5);
ASSERT_LITERAL128(5.5);
ASSERT_LITERAL128(-5.5);
ASSERT_LITERAL128(5.1);
Reported by Cppcheck.
src/mongo/platform/endian.h
1 issues
Line: 96
Column: 10
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
int> = 0>
To bitCast(From t) {
To u;
std::memcpy(&u, &t, sizeof(t));
return u;
}
template <typename T>
using RequireArithmetic = std::enable_if_t<std::is_arithmetic_v<T>, int>;
Reported by FlawFinder.