[PATCH] Fixes for a small number of compiler warnings

Ed Schouten ed@nuxi.nl
Thu Mar 26 16:13:00 GMT 2015


Hi there,

When building Binutils with FreeBSD's stock compiler (Clang 3.4.1), I
observe a small number of compiler warnings that get turned into
errors. More specifically:

- cpu_flags_set(): this function doesn't seem to be used.
- gld*_before_allocation(): we attempt to initialize a variable with
itself. It looks like there's no need to initialize this variable, as
its use is always guarded by ehdr_start.

Attached is a patch that fixes both these compiler warnings.

-- 
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-26  Ed Schouten  <ed@nuxi.nl>
+
+	* emultempl/elf32.em (gld*_before_allocation):
+	Fix warning related to self-assignment. The ehdr_start_save
+	variable does not need to be initialized explicitly.
+
 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