[PATCH] Fixes for a small number of compiler warnings

Ed Schouten ed@nuxi.nl
Fri Mar 27 06:01:00 GMT 2015


2015-03-27 1:07 GMT+01:00 Alan Modra <amodra@gmail.com>:
> This was last changed by commit f9c316c4, which says
>     Silence uninitialized warning on ehdr_start_save
>
>     Older GCC, like 4.1/4.2, will issue an uninitialized warning on
>     ehdr_start_save.  This patch silences by using
>
>     struct bfd_link_hash_entry ehdr_start_save = ehdr_start_save;
>
> Blah.  A warning fix for an older gcc that causes a warning in a
> newer compiler.

Ah, I see. Still, no problem. We can just zero-initialize it. Attached
is an updated patch.

Thanks,
-- 
Ed Schouten <ed@nuxi.nl>
-------------- next part --------------
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 4a43a66..6f03644 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-26  Ed Schouten  <ed@nuxi.nl>
+
+	* config/tc-i386.c (cpu_flags_set): Remove unused function.
+
 2015-03-25  Renlin Li  <renlin.li@arm.com>
 
 	* config/tc-aarch64.c (mapping_state): Remove first MAP_DATA emitting
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index d710216..8266134 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -1382,23 +1382,6 @@ cpu_flags_all_zero (const union i386_cpu_flags *x)
     }
 }
 
-static INLINE void
-cpu_flags_set (union i386_cpu_flags *x, unsigned int v)
-{
-  switch (ARRAY_SIZE(x->array))
-    {
-    case 3:
-      x->array[2] = v;
-    case 2:
-      x->array[1] = v;
-    case 1:
-      x->array[0] = v;
-      break;
-    default:
-      abort ();
-    }
-}
-
 static INLINE int
 cpu_flags_equal (const union i386_cpu_flags *x,
 		 const union i386_cpu_flags *y)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 3a5edf2..31ade77 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-27  Ed Schouten  <ed@nuxi.nl>
+
+	* emultempl/elf32.em (gld*_before_allocation):
+	Fix warning related to self-assignment. Simply zero-initialize
+	the ehdr_start_save variable.
+
 2015-03-24  Marcus Shawcroft  <marcus.shawcroft@arm.com>
 
 	* emultempl/aarch64elf.em (_aarch64_add_stub_section): Set section
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 618e20a..ece2fb0 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1412,7 +1412,7 @@ gld${EMULATION_NAME}_before_allocation (void)
   asection *sinterp;
   bfd *abfd;
   struct elf_link_hash_entry *ehdr_start = NULL;
-  struct bfd_link_hash_entry ehdr_start_save = ehdr_start_save;
+  struct bfd_link_hash_entry ehdr_start_save = {};
 
   if (is_elf_hash_table (link_info.hash))
     {


More information about the Binutils mailing list