Build fixes for uninitialized variables.
authorUlrich Drepper <drepper@redhat.com>
Thu, 4 Oct 2007 18:40:28 +0000 (18:40 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 4 Oct 2007 18:40:28 +0000 (18:40 +0000)
Add some branch prediction.

libdwfl/ChangeLog
libdwfl/linux-kernel-modules.c
src/ChangeLog
src/readelf.c

index 454d934..d682f8f 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-04  Ulrich Drepper  <drepper@redhat.com>
+
+       * linux-kernel-modules.c (dwfl_linux_kernel_report_kernel): Fake
+       initialization of notes variable.
+
 2007-10-04  Roland McGrath  <roland@redhat.com>
 
        * linux-kernel-modules.c (intuit_kernel_bounds): Take new arg NOTES,
index 6164ae7..8954b2f 100644 (file)
@@ -501,6 +501,9 @@ dwfl_linux_kernel_report_kernel (Dwfl *dwfl)
   /* Try to figure out the bounds of the kernel image without
      looking for any vmlinux file.  */
   Dwarf_Addr notes;
+  /* The compiler cannot deduce that if intuit_kernel_bounds returns
+     zero NOTES will be initialized.  Fake the initialization.  */
+  asm ("" : "=m" (notes));
   int result = intuit_kernel_bounds (&start, &end, &notes);
   if (result == 0)
     {
index f4937cf..4d4fa9a 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-04  Ulrich Drepper  <drepper@redhat.com>
+
+       * readelf.c (dump_archive_index): Avoid warning about uninitialized
+       variable with older glibc versions.
+       Add some branch prediction.
+
 2007-10-04  Roland McGrath  <roland@redhat.com>
 
        * readelf.c (print_archive_index): New variable.
index fee908e..ffcb0a1 100644 (file)
@@ -5888,7 +5888,7 @@ print_strings (Ebl *ebl)
 {
   /* Get the section header string table index.  */
   size_t shstrndx;
-  if (elf_getshstrndx (ebl->elf, &shstrndx) < 0)
+  if (unlikely (elf_getshstrndx (ebl->elf, &shstrndx) < 0))
     error (EXIT_FAILURE, 0,
           gettext ("cannot get section header string table index"));
 
@@ -5921,7 +5921,7 @@ dump_archive_index (Elf *elf, const char *fname)
   if (arsym == NULL)
     {
       int result = elf_errno ();
-      if (result != ELF_E_NO_INDEX)
+      if (unlikely (result != ELF_E_NO_INDEX))
        error (EXIT_FAILURE, 0,
               gettext ("cannot get symbol index of archive '%s': %s"),
               fname, elf_errmsg (result));
@@ -5941,11 +5941,15 @@ dump_archive_index (Elf *elf, const char *fname)
          as_off = s->as_off;
 
          Elf *subelf;
-         if (elf_rand (elf, as_off) == 0
-             || (subelf = elf_begin (-1, ELF_C_READ_MMAP, elf)) == NULL)
-           error (EXIT_FAILURE, 0,
-                  gettext ("cannot extract member at offset %Zu in '%s': %s"),
-                  as_off, fname, elf_errmsg (-1));
+         if (unlikely (elf_rand (elf, as_off) == 0)
+             || unlikely ((subelf = elf_begin (-1, ELF_C_READ_MMAP, elf))
+                          == NULL))
+#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 7)
+           while (1)
+#endif
+             error (EXIT_FAILURE, 0,
+                    gettext ("cannot extract member at offset %Zu in '%s': %s"),
+                    as_off, fname, elf_errmsg (-1));
 
          const Elf_Arhdr *h = elf_getarhdr (subelf);