From 1f364baa3a8ae5f3320ffc8fa2fd20856d90529e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wolfgang=20St=C3=B6ggl?= Date: Wed, 17 Jul 2019 12:36:30 +0200 Subject: [PATCH] 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] --- src/rrd_cgi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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; -- 2.47.2