]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Fix rrd_cgi.c Cppcheck_warnings
authorWolfgang Stöggl <c72578@yahoo.de>
Wed, 17 Jul 2019 10:36:30 +0000 (12:36 +0200)
committerTobias Oetiker <tobi@oetiker.ch>
Wed, 17 Jul 2019 21:22:50 +0000 (23:22 +0200)
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

index 1bcf213fedf88d9614eeb33cc5ace32b93d4660b..779b84652e12504d6d937d85feb54f96ef8ca45d 100644 (file)
@@ -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;