Fix/Suppress remaining Cppcheck warnings (#291)

Fix/suppress the following cppcheck warnings:

* arithOperationsOnVoidPointer
* uninitMember
* const*
* shadowVariable
* assignmentIntegerToAddress
* containerOutOfBounds
* pointer-related warnings in Ragel source
* missingOverride
* memleak
* knownConditionTrueFalse
* noExplicitConstructor
* invalidPrintfArgType_sint
* useStlAlgorithm
* cstyleCast
* clarifyCondition
* VSX-related cstyleCast
* unsignedLessThanZero 

Furthermore, we added a suppression list to be used, which also includes the following:
* missingIncludeSystem
* missingInclude
* unmatchedSuppression
This commit is contained in:
Konstantinos Margaritis
2024-05-27 12:23:02 +03:00
committed by GitHub
parent cebc6541c1
commit c837925087
78 changed files with 204 additions and 131 deletions

View File

@@ -98,7 +98,6 @@ TEST(ng_charreach, assignment) {
cr2 = cr;
ASSERT_EQ(cr.count(), cr2.count());
ASSERT_TRUE(cr == cr2);
}
TEST(ng_charreach, flip) {

View File

@@ -138,7 +138,7 @@ vector<u32> getValidFdrEngines() {
static
bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
bytecode_ptr<FDR> buildFDREngineHinted(const std::vector<hwlmLiteral> &lits,
bool make_small, u32 hint,
const target_t &target,
const Grey &grey) {
@@ -151,7 +151,7 @@ bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
}
static
bytecode_ptr<FDR> buildFDREngine(std::vector<hwlmLiteral> &lits,
bytecode_ptr<FDR> buildFDREngine(const std::vector<hwlmLiteral> &lits,
bool make_small, const target_t &target,
const Grey &grey) {
auto proto = fdrBuildProto(HWLM_ENGINE_FDR, lits, make_small, target, grey);

View File

@@ -133,7 +133,7 @@ static vector<u32> getValidFdrEngines() {
}
static
bytecode_ptr<FDR> buildFDREngineHinted(std::vector<hwlmLiteral> &lits,
bytecode_ptr<FDR> buildFDREngineHinted(const std::vector<hwlmLiteral> &lits,
bool make_small, u32 hint,
const target_t &target,
const Grey &grey) {

View File

@@ -370,31 +370,24 @@ TEST(flat_map, get_allocator) {
TEST(flat_map, compare_ops) {
flat_map<u32, u32> f1 = {{0, 1}, {1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}};
flat_map<u32, u32> f1_copy = f1;
flat_map<u32, u32> f2 = {{2, 1}, {4, 2}, {6, 3}, {8, 4}, {10, 5}, {12, 6}};
EXPECT_TRUE(f1 == f1);
EXPECT_TRUE(f1 == f1_copy);
EXPECT_FALSE(f1 == f2);
EXPECT_FALSE(f1 != f1);
EXPECT_FALSE(f1 != f1_copy);
EXPECT_TRUE(f1 != f2);
EXPECT_FALSE(f1 < f1);
EXPECT_FALSE(f1 < f1_copy);
EXPECT_TRUE(f1 < f2);
EXPECT_TRUE(f1 <= f1);
EXPECT_TRUE(f1 <= f1_copy);
EXPECT_TRUE(f1 <= f2);
EXPECT_FALSE(f1 > f1);
EXPECT_FALSE(f1 > f1_copy);
EXPECT_FALSE(f1 > f2);
EXPECT_TRUE(f1 >= f1);
EXPECT_TRUE(f1 >= f1_copy);
EXPECT_FALSE(f1 >= f2);
}

View File

@@ -340,31 +340,24 @@ TEST(flat_set, iter_interop) {
TEST(flat_set, compare_ops) {
flat_set<u32> f1 = {1, 2, 3, 4, 5};
flat_set<u32> f1_copy = f1;
flat_set<u32> f2 = {2, 4, 6, 8, 10};
EXPECT_TRUE(f1 == f1);
EXPECT_TRUE(f1 == f1_copy);
EXPECT_FALSE(f1 == f2);
EXPECT_FALSE(f1 != f1);
EXPECT_FALSE(f1 != f1_copy);
EXPECT_TRUE(f1 != f2);
EXPECT_FALSE(f1 < f1);
EXPECT_FALSE(f1 < f1_copy);
EXPECT_TRUE(f1 < f2);
EXPECT_TRUE(f1 <= f1);
EXPECT_TRUE(f1 <= f1_copy);
EXPECT_TRUE(f1 <= f2);
EXPECT_FALSE(f1 > f1);
EXPECT_FALSE(f1 > f1_copy);
EXPECT_FALSE(f1 > f2);
EXPECT_TRUE(f1 >= f1);
EXPECT_TRUE(f1 >= f1_copy);
EXPECT_FALSE(f1 >= f2);
}

View File

@@ -55,11 +55,11 @@ public:
}
operator u8 *() {
assert(data);
return data.get() + 7;
return reinterpret_cast<u8 *>(data.get()) + 7;
}
operator const u8 *() const {
assert(data);
return data.get() + 7;
return reinterpret_cast<u8 *>(data.get()) + 7;
}
private:

View File

@@ -94,11 +94,11 @@ public:
}
operator u8 *() {
assert(data);
return data.get() + 7;
return reinterpret_cast<u8 *>(data.get()) + 7;
}
operator const u8 *() const {
assert(data);
return data.get() + 7;
return reinterpret_cast<u8 *>(data.get()) + 7;
}
private:
@@ -116,11 +116,11 @@ public:
}
operator u8 *() {
assert(data);
return data.get() + 7;
return reinterpret_cast<u8 *>(data.get()) + 7;
}
operator const u8 *() const {
assert(data);
return data.get() + 7;
return reinterpret_cast<u8 *>(data.get()) + 7;
}
private:

View File

@@ -66,6 +66,7 @@ ostream& operator<<(ostream &os, const RepeatInfo &info) {
class RepeatTest : public TestWithParam<RepeatTestInfo> {
protected:
RepeatTest() = default;
virtual void SetUp() {
test_info = GetParam();
@@ -94,12 +95,12 @@ protected:
delete [] state_int;
}
RepeatTestInfo test_info; // Test params
RepeatInfo info; // Repeat info structure
RepeatControl *ctrl;
char *state;
RepeatTestInfo test_info{}; // Test params
RepeatInfo info{}; // Repeat info structure
RepeatControl *ctrl = nullptr;
char *state = nullptr;
private:
char *state_int;
char *state_int = nullptr;
};
@@ -728,6 +729,7 @@ void test_sparse3entryExpire(const RepeatInfo *info, RepeatControl *ctrl,
class SparseOptimalTest : public TestWithParam<tuple<u32, RepeatTestInfo> > {
protected:
SparseOptimalTest() = default;
virtual void SetUp() {
u32 period;
tie(period, test_info) = GetParam();
@@ -773,13 +775,13 @@ protected:
delete[] ptr;
}
RepeatTestInfo test_info; // Test params
RepeatInfo *info; // Repeat info structure
RepeatControl *ctrl;
char *state;
RepeatTestInfo test_info{}; // Test params
RepeatInfo *info = nullptr; // Repeat info structure
RepeatControl *ctrl = nullptr;
char *state = nullptr;
private:
char *ptr;
char *state_int;
char *ptr = nullptr;
char *state_int = nullptr;
};