From 14e8be8ab3db2d782484af9363d6adc351b95a0b Mon Sep 17 00:00:00 2001 From: Petr Uzel Date: Mon, 23 Apr 2012 10:43:38 +0200 Subject: 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 --- sys-utils/lscpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sys-utils/lscpu.c') diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index a4994b0cc..1adc92bad 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); } -- cgit v1.2.3-55-g7522