diff options
author | Petr Uzel <petr.uzel@suse.cz> | 2012-04-23 10:43:38 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2012-04-23 14:05:29 +0200 |
commit | 14e8be8ab3db2d782484af9363d6adc351b95a0b (patch) | |
tree | 4e94da9deb35f3084114662f833a447d5a412b98 /sys-utils/lscpu.c | |
parent | 4f83dcceba66278378c5e759e56b4d48368bb796 (diff) | |
download | util-linux-14e8be8ab3db2d782484af9363d6adc351b95a0b.tar.gz |
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 <petr.uzel@suse.cz>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r-- | sys-utils/lscpu.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index a4994b0c..1adc92ba 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); } |