This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fixes for a small number of compiler warnings


2015-03-28 8:48 GMT+01:00 Ed Schouten <ed@nuxi.nl>:
> I'd suggest that we'd keep it simple for now and use just use {} here. Thoughts?

Attached is a formatted patch that changes the code to use {}.

-- 
Ed Schouten <ed@nuxi.nl>
From 5f2e0cb424a69804c8b16ed26c189154d674fafb Mon Sep 17 00:00:00 2001
From: Ed Schouten <ed@nuxi.nl>
Date: Tue, 31 Mar 2015 16:41:25 +0200
Subject: [PATCH] Fix a compiler warning that causes the build to fail with
 -Winit-self.

The ehdr_start_save variable does not need to be initialized. Not
initializing it will unfortunately trigger a compiler warning when using
older versions of GCC.

Change the code to use zero-initialization to prevent a compiler warning
when using -Winit-self. This also unbreaks the build when using Clang,
as Clang has a warning similar to -Winit-self as part of -Wall.
---
 ld/ChangeLog          | 6 ++++++
 ld/emultempl/elf32.em | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index 7b28014..45b6b17 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2015-03-31  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-31  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* configure.ac (AM_ZLIB): Removed.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 618e20a..2caddbe 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))
     {
-- 
2.3.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]