Fix compile time warning messages about variables being used before they are initialised.
authorNick Clifton <nickc@redhat.com>
Fri, 24 Apr 2015 16:13:22 +0000 (17:13 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 24 Apr 2015 16:13:22 +0000 (17:13 +0100)
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.

bfd/ChangeLog
bfd/compress.c
binutils/ChangeLog
binutils/ieee.c
binutils/readelf.c

index 11a74de981ed792b5d7ce699da8da705daf9a1da..87e22c2d6e6cc1d14c1686d714702c3689358cab 100644 (file)
@@ -1,3 +1,9 @@
+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
index d0f745fe6e1b10e72088fb5bbd5430469fd8d38f..07289e5d7d911bac897a653dd7f50ccb1d59b6b7 100644 (file)
@@ -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;
index b0a5b1b93a08ecd56860418d00193bca398396b0..44c56b5db31e22a0961df2b530e65484c40d64b9 100644 (file)
@@ -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
index e93fcaa7c55914ee6fd94c5b8a58cc1c38c522b7..a0d69d19ab9edf2afdcbdee52e8bfaa35037db0e 100644 (file)
@@ -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)
index 15338062180d6ca693e4186978ac32a9c6c58c13..dfa5c0b52d696ff2112bf941735625f0bbce5fdc 100644 (file)
@@ -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;
This page took 0.03716 seconds and 4 git commands to generate.