aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2015-04-24 17:13:22 +0100
committerNick Clifton <nickc@redhat.com>2015-04-24 17:13:22 +0100
commitde13ef81f041f7f51687ef1873c74e853b97e73a (patch)
treeac4a0f49bc8e11516977363bba28319767a5fd31
parent7a5c933c7c2c3926b13a047c64f2af1d3ce8e1db (diff)
downloadgdb-de13ef81f041f7f51687ef1873c74e853b97e73a.zip
gdb-de13ef81f041f7f51687ef1873c74e853b97e73a.tar.gz
gdb-de13ef81f041f7f51687ef1873c74e853b97e73a.tar.bz2
Fix compile time warning messages about variables being used before they are initialised.
PR 18313 bin * ieee.c (ieee_read_cxx_class): Initialise the varargs variable. * readelf.c (uncompress_section_contents): Zero initialise the zstream structure. bfd * compress.c (decompress_contents): Zero initialse the z_stream structure.
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/compress.c9
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/ieee.c2
-rw-r--r--binutils/readelf.c9
5 files changed, 26 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 11a74de..87e22c2 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,11 @@
2015-04-24 Nick Clifton <nickc@redhat.com>
+ PR 18313
+ * compress.c (decompress_contents): Zero initialse the z_stream
+ structure.
+
+2015-04-24 Nick Clifton <nickc@redhat.com>
+
* elf.c (_bfd_elf_is_local_label_name): Extend test for assembler
local labels to include local labels with a numeric suffix and
fake symbols.
diff --git a/bfd/compress.c b/bfd/compress.c
index d0f745f..07289e5 100644
--- a/bfd/compress.c
+++ b/bfd/compress.c
@@ -37,9 +37,12 @@ decompress_contents (bfd_byte *compressed_buffer,
/* It is possible the section consists of several compressed
buffers concatenated together, so we uncompress in a loop. */
- strm.zalloc = NULL;
- strm.zfree = NULL;
- strm.opaque = NULL;
+ /* PR 18313: The state field in the z_stream structure is supposed
+ to be invisible to the user (ie us), but some compilers will
+ still complain about it being used without initialisation. So
+ we first zero the entire z_stream structure and then set the fields
+ that we need. */
+ memset (& strm, 0, sizeof strm);
strm.avail_in = compressed_size - 12;
strm.next_in = (Bytef*) compressed_buffer + 12;
strm.avail_out = uncompressed_size;
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index b0a5b1b..44c56b5 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2015-04-24 Nick Clifton <nickc@redhat.com>
+
+ PR 18313
+ * ieee.c (ieee_read_cxx_class): Initialise the varargs variable.
+ * readelf.c (uncompress_section_contents): Zero initialise the
+ zstream structure.
+
2015-04-23 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/18209
diff --git a/binutils/ieee.c b/binutils/ieee.c
index e93fcaa..a0d69d1 100644
--- a/binutils/ieee.c
+++ b/binutils/ieee.c
@@ -2954,7 +2954,7 @@ ieee_read_cxx_class (struct ieee_info *info, const bfd_byte **pp,
{
debug_type return_type;
const debug_type *arg_types;
- bfd_boolean varargs;
+ bfd_boolean varargs = FALSE;
if (debug_get_type_kind (dhandle, pv->type)
!= DEBUG_KIND_FUNCTION)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 1533806..dfa5c0b 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -12067,9 +12067,12 @@ uncompress_section_contents (unsigned char **buffer,
/* It is possible the section consists of several compressed
buffers concatenated together, so we uncompress in a loop. */
- strm.zalloc = NULL;
- strm.zfree = NULL;
- strm.opaque = NULL;
+ /* PR 18313: The state field in the z_stream structure is supposed
+ to be invisible to the user (ie us), but some compilers will
+ still complain about it being used without initialisation. So
+ we first zero the entire z_stream structure and then set the fields
+ that we need. */
+ memset (& strm, 0, sizeof strm);
strm.avail_in = compressed_size - header_size;
strm.next_in = (Bytef *) compressed_buffer + header_size;
strm.avail_out = uncompressed_size;