]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Fix build when missing -lz and -lbz2.
authorRoland McGrath <roland@redhat.com>
Thu, 22 Jan 2009 20:59:23 +0000 (12:59 -0800)
committerRoland McGrath <roland@redhat.com>
Thu, 22 Jan 2009 20:59:23 +0000 (12:59 -0800)
libdwfl/ChangeLog
libdwfl/open.c

index 87e2b48d7ea822a272dfc1de3d5327cf4ddbb1db..5490f5f0f63fc672281547c69bfcfeccd590d442 100644 (file)
@@ -1,5 +1,7 @@
 2009-01-22  Roland McGrath  <roland@redhat.com>
 
+       * open.c (decompress): Move BUFFER, SIZE decls outside #if.
+
        * dwfl_segment_report_module.c (addr_segndx): Remove bogus adjustments
        after address-matching loop.
 
index ca6b862fad8bbb0b9a1ef6ff8eb6d93dcfbf7e90..611295f2addafa541cae1720a73a6dcc1518885a 100644 (file)
 /* Always consumes *ELF, never consumes FD.
    Replaces *ELF on success.  */
 static Dwfl_Error
-decompress (int fd, Elf **elf)
+decompress (int fd __attribute__ ((unused)), Elf **elf)
 {
   Dwfl_Error error = DWFL_E_BADELF;
+  void *buffer = NULL;
+  size_t size = 0;
 
 #if USE_ZLIB || USE_BZLIB
-  void *buffer;
-  size_t size;
-
   const off64_t offset = (*elf)->start_offset;
   void *const mapped = ((*elf)->map_address == NULL ? NULL
                        : (*elf)->map_address + (*elf)->start_offset);
@@ -87,14 +86,22 @@ decompress (int fd, Elf **elf)
 
   if (error == DWFL_E_NOERROR)
     {
-      *elf = elf_memory (buffer, size);
-      if (*elf == NULL)
+      if (unlikely (size == 0))
        {
-         error = DWFL_E_LIBELF;
+         error = DWFL_E_BADELF;
          free (buffer);
        }
       else
-       (*elf)->flags |= ELF_F_MALLOCED;
+       {
+         *elf = elf_memory (buffer, size);
+         if (*elf == NULL)
+           {
+             error = DWFL_E_LIBELF;
+             free (buffer);
+           }
+         else
+           (*elf)->flags |= ELF_F_MALLOCED;
+       }
     }
 
   return error;