This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[patch] Initialize input_pos
- From: Mark Wielaard <mjw at redhat dot com>
- To: elfutils-devel at lists dot fedorahosted dot org
- Date: Thu, 27 Aug 2009 17:35:08 +0200
- Subject: [patch] Initialize input_pos
Hi,
My gcc cannot figure out how input_pos can always be initialized:
gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -I. -I/home/mark/src/elfutils/libdwfl
-I.. -I. -I/home/mark/src/elfutils/libdwfl
-I/home/mark/src/elfutils/libdwfl/../libelf
-I/home/mark/src/elfutils/libdwfl/../libebl
-I/home/mark/src/elfutils/libdwfl/../libdw -I..
-I/home/mark/src/elfutils/libdwfl/../lib -Wall -Werror -Wshadow
-Wunused -Wformat=2 -Wextra -std=gnu99 -g -O2 -MT bzip2.o -MD -MP
-MF .deps/bzip2.Tpo -c -o
bzip2.o /home/mark/src/elfutils/libdwfl/bzip2.c
cc1: warnings being treated as errors
In file included from /home/mark/src/elfutils/libdwfl/bzip2.c:4:
/home/mark/src/elfutils/libdwfl/gzip.c: In function ‘__libdw_bunzip2’:
/home/mark/src/elfutils/libdwfl/gzip.c:179: error: ‘input_pos’ may be
used uninitialized in this function
make[2]: *** [bzip2.o] Error 1
I think it is right. input_pos should be explicitly initialized to zero
when mmaped is set. The attached patch does this. OK to commit?
Thanks,
Mark
>From f1261197075984d56b76ca38df31307acd530bb8 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mjw@redhat.com>
Date: Thu, 27 Aug 2009 15:13:04 +0200
Subject: [PATCH] libdwfl/gzip.c (unzip): Initialize input_pos to zero when mmaped != NULL.
---
libdwfl/ChangeLog | 4 ++++
libdwfl/gzip.c | 2 ++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 9d2bf8c..19ede7e 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-27 Mark Wielaard <mjw@redhat.com>
+
+ * gzip.c (unzip): Initialize input_pos to zero when mmaped != NULL.
+
2009-08-26 Roland McGrath <roland@redhat.com>
* gzip.c (find_zImage_payload): New function, broken out of ...
diff --git a/libdwfl/gzip.c b/libdwfl/gzip.c
index daf250b..41893f5 100644
--- a/libdwfl/gzip.c
+++ b/libdwfl/gzip.c
@@ -210,6 +210,8 @@ unzip (int fd, off64_t start_offset,
mapped = input_buffer;
mapped_size = n;
}
+ else
+ input_pos = 0;
/* First, look at the header. */
if ((mapped_size <= sizeof MAGIC
--
1.6.2.5