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

@@ -164,7 +164,7 @@ ComponentSequence *enterSequence(ComponentSequence *parent,
ComponentSequence *seq = child.get();
parent->addComponent(std::move(child));
return seq;
return seq; // cppcheck-suppress returnDanglingLifetime
}
static

View File

@@ -99,7 +99,8 @@ public:
const NFABuilder &getBuilder() const override { return builder; }
/** \brief Wire up the lasts of one component to the firsts of another. */
void connectRegions(const vector<PositionInfo> &lasts,
// cppcheck-suppress virtualCallInConstructor
virtual void connectRegions(const vector<PositionInfo> &lasts,
const vector<PositionInfo> &firsts) override;
/** \brief Wire the lasts of the main sequence to accepts. */

View File

@@ -108,6 +108,8 @@ const char *read_control_verbs(const char *ptr, const char *end, size_t start,
try {
%% write exec;
} catch (LocatedParseError &error) {
// cppcheck-suppress pointerLessThanZero
// cppcheck-suppress pointerPositive
if (ts >= ptr && ts <= pe) {
error.locate(ts - ptr + start);
} else {

View File

@@ -37,6 +37,7 @@ namespace ue2 {
/** Class representing a component state. */
class PositionInfo {
public:
// cppcheck-suppress noExplicitConstructor
PositionInfo(unsigned int p) : pos(p), flags(0) {}
bool operator<(const PositionInfo &other) const {

View File

@@ -347,6 +347,7 @@ void prefilterTree(unique_ptr<Component> &root, const ParseMode &mode) {
assert(root);
PrefilterVisitor vis(root.get(), mode);
// cppcheck-suppress constVariablePointer
Component *c = root->accept(vis);
if (c != root.get()) {
root.reset(c);