This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB 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]

[Patch] Fix binutils-gdb build with GCC 4.9 (was: Build problems with GIT version: ../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect)


Dear all,

GCC 4.9 (current GIT version) seems to warn now about
   bfd_set_section_userdata (stdoutput, seg, seginfo);
where the macro expands to "..., TRUE" (-Wunused-value)

And as binutils-gdb is compiled by default with "-Wall ... -Werror",
the build now fails.

That's fixed by the attached patch by adding (void) before those
'function' calls. (The macros are also called in context of "if(...)",
where the return value matters.)


Is the patch okay? If so, please commit. (It was tested by
building gdb into an empty directory.)


I haven't tried - but this patch or a very similar one probably
should do be added to the gdb 7.7 branch prior release. Maybe like
wise for binutils, depending how soon a branch release is planned
and whether also branches are build with -Werror.

Tobias


On Tue, Jan 28, 2014 at 09:25:17AM +0100, Tobias Burnus wrote:
> building the GIT version of binutils-gdb using GCC 4.9 fails as follows; it worked recently,
> albeit with a slightly older GCC 4.9.
> 
> The failure is:
> 
> make[4]: Entering directory `/data/local_users/tobiasb/gdb/binutils-gdb/build/gas'
> gcc -DHAVE_CONFIG_H -I. -I../../gas  -I. -I../../gas -I../bfd -I../../gas/config -I../../gas/../include -I../../gas/.. -I../../gas/../DIR="\"/data/local_users/tobiasb/gdb/gdb-inst/share/locale\""  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -gs.o -MD -MP -MF .deps/subsegs.Tpo -c -o subsegs.o ../../gas/subsegs.c
> In file included from ../../gas/as.h:95:0,
>                  from ../../gas/subsegs.c:25:
> ../../gas/subsegs.c: In function 'subseg_change':
> ../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
>  #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
>                                                                            ^
> ../../gas/subsegs.c:70:7: note: in expansion of macro 'bfd_set_section_userdata'
>        bfd_set_section_userdata (stdoutput, seg, seginfo);
>        ^
> ../../gas/subsegs.c: In function 'subseg_get':
> ../bfd/bfd.h:304:75: error: right-hand operand of comma expression has no effect [-Werror=unused-value]
>  #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
>                                                                            ^
> ../../gas/subsegs.c:172:7: note: in expansion of macro 'bfd_set_section_userdata'
>        bfd_set_section_userdata (stdoutput, secptr, seginfo);
>        ^
2014-01-29  Tobias Burnus  <burnus@net-b.de>

binutils/
	* objcopy.c (copy_object): Cast ignored result of macro function
	to void.
gas/
	* config/obj-elf.c (obj_elf_init_stab_section): Cast ignored result
	of macro function to void.
	* subsegs.c (subseg_change, subseg_get): Ditto.
	* write.c (record_alignment): Ditto.
gdb/
	* cli/cli-dump.c (dump_bfd_file): Cast ignored result of macro
	function to void.
	* dwarf2read.c (try_open_dwop_file): Ditto.
	* gcore.c (write_gcore_file, gcore_create_callback): Ditto.
	* gdb_bfd.c (get_section_descriptor): Ditto.
	* record-full.c (record_full_save): Ditto.
	* solib.c (solib_bfd_fopen): Ditto.
	* symfile.c (default_symfile_offsets, symfile_bfd_open): Ditto.
ld/
	* ldlang.c (lang_size_sections_1):


diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 9a6bb72..e6228a6 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1949,7 +1949,8 @@ copy_object (bfd *ibfd, bfd *obfd, const bfd_arch_info_type *input_arch)
 		/* Umm, not sure what to do in this case.  */
 		debuglink_vma = 0x1000;
 
-	      bfd_set_section_vma (obfd, gnu_debuglink_section, debuglink_vma);
+	      (void) bfd_set_section_vma (obfd, gnu_debuglink_section,
+					  debuglink_vma);
 	    }
 	}
     }
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 3377261..56fa8ea 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -1937,7 +1937,7 @@ obj_elf_init_stab_section (segT seg)
 
   /* Force the section to align to a longword boundary.  Without this,
      UnixWare ar crashes.  */
-  bfd_set_section_alignment (stdoutput, seg, 2);
+  (void) bfd_set_section_alignment (stdoutput, seg, 2);
 
   /* Make space for this first symbol.  */
   p = frag_more (12);
diff --git a/gas/subsegs.c b/gas/subsegs.c
index 69f837b..a25a777 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -67,7 +67,7 @@ subseg_change (register segT seg, register int subseg)
     {
       seginfo = (segment_info_type *) xcalloc (1, sizeof (*seginfo));
       seginfo->bfd_section = seg;
-      bfd_set_section_userdata (stdoutput, seg, seginfo);
+      (void) bfd_set_section_userdata (stdoutput, seg, seginfo);
     }
 }
 
@@ -169,7 +169,7 @@ subseg_get (const char *segname, int force_new)
       secptr->output_section = secptr;
       seginfo = (segment_info_type *) xcalloc (1, sizeof (*seginfo));
       seginfo->bfd_section = secptr;
-      bfd_set_section_userdata (stdoutput, secptr, seginfo);
+      (void) bfd_set_section_userdata (stdoutput, secptr, seginfo);
     }
   return secptr;
 }
diff --git a/gas/write.c b/gas/write.c
index 745abe6..d2c5fdb 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -363,7 +363,7 @@ record_alignment (/* Segment to which alignment pertains.  */
     return;
 
   if ((unsigned int) align > bfd_get_section_alignment (stdoutput, seg))
-    bfd_set_section_alignment (stdoutput, seg, align);
+    (void) bfd_set_section_alignment (stdoutput, seg, align);
 }
 
 int
diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c
index 005e207..e307be0 100644
--- a/gdb/cli/cli-dump.c
+++ b/gdb/cli/cli-dump.c
@@ -194,8 +194,8 @@ dump_bfd_file (const char *filename, const char *mode,
   obfd = bfd_openw_with_cleanup (filename, target, mode);
   osection = bfd_make_section_anyway (obfd, ".newsec");
   bfd_set_section_size (obfd, osection, len);
-  bfd_set_section_vma (obfd, osection, vaddr);
-  bfd_set_section_alignment (obfd, osection, 0);
+  (void) bfd_set_section_vma (obfd, osection, vaddr);
+  (void) bfd_set_section_alignment (obfd, osection, 0);
   bfd_set_section_flags (obfd, osection, (SEC_HAS_CONTENTS
 					  | SEC_ALLOC
 					  | SEC_LOAD));
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 54c538a..ef55924 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -10164,7 +10164,7 @@ try_open_dwop_file (const char *file_name, int is_dwp, int search_cwd)
   xfree (absolute_name);
   if (sym_bfd == NULL)
     return NULL;
-  bfd_set_cacheable (sym_bfd, 1);
+  (void) bfd_set_cacheable (sym_bfd, 1);
 
   if (!bfd_check_format (sym_bfd, bfd_object))
     {
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 67fbf30..6226d07 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -93,8 +93,8 @@ write_gcore_file (bfd *obfd)
     error (_("Failed to create 'note' section for corefile: %s"),
 	   bfd_errmsg (bfd_get_error ()));
 
-  bfd_set_section_vma (obfd, note_sec, 0);
-  bfd_set_section_alignment (obfd, note_sec, 0);
+  (void) bfd_set_section_vma (obfd, note_sec, 0);
+  (void) bfd_set_section_alignment (obfd, note_sec, 0);
   bfd_set_section_size (obfd, note_sec, note_size);
 
   /* Now create the memory/load sections.  */
@@ -466,7 +466,7 @@ gcore_create_callback (CORE_ADDR vaddr, unsigned long size, int read,
     }
 
   bfd_set_section_size (obfd, osec, size);
-  bfd_set_section_vma (obfd, osec, vaddr);
+  (void) bfd_set_section_vma (obfd, osec, vaddr);
   bfd_section_lma (obfd, osec) = 0; /* ??? bfd_set_section_lma?  */
   return 0;
 }
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 4d4b0a5..38aa9d4 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -345,7 +345,7 @@ get_section_descriptor (asection *section)
   if (result == NULL)
     {
       result = bfd_zalloc (section->owner, sizeof (*result));
-      bfd_set_section_userdata (section->owner, section, result);
+      (void) bfd_set_section_userdata (section->owner, section, result);
     }
 
   return result;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index 9a2b5e6..4f86b18 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -2726,8 +2726,8 @@ record_full_save (const char *recfilename)
 	   recfilename,
            bfd_errmsg (bfd_get_error ()));
   bfd_set_section_size (obfd, osec, save_size);
-  bfd_set_section_vma (obfd, osec, 0);
-  bfd_set_section_alignment (obfd, osec, 0);
+  (void) bfd_set_section_vma (obfd, osec, 0);
+  (void) bfd_set_section_alignment (obfd, osec, 0);
   bfd_section_lma (obfd, osec) = 0;
 
   /* Save corefile state.  */
diff --git a/gdb/solib.c b/gdb/solib.c
index 3350bfd..38faca8 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -396,7 +396,7 @@ solib_bfd_fopen (char *pathname, int fd)
       abfd = gdb_bfd_open (pathname, gnutarget, fd);
 
       if (abfd)
-	bfd_set_cacheable (abfd, 1);
+	(void) bfd_set_cacheable (abfd, 1);
     }
 
   if (!abfd)
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 06d2119..de2afda 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -751,7 +751,8 @@ default_symfile_offsets (struct objfile *objfile,
 	      if ((bfd_get_section_flags (abfd, cur_sec) & SEC_ALLOC) == 0)
 		continue;
 
-	      bfd_set_section_vma (abfd, cur_sec, offsets[cur_sec->index]);
+	      (void) bfd_set_section_vma (abfd, cur_sec,
+					  offsets[cur_sec->index]);
 	      exec_set_section_address (bfd_get_filename (abfd),
 					cur_sec->index,
 					offsets[cur_sec->index]);
@@ -1751,7 +1752,7 @@ symfile_bfd_open (const char *cname)
   if (!sym_bfd)
     error (_("`%s': can't open to read symbols: %s."), name,
 	   bfd_errmsg (bfd_get_error ()));
-  bfd_set_cacheable (sym_bfd, 1);
+  (void) bfd_set_cacheable (sym_bfd, 1);
 
   if (!bfd_check_format (sym_bfd, bfd_object))
     {
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 9903f70..e86045d 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -4866,9 +4866,10 @@ lang_size_sections_1
 			   " section %s\n"), os->name);
 
 		input = os->children.head->input_section.section;
-		bfd_set_section_vma (os->bfd_section->owner,
-				     os->bfd_section,
-				     bfd_section_vma (input->owner, input));
+		(void) bfd_set_section_vma (os->bfd_section->owner,
+					    os->bfd_section,
+					    bfd_section_vma (input->owner,
+							     input));
 		os->bfd_section->size = input->size;
 		break;
 	      }
@@ -4951,7 +4952,7 @@ lang_size_sections_1
 			     os->name, (unsigned long) (newdot - savedot));
 		  }
 
-		bfd_set_section_vma (0, os->bfd_section, newdot);
+		(void) bfd_set_section_vma (0, os->bfd_section, newdot);
 
 		os->bfd_section->output_offset = 0;
 	      }

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