]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: fix possibly undefined operation
authorPetr Uzel <petr.uzel@suse.cz>
Mon, 23 Apr 2012 08:43:38 +0000 (10:43 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Apr 2012 12:05:29 +0000 (14:05 +0200)
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>
sys-utils/lscpu.c

index a4994b0cc6c5725c617c07de9c1e92a766f19a3a..1adc92bad35de5cdac40c75c47d5d62953744689 100644 (file)
@@ -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);
        }