]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_daemon.c: "comparison between pointer and zero character constant" 818/head
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 12 Sep 2017 13:00:42 +0000 (14:00 +0100)
committerAlan Jenkins <alan.christopher.jenkins@gmail.com>
Tue, 12 Sep 2017 14:43:25 +0000 (15:43 +0100)
rrd_daemon.c: In function â€˜handle_request_list’:
rrd_daemon.c:2587:22: warning: comparison between pointer and zero character constant [-Wpointer-compare]
   } while (start_ptr != '\0');
                      ^~
rrd_daemon.c:2587:12: note: did you mean to dereference the pointer?
   } while (start_ptr != '\0');

I thought this might be related to what travis picked up with valgrind
here, but I couldn't reproduce it.  Also I don't think this commit fixes a
bug; all it's doing is cleaning up the compiler warning.

Starting rrdcached...
OK: empty directory ./list1_dir returns nothing
==23957== LEAK SUMMARY:
==23957==    definitely lost: 0 bytes in 0 blocks
==23957==    indirectly lost: 0 bytes in 0 blocks
==23957==      possibly lost: 0 bytes in 0 blocks
==23957==    still reachable: 14,712 bytes in 6 blocks
==23957==         suppressed: 0 bytes in 0 blocks
==23957==
==23957== For counts of detected and suppressed errors, rerun with: -v
==23957== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 2 from 2)
FAILED: (rc=valgrind error) single file /list1.rrd
FAIL: list1

src/rrd_daemon.c

index 3c18f5dcbe50259a0e1d1ec9887ef65a65289d54..e17d24dbc6653f690b88b9da9a65789511f68d82 100644 (file)
@@ -2522,16 +2522,12 @@ static int handle_request_list (HANDLER_PROTO) /* {{{ */
   start_ptr = list;
   end_ptr = list;
 
-  do {
+  while (*start_ptr != '\0') {
     end_ptr = strchr(start_ptr, '\n');
 
     if (end_ptr == NULL) {
        end_ptr = start_ptr + strlen(start_ptr);
-
-       if (end_ptr == start_ptr) {
-               break;
-       }
-         }
+  }
 
     if ((end_ptr - start_ptr + strlen(fullpath) + 1) >= PATH_MAX) {
       /* Name too long: skip entry */
@@ -2584,7 +2580,7 @@ static int handle_request_list (HANDLER_PROTO) /* {{{ */
 loop_next:
     start_ptr = end_ptr + 1;
 
-  } while (start_ptr != '\0');
+  }
 
   free(list);