PATCH to gdb/linux-nat.c

Gabriel Dos Reis gdr@cs.tamu.edu
Fri Feb 9 09:08:00 GMT 2007


Hi,

  This patchlet fixes the build failure

[...]
gcc -c -g -O2    -I. -I/home/gdr/redhat/src/gdb -I/home/gdr/redhat/src/gdb/config -DLOCALEDIR="\"/home/gdr/share/locale\"" -DHAVE_CONFIG_H -I/home/gdr/redhat/src/gdb/../include/opcode -I/home/gdr/redhat/src/gdb/../readline/.. -I../bfd -I/home/gdr/redhat/src/gdb/../bfd -I/home/gdr/redhat/src/gdb/../include   -DMI_OUT=1 -DTUI=1  -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wno-switch -Werror /home/gdr/redhat/src/gdb/linux-nat.c
cc1: warnings being treated as errors
/home/gdr/redhat/src/gdb/linux-nat.c: In function 'linux_nat_find_memory_regions':
/home/gdr/redhat/src/gdb/linux-nat.c:2556: warning: the address of 'filename' will always evaluate as 'true'
make[2]: *** [linux-nat.o] Error 1


for a native configuration on an i686-pc-linux-gnu and a build with
SVN GCC.  The problem is that the existing code was testing whether
the value of 'filename' is null.  That test is statically known to be
false since 'filename' is declared as a local array variable.

OK to apply?

-- Gaby

2007-02-09  Gabriel Dos Reis  <gdr@integrable-solutions.net>

	* linux-nat.c (linux_nat_find_memory_regions): Don't check the
	address of 'filename'; it is always non null.

Index: gdb/linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/linux-nat.c,v
retrieving revision 1.55
diff -p -r1.55 linux-nat.c
*** gdb/linux-nat.c	9 Jan 2007 17:58:51 -0000	1.55
--- gdb/linux-nat.c	9 Feb 2007 08:58:04 -0000
*************** linux_nat_find_memory_regions (int (*fun
*** 2553,2559 ****
  			    size, paddr_nz (addr),
  			    read ? 'r' : ' ',
  			    write ? 'w' : ' ', exec ? 'x' : ' ');
! 	  if (filename && filename[0])
  	    fprintf_filtered (gdb_stdout, " for %s", filename);
  	  fprintf_filtered (gdb_stdout, "\n");
  	}
--- 2553,2559 ----
  			    size, paddr_nz (addr),
  			    read ? 'r' : ' ',
  			    write ? 'w' : ' ', exec ? 'x' : ' ');
! 	  if (filename[0])
  	    fprintf_filtered (gdb_stdout, " for %s", filename);
  	  fprintf_filtered (gdb_stdout, "\n");
  	}



More information about the Gdb-patches mailing list