[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gnulib] minor used-uninitialized bug in human.c
From: |
Jim Meyering |
Subject: |
[bug-gnulib] minor used-uninitialized bug in human.c |
Date: |
Sat, 09 Apr 2005 14:42:41 +0200 |
Hi Paul,
I've just found a little problem with human.c.
human.c:475: warning: 'opts' may be used uninitialized in this function
It's legitimate. You can exercise it like this:
DU_BLOCK_SIZE=lkjsdlkfj valgrind ./du -s /tmp
Without a function describing what humblock is intended to
do in this case, I made it set *options to zero.
Did you intend something else?
I've made this change in coreutils:
2005-04-09 Jim Meyering <address@hidden>
* human.c (humblock): Set *options even when returning due to
xstrtoumax conversion failure. Thanks to a used-uninitialized
warning from gcc-4.
Index: lib/human.c
===================================================================
RCS file: /fetish/cu/lib/human.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -p -u -r1.31 -r1.32
--- lib/human.c 9 Mar 2005 19:22:05 -0000 1.31
+++ lib/human.c 9 Apr 2005 12:35:41 -0000 1.32
@@ -451,7 +451,10 @@ humblock (char const *spec, uintmax_t *b
strtol_error e = xstrtoumax (spec, &ptr, 0, block_size,
"eEgGkKmMpPtTyYzZ0");
if (e != LONGINT_OK)
- return e;
+ {
+ *options = 0;
+ return e;
+ }
for (; ! ('0' <= *spec && *spec <= '9'); spec++)
if (spec == ptr)
{
- [bug-gnulib] minor used-uninitialized bug in human.c,
Jim Meyering <=