ar, nm and drlink

Peter Naulls peter at chocky.org
Fri Mar 1 03:20:50 PST 2002


In message <m3bse92ye1.fsf at nick.ws.noc.dsvr.net>
          Nick Burrett <nick at dsvr.net> wrote:

> 
> I have committed implementations of `ar' and `nm' which I found
> sitting around on my hard disk from way back in 1999.
> 
> drlink was updated a couple of days ago to version 0.3.8, which
> is a synchronisation between GCCSDK and Dave Daniels.

What follows is warning fixes for programs under riscos-aof, including
the above.  The entirely of these fixes is unused functions/variables,
undeclared functions and uninitialised variables.  The only exception,
which I'd like a second opinon on is the bracketing in drlink - I'm
pretty sure the & should really be &&.

Peter

Index: riscos-aof/Makefile
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/Makefile,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 Makefile
--- riscos-aof/Makefile	2002/02/28 19:18:24	1.2.2.2
+++ riscos-aof/Makefile	2002/03/01 11:09:43
@@ -3,15 +3,18 @@
 
 export TLIB
 
+CFLAGS += -Werror -D_GNU_SOURCE
+
 ifeq (${STAGE},stage1)
 bin_dir=$(ux_gccpkg)/$(gn_standard_exec_prefix)
 gcc_bin_dir=$(ux_gccpkg)/$(gn_gcc_bin_dir)
 else
 bin_dir=$(ro_gccpkg)/$(gn_standard_exec_prefix)
 gcc_bin_dir=$(ro_gccpkg)/$(gn_gcc_bin_dir)
Index: riscos-aof/as/commands.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/commands.c,v
retrieving revision 1.3.2.3
diff -u -r1.3.2.3 commands.c
--- riscos-aof/as/commands.c	2001/12/12 14:57:07	1.3.2.3
+++ riscos-aof/as/commands.c	2002/03/01 11:09:44
@@ -15,6 +15,7 @@
 #endif
 
 #include "commands.h"
+#include "depend.h"
 #include "error.h"
 #include "input.h"
 #include "output.h"
Index: riscos-aof/as/lex.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/lex.c,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 lex.c
--- riscos-aof/as/lex.c	2001/12/12 14:57:07	1.3.2.2
+++ riscos-aof/as/lex.c	2002/03/01 11:09:45
@@ -6,6 +6,7 @@
 #include <ctype.h>
 #include <math.h>
 #include <string.h>
+#include <stdlib.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #elif HAVE_INTTYPES_H
@@ -20,6 +21,7 @@
 #include "hash.h"
 #include "symbol.h"
 #include "area.h"
+#include "os.h"
 
 extern int gcc_backend;
 extern int objasm;
Index: riscos-aof/as/local.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/local.c,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 local.c
--- riscos-aof/as/local.c	2001/12/12 14:57:07	1.2.2.1
+++ riscos-aof/as/local.c	2002/03/01 11:09:45
@@ -4,6 +4,7 @@
  */
 #include "sdk-config.h"
 #include <string.h>
+#include <stdlib.h>
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #elif HAVE_INTTYPES_H
@@ -15,6 +16,7 @@
 #include "asm.h"
 #include "input.h"
 #include "variables.h"
+#include "os.h"
 
 typedef struct localPos
   {
Index: riscos-aof/as/macros.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/macros.c,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 macros.c
--- riscos-aof/as/macros.c	2001/12/12 14:57:07	1.3.2.1
+++ riscos-aof/as/macros.c	2002/03/01 11:09:46
@@ -19,6 +19,7 @@
 #include <stdlib.h>
 #include <ctype.h>
 #include "variables.h"
+#include "os.h"
 
 #define MACRO_LIMIT 16
 #define MACRO_DEPTH 10
Index: riscos-aof/as/os.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/os.h,v
retrieving revision 1.3.2.1
diff -u -r1.3.2.1 os.h
--- riscos-aof/as/os.h	2001/12/12 16:12:37	1.3.2.1
+++ riscos-aof/as/os.h	2002/03/01 11:09:46
@@ -6,6 +6,7 @@
 #ifndef __os_h
 #define __os_h
 #include <stdio.h>
+#include <string.h>
 
 #ifdef CROSS_COMPILE
 /* UNIX specific information.  */
@@ -56,6 +57,8 @@
 #endif /* __riscos */
 
 char *CanonicaliseFile (const FILE * path);
+#ifndef strndup
 char *strndup (const char *, int len);
+#endif
 
 #endif
Index: riscos-aof/as/strdup.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/strdup.c,v
retrieving revision 1.1.1.1.2.2
diff -u -r1.1.1.1.2.2 strdup.c
--- riscos-aof/as/strdup.c	2001/12/12 16:12:37	1.1.1.1.2.2
+++ riscos-aof/as/strdup.c	2002/03/01 11:09:46
@@ -8,6 +8,7 @@
 #include "os.h"
 #include "error.h"
 
+#ifndef strndup
 char *
 strndup (const char *str, int len)
 {
@@ -21,3 +22,4 @@
     }
   return c;
 }
+#endif
Index: riscos-aof/as/value.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/value.c,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 value.c
--- riscos-aof/as/value.c	2001/12/12 14:57:07	1.2.2.1
+++ riscos-aof/as/value.c	2002/03/01 11:09:46
@@ -15,6 +15,7 @@
 #include "value.h"
 #include "code.h"
 #include "error.h"
+#include "os.h"
 
 /* Code demands at least one Lateinfo */
 Value valueLateToCode(int offset,LateInfo *late)
Index: riscos-aof/as/version.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/as/version.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 version.h
--- riscos-aof/as/version.h	2000/11/08 09:38:57	1.1.1.1
+++ riscos-aof/as/version.h	2002/03/01 11:09:46
@@ -1,3 +1,4 @@
+#undef VERSION
 #define VERSION \
   "AS v1.30, " __DATE__ "\n"
 #ifdef CROSS_COMPILE
Index: riscos-aof/drlink/areas.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/areas.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 areas.c
--- riscos-aof/drlink/areas.c	2002/02/26 07:35:33	1.1.2.2
+++ riscos-aof/drlink/areas.c	2002/03/01 11:09:53
@@ -653,7 +653,7 @@
 ** files
 */
 bool scan_head(filelist *fp) {
-  arealist *ap;		/* Points at arealist entry created for entry being checked */
+  arealist *ap = NULL;  /* Points at arealist entry created for entry being checked */
   objheadhdr *ahp;	/* Points at OBJ_HEAD chunk of file */
   areaentry
    *aep,			/* Points at OBJ_HEAD entry being checked */
@@ -1426,7 +1426,7 @@
 */
 static void fixup_type2(unsigned int reltypesym, unsigned int *relplace) {
   unsigned int reltype, relvalue, symtindex;
-  symtentry *sp;
+  symtentry *sp = NULL;
   arealist *ap;
   reltype = get_type2_type(reltypesym);
   if ((reltype & REL_SYM)!=0) {	/* Symbol relocation */
@@ -1584,8 +1584,8 @@
  * () to it
  */
   noheader = imagetype==RMOD 
-   || imagetype==BIN &&
-    (entryarea==rocodelist || (rodatalist==NIL && entryarea==rwcodelist)) && entryoffset==0
+   || (imagetype==BIN &&
+    (entryarea==rocodelist || (rodatalist==NIL && entryarea==rwcodelist)) && entryoffset==0)
    || opt_codebase;
 }
 
@@ -1983,6 +1983,8 @@
     break;
   case TYPE2_AP: /* Area, PC-rel */
     flags = flags & (REL_AOFMASK | REL_PC);
+  default:
+    break;
   }
   rp->reltypesym = flags<<24 | REL_TYPE2 | sid;
 }
@@ -2034,6 +2036,8 @@
           break;
         case TYPE2_RP:	/* Cannot do relocation, but modify offset in instruction */
           alter_area_offset(rp);
+        default:
+          break;
         }
         rp++;
       }
Index: riscos-aof/drlink/drlmain.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/drlmain.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 drlmain.c
--- riscos-aof/drlink/drlmain.c	2002/02/26 07:35:33	1.1.2.2
+++ riscos-aof/drlink/drlmain.c	2002/03/01 11:09:54
@@ -185,7 +185,7 @@
   do {
     if (option) *cp = tolower(*cp);
     cp++;
-  } while (cp!=cvptrend && ((terminator=='"' && *cp!='"') || (terminator==' ' & *cp>' ')));
+  } while (cp!=cvptrend && ((terminator=='"' && *cp!='"') || (terminator==' ' && *cp>' ')));
   if (terminator=='"' && cp==cvptrend) {	/* " missing */
     error("Error: Unmatched '\"' found");
     cvptr = cp;
@@ -695,6 +695,8 @@
     break;
   case NOSUPPORT:
     error("Fatal: 'link' option '%s' is not supported", op);
+  default:
+    break;  
   }
   return ok;
 }
@@ -736,6 +738,8 @@
   case AOF:
     if (imagename==NIL) imagename = "aof";
     opt_nounused = FALSE;
+  default:
+    break;  
   }
   if (imagename==NIL) imagename = "!RunImage";
   opt_verbose = opt_verbose && !opt_quiet;
Index: riscos-aof/drlink/files.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/files.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 files.c
--- riscos-aof/drlink/files.c	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/files.c	2002/03/01 11:09:57
@@ -580,6 +580,8 @@
       ok = TRUE;
     }
     break;
+  default:
+    break;  
   }
   return ok;
 }
@@ -956,7 +958,8 @@
     break;
   case LIBRARY:
     error("Error: '%s' is a library. Nested libraries are not supported", membername);
-    break;
+  default:
+    break;  
   }
   return fp;
 }
@@ -980,6 +983,7 @@
     break;
   case LIBRARY:
     error("Error: '%s' is a library. Nested libraries are not supported", objectname);
+  default:
     break;
   }
   filebase = oldbase;
Index: riscos-aof/drlink/linkedit.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/linkedit.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 linkedit.c
--- riscos-aof/drlink/linkedit.c	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/linkedit.c	2002/03/01 11:09:59
@@ -251,6 +251,8 @@
     break;
   case EDT_ENTRY:
     new_entry = p;
+  default:
+    break;  
   }
   return TRUE;
 }
Index: riscos-aof/drlink/symbols.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/symbols.c,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 symbols.c
--- riscos-aof/drlink/symbols.c	2002/02/26 07:35:33	1.1.2.3
+++ riscos-aof/drlink/symbols.c	2002/03/01 11:10:02
@@ -209,6 +209,8 @@
         else {
           error("Warning: Symbol '%s' in '%s' is already a 'global' symbol", symtp->symtname, ep->edtfile);
         }
+      default:
+        break;  
       }
     }
     ep = ep->edtnext;
Index: riscos-aof/ld/ld.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/ld/ld.c,v
retrieving revision 1.7.2.7
diff -u -r1.7.2.7 ld.c
--- riscos-aof/ld/ld.c	2002/02/24 18:29:08	1.7.2.7
+++ riscos-aof/ld/ld.c	2002/03/01 11:10:07
@@ -25,7 +25,6 @@
    define CROSS_COMPILE.  */
 
 #include "sdk-config.h"
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdarg.h>
 #include <stddef.h>
@@ -354,11 +353,13 @@
 
 /* Free a hash table.  */
 
+#if 0
 static void
 hash_table_free (struct hash_table *table)
 {
   obstack_free (&table->memory, (void *) NULL);
 }
+#endif
 
 /* Look up a string in a hash table.  */
 
@@ -447,6 +448,7 @@
 
 /* Traverse a hash table.  */
 
+#if 0
 static void
 hash_traverse (struct hash_table *table,
 	       boolean (*func) (struct hash_entry *, void *),
@@ -465,6 +467,7 @@
 	}
     }
 }
+#endif
 
 typedef struct symbol_hash_entry
 {
@@ -680,10 +683,12 @@
 tlink_execute (char *prog, char **argv, char *redir, char *viafile)
 {
   char *command, *temp;
-  char **p_argv, *str, *s, filename[256];
+  char **p_argv, *str, *s = NULL, filename[256];
   FILE *handle;
   int system_result, command_size;
+#ifdef __riscos__
   pid_t pid;
+#endif
 
   /* Reserve some space for the command line.  */
   command_size = 512;
@@ -850,7 +855,7 @@
   if (tlink_verbose >= 3)
     printf ("Command line to execute: '%s'\n", command);
 
-#ifdef __riscos
+#ifdef __riscos__
   pid = vfork ();
   if (pid == (pid_t) 0)
     {
@@ -1348,7 +1353,7 @@
     temp_filename[len++] = '/';
   strcpy (temp_filename + len, "ccXXXXXX");
 
-  mktemp (temp_filename);
+  mkstemp (temp_filename);
 }
 
 static void
@@ -1564,8 +1569,6 @@
 static int check_and_add_library (const char *file_name)
 {
   char converted[256], *temp;
-  int regs[6];
-  struct stat f;
 
 #ifdef CROSS_COMPILE
   temp = strcpy (converted, file_name);
@@ -1605,7 +1608,7 @@
           && list->name[i] != '/')
         strcat (file_name, "/");
 
-#ifdef CROSS_COMPILE 
+#ifdef CROSS_COMPILE
       strcat (file_name, "lib"); 
       strcat (file_name, library); 
       strcat (file_name, ".a"); 
@@ -1682,7 +1685,9 @@
 
 static void add_input_file (const char *fname)
 {
+#ifndef CROSS_COMPILE
   char tmp[256];
+#endif
 
   if (tlink_verbose >= 4)
     printf ("adding object file %s\n", fname);
Index: riscos-aof/nm/nm.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/nm/Attic/nm.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 nm.c
--- riscos-aof/nm/nm.c	2002/02/28 19:18:24	1.1.2.1
+++ riscos-aof/nm/nm.c	2002/03/01 11:10:08
@@ -4,7 +4,9 @@
 #include <getopt.h>
 #include "libiberty.h"
 
+#ifndef LITTLE_ENDIAN
 #define LITTLE_ENDIAN 1
+#endif
 #define NM_VERSION "1.00"
 
 static void nm_help (void);
@@ -252,7 +254,7 @@
 struct chunkent *
 read_chunkents (FILE *ifp, struct chunkhdr *hdr)
 {
-  register i;
+  register int i;
 
   if (ents)
     free (ents);
@@ -292,7 +294,7 @@
 struct symbol *
 read_symboltab (FILE *ifp, struct chunkent *syment, int numsyms)
 {
-  register i;
+  register int i;
 
   if (symptr)
     free (symptr);
@@ -331,7 +333,7 @@
 struct aofhdr *
 read_aofhdr (FILE *ifp, struct chunkent *hdrent)
 {
-  register i;
+  register int i;
   struct areahdr *areahdr;
 
   if (aofhdr)
@@ -403,9 +405,9 @@
   FILE *handle;
   struct chunkhdr *hdr;
   struct chunkent *ents, *ent;
-  struct aofhdr *aofhdr;
-  struct symbol *symboltab;
-  char *stringtab;
+  struct aofhdr *aofhdr = NULL;
+  struct symbol *symboltab = NULL;
+  char *stringtab = NULL;
   long area_offset;
   long symboltab_size;
 


-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 RISC OS Projects Initiative  -  http://www.chocky.org/initiative/
 Java for RISC OS and ARM     -  http://www.chocky.org/java/
 Debian Linux on RiscPCs      -  http://www.chocky.org/debian/
------------------------------------------------------------------------



More information about the gcc mailing list