Skip to content

Commit 24cd9bc

Browse files
sprandom: fix warning: comparison will always evaluate as true
The log_buf() macro checks whether the buffer is NULL, but in this case the variable is defined on the stack and can never be NULL. Use the low-level __log_buf() function to eliminate the warning. Fixes the following warning with 32-bit build: LDFLAGS="-m32" ./configure --disable-native --extra-cflags="-m32 -march=i386" && make sprandom.c: In function ‘print_d_array’: log.h:24:12: warning: the comparison will always evaluate as ‘true’ \ for the address of ‘out’ will never be NULL [-Waddress] if ((buf) != NULL) \ Reported-by: Sitsofe Wheeler <[email protected]> Signed-off-by: Tomas Winkler <[email protected]>
1 parent 80d72cb commit 24cd9bc

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sprandom.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ static void print_d_array(const char *hdr, double *darray, size_t len)
120120

121121
buf_output_init(&out);
122122

123-
log_buf(&out, "[");
123+
__log_buf(&out, "[");
124124
for (i = 0; i < len - 1; i++)
125-
log_buf(&out, "%.2f, ", darray[i]);
125+
__log_buf(&out, "%.2f, ", darray[i]);
126126

127-
log_buf(&out, "%.2f]\n", darray[len - 1]);
127+
__log_buf(&out, "%.2f]\n", darray[len - 1]);
128128
if (hdr)
129129
dprint(FD_SPRANDOM, "%s: ", hdr);
130130

@@ -139,11 +139,11 @@ static void print_d_points(struct point *parray, size_t len)
139139

140140
buf_output_init(&out);
141141

142-
log_buf(&out, "[");
142+
__log_buf(&out, "[");
143143
for (i = 0; i < len - 1; i++)
144-
log_buf(&out, "(%.2f %.2f), ", parray[i].x, parray[i].y);
144+
__log_buf(&out, "(%.2f %.2f), ", parray[i].x, parray[i].y);
145145

146-
log_buf(&out, "(%.2f %.2f)]\n", parray[len - 1].x, parray[len - 1].y);
146+
__log_buf(&out, "(%.2f %.2f)]\n", parray[len - 1].x, parray[len - 1].y);
147147
dprint(FD_SPRANDOM, "%s", out.buf);
148148
buf_output_free(&out);
149149
}

0 commit comments

Comments
 (0)