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]

concat and NULLs


Apparently NULL defined as a plain zero is acceptable according to the
ISO C standard.  So, for best portability we shouldn't pass NULL where
a pointer argument is expected in the variable argument part of a
function declared with an ellipsis.  Most of binutils already does
this.

binutils/
	* objdump.c (main): Don't pass unadorned NULL to concat.
gas/
	* read.c (s_weakref): Don't pass unadorned NULL to concat.
	* config/tc-i386.c (set_cpu_arch, md_parse_option): Likewise.
ld/
	* ldlang.c (new_afile): Don't pass unadorned NULL to concat.
	* ldfile.c (ldfile_add_library_path): Likewise.
	* emultempl/elf32.em (check_ld_elf_hints, check_ld_so_conf): Likewise.
	* emultempl/lnk960.em (lnk960_before_parse): Likewise.
	* emultempl/spuelf.em (embedded_spu_file): Likewise.

Index: binutils/objdump.c
===================================================================
RCS file: /cvs/src/src/binutils/objdump.c,v
retrieving revision 1.135
diff -u -p -r1.135 objdump.c
--- binutils/objdump.c	28 Jan 2008 15:15:32 -0000	1.135
+++ binutils/objdump.c	4 Feb 2008 00:24:03 -0000
@@ -1,6 +1,6 @@
 /* objdump.c -- dump information about an object file.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
@@ -3083,7 +3083,7 @@ main (int argc, char **argv)
 	  if (disassembler_options)
 	    /* Ignore potential memory leak for now.  */
 	    disassembler_options = concat (disassembler_options, ",",
-					   optarg, NULL);
+					   optarg, (const char *) NULL);
 	  else
 	    disassembler_options = optarg;
 	  break;
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.137
diff -u -p -r1.137 read.c
--- gas/read.c	25 Jan 2008 16:18:40 -0000	1.137
+++ gas/read.c	4 Feb 2008 00:24:08 -0000
@@ -3449,14 +3449,15 @@ s_weakref (int ignore ATTRIBUTE_UNUSED)
 	  char *loop;
 
 	  loop = concat (S_GET_NAME (symbolP),
-			 " => ", S_GET_NAME (symbolP2), NULL);
+			 " => ", S_GET_NAME (symbolP2), (const char *) NULL);
 
 	  symp = symbolP2;
 	  while (symp != symbolP)
 	    {
 	      char *old_loop = loop;
 	      symp = symbol_get_value_expression (symp)->X_add_symbol;
-	      loop = concat (loop, " => ", S_GET_NAME (symp), NULL);
+	      loop = concat (loop, " => ", S_GET_NAME (symp),
+			     (const char *) NULL);
 	      free (old_loop);
 	    }
 
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.325
diff -u -p -r1.325 tc-i386.c
--- gas/config/tc-i386.c	23 Jan 2008 19:05:11 -0000	1.325
+++ gas/config/tc-i386.c	4 Feb 2008 00:24:13 -0000
@@ -1784,7 +1784,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED
 		      char *name = cpu_sub_arch_name;
 		      cpu_sub_arch_name = concat (name,
 						  cpu_arch[i].name,
-						  NULL);
+						  (const char *) NULL);
 		      free (name);
 		    }
 		  else
@@ -7299,7 +7299,7 @@ md_parse_option (int c, char *arg)
 			  char *name = cpu_sub_arch_name;
 			  cpu_sub_arch_name = concat (name,
 						      cpu_arch[i].name,
-						      NULL);
+						      (const char *) NULL);
 			  free (name);
 			}
 		      else
Index: ld/ldfile.c
===================================================================
RCS file: /cvs/src/src/ld/ldfile.c,v
retrieving revision 1.43
diff -u -p -r1.43 ldfile.c
--- ld/ldfile.c	6 Jul 2007 14:09:41 -0000	1.43
+++ ld/ldfile.c	4 Feb 2008 00:24:24 -0000
@@ -113,7 +113,7 @@ ldfile_add_library_path (const char *nam
      now.  */
   if (name[0] == '=')
     {
-      new->name = concat (ld_sysroot, name + 1, NULL);
+      new->name = concat (ld_sysroot, name + 1, (const char *) NULL);
       new->sysrooted = TRUE;
     }
   else
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.280
diff -u -p -r1.280 ldlang.c
--- ld/ldlang.c	25 Jan 2008 17:34:29 -0000	1.280
+++ ld/ldlang.c	4 Feb 2008 00:24:29 -0000
@@ -944,7 +944,7 @@ new_afile (const char *name,
       p->is_archive = TRUE;
       p->filename = name;
       p->real = TRUE;
-      p->local_sym_name = concat ("-l", name, NULL);
+      p->local_sym_name = concat ("-l", name, (const char *) NULL);
       p->just_syms_flag = FALSE;
       p->search_dirs_flag = TRUE;
       break;
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.188
diff -u -p -r1.188 elf32.em
--- ld/emultempl/elf32.em	16 Sep 2007 18:55:23 -0000	1.188
+++ ld/emultempl/elf32.em	4 Feb 2008 00:24:29 -0000
@@ -13,7 +13,7 @@ fragment <<EOF
 
 /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME}
    Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    ELF support by Ian Lance Taylor <ian@cygnus.com>
 
@@ -556,7 +556,7 @@ gld${EMULATION_NAME}_check_ld_elf_hints 
       FILE *f;
       char *tmppath;
 
-      tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, NULL);
+      tmppath = concat (ld_sysroot, _PATH_ELF_HINTS, (const char *) NULL);
       f = fopen (tmppath, FOPEN_RB);
       free (tmppath);
       if (f != NULL)
@@ -776,11 +776,13 @@ gld${EMULATION_NAME}_check_ld_so_conf (c
 
       info.path = NULL;
       info.len = info.alloc = 0;
-      tmppath = concat (ld_sysroot, "${prefix}/etc/ld.so.conf", NULL);
+      tmppath = concat (ld_sysroot, "${prefix}/etc/ld.so.conf",
+			(const char *) NULL);
       if (!gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath))
 	{
 	  free (tmppath);
-	  tmppath = concat (ld_sysroot, "/etc/ld.so.conf", NULL);
+	  tmppath = concat (ld_sysroot, "/etc/ld.so.conf",
+			    (const char *) NULL);
 	  gld${EMULATION_NAME}_parse_ld_so_conf (&info, tmppath);
 	}
       free (tmppath);
Index: ld/emultempl/lnk960.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/lnk960.em,v
retrieving revision 1.23
diff -u -p -r1.23 lnk960.em
--- ld/emultempl/lnk960.em	19 Jul 2007 19:56:10 -0000	1.23
+++ ld/emultempl/lnk960.em	4 Feb 2008 00:24:29 -0000
@@ -3,7 +3,7 @@
 fragment <<EOF
 /* intel coff loader emulation specific stuff
    Copyright 1991, 1992, 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2003,
-   2005, 2007 Free Software Foundation, Inc.
+   2005, 2007, 2008 Free Software Foundation, Inc.
    Written by Steve Chamberlain steve@cygnus.com
 
    This file is part of the GNU Binutils.
@@ -94,7 +94,7 @@ lnk960_before_parse (void)
 	einfo ("%P%F I960BASE and G960BASE not set\n");
     }
 
-  ldfile_add_library_path (concat (name, "/lib", NULL), FALSE);
+  ldfile_add_library_path (concat (name, "/lib", (const char *) NULL), FALSE);
   ldfile_output_architecture = bfd_arch_i960;
   ldfile_output_machine = bfd_mach_i960_core;
 }
Index: ld/emultempl/spuelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/spuelf.em,v
retrieving revision 1.14
diff -u -p -r1.14 spuelf.em
--- ld/emultempl/spuelf.em	28 Jan 2008 05:59:24 -0000	1.14
+++ ld/emultempl/spuelf.em	4 Feb 2008 00:24:30 -0000
@@ -1,5 +1,5 @@
 # This shell script emits a C file. -*- C -*-
-#   Copyright 2006, 2007 Free Software Foundation, Inc.
+#   Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -353,9 +353,9 @@ embedded_spu_file (lang_input_statement_
 	if (strncmp (infile, "crtbegin", 8) == 0)
 	  {
 	    if (infile[8] == 'S')
-	      flags = concat (flags, " -fPIC", NULL);
+	      flags = concat (flags, " -fPIC", (const char *) NULL);
 	    else if (infile[8] == 'T')
-	      flags = concat (flags, " -fpie", NULL);
+	      flags = concat (flags, " -fpie", (const char *) NULL);
 	    break;
 	  }
       }

-- 
Alan Modra
Australia Development Lab, IBM


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