From: Alan Jenkins Date: Tue, 12 Sep 2017 13:00:42 +0000 (+0100) Subject: src/rrd_daemon.c: "comparison between pointer and zero character constant" X-Git-Tag: v1.7.1~109^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e6c14a4f457265e1036156f975120a0e7b9bcf54;p=thirdparty%2Frrdtool-1.x.git src/rrd_daemon.c: "comparison between pointer and zero character constant" 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 --- diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index 3c18f5dc..e17d24db 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -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);