From: Petr Uzel <petr.uzel@suse.cz>
To: util-linux <util-linux@vger.kernel.org>
Subject: [PATCH] lscpu: fix possibly undefined operation
Date: Mon, 23 Apr 2012 10:43:38 +0200 [thread overview]
Message-ID: <1335170618-10133-1-git-send-email-petr.uzel@suse.cz> (raw)
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 | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index 1c2d9b6..f4a06e6 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);
}
--
1.7.7
next reply other threads:[~2012-04-23 8:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-23 8:43 Petr Uzel [this message]
2012-04-23 12:09 ` [PATCH] lscpu: fix possibly undefined operation Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1335170618-10133-1-git-send-email-petr.uzel@suse.cz \
--to=petr.uzel@suse.cz \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox