From: Petr Uzel Date: Mon, 23 Apr 2012 08:43:38 +0000 (+0200) Subject: lscpu: fix possibly undefined operation X-Git-Tag: v2.22-rc1~489 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=14e8be8ab3db2d782484af9363d6adc351b95a0b;p=thirdparty%2Futil-linux.git lscpu: fix possibly undefined operation With -Wall -Werror, compilation of lscpu.c fails with: Making all in sys-utils make[2]: Entering directory `/home/petr/upstream/util-linux/sys-utils' gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -include ../config.h -I../include -DLOCALEDIR=\"/usr/share/locale\" -fsigned-char -Wall -Werror -MT lscpu.o -MD -MP -MF .deps/lscpu.Tpo -c -o lscpu.o lscpu.c lscpu.c: In function ‘print_parsable’: lscpu.c:971:7: error: operation on ‘p’ may be undefined [-Werror=sequence-point] cc1: all warnings being treated as errors Fix by splitting the pointer increment to separate statement. Signed-off-by: Petr Uzel --- diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index a4994b0cc6..1adc92bad3 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -967,8 +967,10 @@ print_parsable(struct lscpu_desc *desc, int cols[], int ncols, */ char *p = data + 1; - while (p && *p != '\0') - *p++ = tolower((unsigned int) *p); + while (p && *p != '\0') { + *p = tolower((unsigned int) *p); + p++; + } } fputs(data && *data ? data : "", stdout); }