From: Wolfgang Stöggl Date: Wed, 17 Jul 2019 10:36:30 +0000 (+0200) Subject: Fix rrd_cgi.c Cppcheck_warnings X-Git-Tag: v1.8.0~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f364baa3a8ae5f3320ffc8fa2fd20856d90529e;p=thirdparty%2Frrdtool-1.x.git Fix rrd_cgi.c Cppcheck_warnings Remove the identical inner 'if' condition. Use the %zu format specifier for size_t returned from strlen(), according to: https://en.cppreference.com/w/c/string/byte/strlen - Fixes the following Cppcheck warnings: [src/rrd_cgi.c:349] (warning) Identical inner 'if' condition is always true (outer condition is 'calcpr[i]' and inner condition is 'calcpr[i]'). [identicalInnerCondition] [src/rrd_cgi.c:527] (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint] or [src/rrd_cgi.c:527] (portability) %zd in format string (no. 1) requires 'ssize_t' but the argument type is 'size_t {aka unsigned long long}'. [invalidPrintfArgType_sint] --- diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 1bcf213f..779b8465 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -346,9 +346,7 @@ static void calfree( long i; for (i = 0; calcpr[i]; i++) { - if (calcpr[i]) { - free(calcpr[i]); - } + free(calcpr[i]); } if (calcpr) { free(calcpr); @@ -525,7 +523,7 @@ int main( if (!filter) { printf("Content-Type: text/html\n" - "Content-Length: %zd\n", strlen(buffer)); + "Content-Length: %zu\n", strlen(buffer)); if (labs(goodfor) > 0) { time_t now;