This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] Fixes for a small number of compiler warnings
- From: Ed Schouten <ed at nuxi dot nl>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 31 Mar 2015 16:47:10 +0200
- Subject: Re: [PATCH] Fixes for a small number of compiler warnings
- Authentication-results: sourceware.org; auth=none
- References: <CABh_MK=meHjQHZH9Cssu3xSgsrehcar0-COMZSJf0cHZTKxH4A at mail dot gmail dot com> <20150327000715 dot GY26234 at bubble dot grove dot modra dot org> <CABh_MKmxfVGU9b=vD9yHdUWXtkN7==Ptmu4h3izQPGCzsa=b=g at mail dot gmail dot com> <CAMe9rOrys_QG+0opphc9AXn5=Z-Df4Nk0WUFTJEy-dy_ux8Y=g at mail dot gmail dot com> <CABh_MKmKPHAfVo5Q2BkBnQuGFk-x+5a3j46KtXgF9_af2UHrCg at mail dot gmail dot com>
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