Skip to content

Commit 4b42585

Browse files
committed
Cosmetics: fix cppcheck warnings
1 parent 8da787a commit 4b42585

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ cppcheck:
5959
@cppcheck -U YYSTYPE -U MBEDTLS_MD5_ALT -U MBEDTLS_SHA1_ALT \
6060
-D MS_CPPCHECK_DISABLED_FOR_PARSER \
6161
--suppressions-list=./test/cppcheck_suppressions.txt \
62-
--enable=all \
62+
--enable=warning,style,performance,portability,unusedFunction,missingInclude \
6363
--inconclusive \
6464
--template="warning: {file},{line},{severity},{id},{message}" \
6565
-I headers -I . -I others -I src -I others/mbedtls -I src/parser \

src/modsecurity.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
256256
strlen("highlight"));
257257

258258
yajl_gen_array_open(g);
259-
while (vars.size() > 0) {
259+
while (vars.size() > 3) {
260260
std::string value;
261261
yajl_gen_map_open(g);
262262
vars.pop_back();
@@ -303,7 +303,7 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
303303
varValue.size());
304304
yajl_gen_map_close(g);
305305

306-
while (trans.size() > 0) {
306+
while (!trans.empty()) {
307307
modsecurity::actions::transformations::Transformation *t;
308308
std::string varValueRes;
309309
yajl_gen_map_open(g);
@@ -338,7 +338,7 @@ int ModSecurity::processContentOffset(const char *content, size_t len,
338338

339339
yajl_gen_map_open(g);
340340

341-
while (ops.size() > 0) {
341+
while (ops.size() > 3) {
342342
std::string value;
343343
yajl_gen_string(g, reinterpret_cast<const unsigned char*>("highlight"),
344344
strlen("highlight"));

src/request_body_processor/json.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ int JSON::yajl_start_array(void *ctx) {
232232

233233
int JSON::yajl_end_array(void *ctx) {
234234
JSON *tthis = reinterpret_cast<JSON *>(ctx);
235-
if (tthis->m_containers.size() <= 0) {
235+
if (tthis->m_containers.empty()) {
236236
return 1;
237237
}
238238

@@ -266,7 +266,7 @@ int JSON::yajl_start_map(void *ctx) {
266266
*/
267267
int JSON::yajl_end_map(void *ctx) {
268268
JSON *tthis = reinterpret_cast<JSON *>(ctx);
269-
if (tthis->m_containers.size() <= 0) {
269+
if (tthis->m_containers.empty()) {
270270
return 1;
271271
}
272272

src/utils/geo_lookup.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ bool GeoLookup::setDataBase(const std::string& filePath,
9191
#endif
9292
err->append(".");
9393

94-
if (intMax.size() > 0) {
94+
if (!intMax.empty()) {
9595
err->append(" " + intMax);
9696

9797
}
98-
if (intGeo.size() > 0) {
98+
if (!intGeo.empty()) {
9999
err->append(" " + intGeo);
100100
}
101101
return false;

src/variables/web_app_id.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class WebAppId : public Variable {
3838
void evaluate(Transaction *transaction,
3939
RuleWithActions *rule,
4040
std::vector<const VariableValue *> *l) override {
41-
const std::string name("WEBAPPID");
4241
const std::string rname = transaction->m_rules->m_secWebAppId.m_value;
4342
l->push_back(new VariableValue(&m_name, &rname));
4443
}

test/cppcheck_suppressions.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ duplicateBranch:src/request_body_processor/multipart.cc:91
5151
syntaxError:src/transaction.cc:62
5252
noConstructor:src/variables/variable.h:152
5353
duplicateBranch:src/request_body_processor/multipart.cc:93
54+
knownConditionTrueFalse:src/utils/geo_lookup.cc:94
55+
knownConditionTrueFalse:src/utils/geo_lookup.cc:98
56+
danglingTempReference:src/modsecurity.cc:204
5457

5558
noExplicitConstructor:seclang-parser.hh
5659

@@ -61,3 +64,4 @@ preprocessorErrorDirective
6164
funcArgNamesDifferent
6265
unmatchedSuppression
6366
missingInclude
67+

0 commit comments

Comments
 (0)