drlink warning fixes

Peter Naulls peter at chocky.org
Sat Mar 30 07:37:56 PST 2002


This is mostly the usual static/const/signed fixes.

Two things are worth nothing though - using %08p isn't really
valid, and causes GCC to moan.  Just %p is quite sufficient. The C++
name handling is slightly rearranged so that the const char pointers
work correctly.


Index: riscos-aof/drlink/aofiles.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/Attic/aofiles.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 aofiles.c
--- riscos-aof/drlink/aofiles.c	2002/02/26 07:38:19	1.1.2.1
+++ riscos-aof/drlink/aofiles.c	2002/03/30 15:13:10
@@ -25,7 +25,7 @@
 
 typedef struct newhead {
   int headhash;				/* Hashed version of area name */
-  char *headname;			/* Pointer to name of area */
+  const char *headname;			/* Pointer to name of area */
   unsigned int headattr;		/* Area's attributes */
   struct newhead *headflink;		/* Next area in list */
 } newhead;
@@ -39,7 +39,7 @@
  } newsymt;

 typedef struct strtentry {
-  char *strtname;			/* Pointer to name */
+  const char *strtname;			/* Pointer to name */
   int strthash;				/* Name's hash value */
   unsigned int strtoffset;		/* Name's offset within the OBJ_STRT chunk */
   struct strtentry *strtnext;		/* Next entry in order of creation */
@@ -77,7 +77,7 @@
 /*
 ** 'init_aofile' initialises things concerning the AOF file
 */
-void init_aofile(void) {
+static void init_aofile(void) {
   int n;
   head_start = head_size = 0;
   area_start = area_size = 0;
@@ -104,7 +104,7 @@
 ** they are linked together in the order they are created for when
 ** the actual OBJ_STRT is built.
 */
-static unsigned int addto_strt(char *name) {
+static unsigned int addto_strt(const char *name) {
   strtentry *p;
   int hashval;
   hashval = hash(name);
@@ -182,7 +182,7 @@
 ** It also calculates the size of the new OBJ_HEAD chunk as
 ** this is known at this point.
 */
-static void reloc_aofareas() {
+static void reloc_aofareas(void) {
   reloc_aofarlist(rocodelist);
   reloc_aofarlist(rodatalist);
   reloc_aofarlist(rwcodelist);
@@ -200,7 +200,7 @@
   newhead *hp;
   unsigned int index;
   int hash;
-  char *name;
+  const char *name;
   unsigned int attr;
   name = ap->arname;
   attr = ap->aratattr;
Index: riscos-aof/drlink/areahdr.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/areahdr.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 areahdr.h
--- riscos-aof/drlink/areahdr.h	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/areahdr.h	2002/03/30 15:13:10
@@ -86,7 +86,7 @@
 */
 typedef struct arealist {
   int arhash;				/* Area name's hash value */
-  char *arname;				/* Pointer to area name in loaded OBJ_STRT chunk */
+  const char *arname;			/* Pointer to area name in loaded OBJ_STRT chunk */
   struct arealist *arbase;		/* Pointer to first area with same name */
   struct arealist *arlast;		/* Pointer to last area with same name or nil */
   struct filelist *arfileptr;		/* Pointer to area's file's file list entry */
Index: riscos-aof/drlink/areas.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/areas.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 areas.c
--- riscos-aof/drlink/areas.c	2002/03/07 17:37:32	1.1.2.4
+++ riscos-aof/drlink/areas.c	2002/03/30 15:13:15
@@ -161,7 +161,7 @@
   *areablock;			/* Memory allocated to hold arealist structures */
 
 typedef struct arealimits {
-    char *areaname;		/* Ptr to name of area */
+    const char *areaname;	/* Ptr to name of area */
     int areahash;		/* Hashed area name */
     symtentry *areabase;	/* Pointer to SYMT entry of area's 'base' symbol */
     symtentry *arealimit;	/* Pointer to SYMT entry of area's 'limit' symbol */
@@ -315,7 +315,7 @@
   return ap;
 }
 
-static char *make_name(char *s1, char *s2) {
+static char *make_name(const char *s1, const char *s2) {
   char *p;
   if ((p = allocmem(strlen(s1)+strlen(s2)+sizeof(char)))==NIL) {
     error("Fatal: Out of memory in 'make_name'");
@@ -333,7 +333,7 @@
 static void list_attributes(arealist *ap) {
   char text[MSGBUFLEN];
   unsigned int attr, count, n;
-  struct {unsigned int atmask; char *atname;} attributes[] = {
+  struct {unsigned int atmask; const char *atname;} attributes[] = {
     {ATT_ABSOL,  "Absolute"},
     {ATT_CODE,   "Code"}   ,
     {ATT_COMDEF, "Common definition"},
@@ -389,7 +389,7 @@
 static void insert_area(arealist **list, arealist **lastentry, arealist *newarea) {
   int compres, lastres;
   arealist *ap, *lastarea;
-  char *name;
+  const char *name;
   arealimits *lp;
   lastarea = NIL;
   name = newarea->arname;
@@ -538,7 +538,7 @@
 ** block that is referenced only by an entry in the OBJ_SYMT chunk with the
 ** 'common' attribute set. It returns a pointer to the structure created
 */
-static arealist *add_commonarea(char *name, unsigned int size) {
+static arealist *add_commonarea(const char *name, unsigned int size) {
   arealist *ap;
   ap = allocmem(sizeof(arealist));
   if (ap==NIL) error("Fatal: Out of memory in 'add_commonarea'");
@@ -840,7 +840,7 @@
   relocation *rp;		/* Points at entry in relocation part of OBJ_AREA chunk */
   symtentry *stp;		/* Points at entry in OBJ_SYMT chunk */
   symbol *sp;
-  int refcount, i, j, reltype;
+  unsigned int refcount, i, j, reltype;
   refcount = 0;
   ap = &fp->objheadptr->firstarea;
   rp = COERCE(fp->objareaptr, relocation*);
@@ -1072,7 +1072,7 @@
 static void fillin_limits(arealist *firstarea, arealist *lastarea) {
   arealimits *p;
   int hashval;
-  char *name;
+  const char *name;
   hashval = firstarea->arhash;
   name = firstarea->arname;
   p = arlimlist;
@@ -1673,7 +1673,7 @@
 ** 'write_areareloc' builds and writes the relocation information for
 ** each area in the area list passed to it
 */
-void write_areareloc(arealist *ap) {
+static void write_areareloc(arealist *ap) {
   while (ap!=NIL) {
     if (ap->arnumrelocs!=0) write_reloc(ap);
     ap = ap->arflink;
@@ -2133,7 +2133,7 @@
 ** 'print_arealist' is called to list the areas in an image file of a
 ** particular type, that is, read-only code, read/write code and so forth
 */
-static void print_arealist(char *areaclass, arealist *ap) {
+static void print_arealist(const char *areaclass, arealist *ap) {
   unsigned int offset;
   char text[MSGBUFLEN];
   offset = (imagetype==RMOD ? progbase : 0);
@@ -2178,7 +2178,7 @@
 ** from the image file as there were no references to them
 */
 static void list_unused(arealist *ap, bool findsymbol) {
-  char *symname;
+  const char *symname;
   char text[MSGBUFLEN];
   while (ap!=NIL) {
     if (ap->arefcount==0) {
Index: riscos-aof/drlink/c++names.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/Attic/c++names.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 c++names.c
--- riscos-aof/drlink/c++names.c	2002/02/26 07:38:19	1.1.2.1
+++ riscos-aof/drlink/c++names.c	2002/03/30 15:13:16
@@ -14,6 +14,19 @@
 
 /* #define MANGLED */
 
+#include <string.h>
+#include <ctype.h>
+#include "drlhdr.h"
+#include "filehdr.h"
+#include "areahdr.h"
+#include "chunkhdr.h"
+#include "procdefs.h"
+
+#define MAXLENGTH 1024		/* Maximum expanded name length */
+
+static char fullname[MAXLENGTH];	/* Expanded function name */
+
+
 #ifdef MANGLED
 
 /*
@@ -22,10 +35,7 @@
 */
 
 
-#include <string.h>
-#include <ctype.h>
 
-#define MAXLENGTH 1024		/* Maximum expanded name length */
 
 typedef enum {	/* Tokens */
   ALLDONE, NOTMANGLED, IDENT, OPER, BASICTYPE, MODIFIER, POINTER,
@@ -104,7 +114,6 @@
 
 static signature *sigstack;	/* Stack of function signatures */
 
-static char fullname[MAXLENGTH];	/* Expanded function name */
 
 struct {unsigned char namelen; symboltype what; char *encoded_name, *proper_name;} operators [] = {
 	/* Encoded -> proper operator names */
@@ -179,7 +188,7 @@
   return &fullname[0];
 }
 
-char *decode_name(char *name) {
+char *decode_name(const char *name) {
   if (opt_cpp) {
     return decode(name)
   }
@@ -194,8 +203,8 @@
 ** 'decode_name' returns a pointer to a de-mangled version of the
 ** name passed to it.
 */
-char *decode_name(char *name) {
-  return name;
+char *decode_name(const char *name) {
+  return strncpy(fullname, name, MAXLENGTH);
 }
 
 #endif
Index: riscos-aof/drlink/debug.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/debug.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 debug.c
--- riscos-aof/drlink/debug.c	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/debug.c	2002/03/30 15:13:16
@@ -71,7 +71,7 @@
 /*
 ** 'add_lldentry' adds one entry to the low level debugging tables
 */
-static void add_lldentry(char *name, unsigned int class, int value) {
+static void add_lldentry(const char *name, unsigned int class, int value) {
   strcpy(lldnamenext, name);
   lldinfonext->lldoffset = class+(lldnamenext-lldnametable);
   lldinfonext->lldvalue = value;
Index: riscos-aof/drlink/drlhdr.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/drlhdr.h,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 drlhdr.h
--- riscos-aof/drlink/drlhdr.h	2002/03/07 10:48:31	1.1.2.3
+++ riscos-aof/drlink/drlhdr.h	2002/03/30 15:13:17
@@ -31,7 +31,7 @@
 #define TRUE 1
 #define NIL 0
 #define NULLCHAR 0
-#define COERCE(x,t) (t)(x)
+#define COERCE(x,t) ((t)(void *)(x))
 
 #define FNAMELEN 500		/* Maximum filename length */
 #define LEAFLEN 100		/* Maximum leaf name length */
Index: riscos-aof/drlink/drlmain.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/drlmain.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 drlmain.c
--- riscos-aof/drlink/drlmain.c	2002/03/07 10:48:31	1.1.2.4
+++ riscos-aof/drlink/drlmain.c	2002/03/30 15:13:19
@@ -388,7 +388,11 @@
     OPT_WORKS
   } actions;
 
-typedef struct {char *optname; unsigned char optlen; actions optaction;} option;
+typedef struct {
+  const char *optname;
+  unsigned char optlen;
+  actions optaction;
+} option;
 
 option optionlist [] = {
 /* areamap */	{"area", 4, OPT_MAPFILE},
@@ -439,7 +443,7 @@
 /* workspace */	{"w", 1, OPT_WORKS},
 /* xref */	{"x", 1, IGNORED}};
 
-  int n;
+  unsigned int n;
   unsigned int value;
   bool ok;
   char *op;
Index: riscos-aof/drlink/filehdr.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/filehdr.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 filehdr.h
--- riscos-aof/drlink/filehdr.h	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/filehdr.h	2002/03/30 15:13:19
@@ -87,7 +87,9 @@
 
 extern char
    *symbolname,				/* Pointer to name of symbol file */
-   *mapfilename,			/* Pointer to name of map file */
+   *mapfilename;			/* Pointer to name of map file */
+
+extern const char
    *imagename;				/* Pointer to name of linker output file */
 
 extern bool
Index: riscos-aof/drlink/files.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/files.c,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 files.c
--- riscos-aof/drlink/files.c	2002/03/07 10:48:31	1.1.2.3
+++ riscos-aof/drlink/files.c	2002/03/30 15:13:22
@@ -69,7 +69,9 @@
 
 char
    *symbolname,				/* Pointer to name of symbol file */
-   *mapfilename,			/* Pointer to name of map file */
+   *mapfilename;			/* Pointer to name of map file */
+
+const char
    *imagename;				/* Pointer to name of linker output file */
 
 bool
@@ -243,7 +245,7 @@
 */
 fileinfo examine_file(char *filename) {
   FILE *libfile;
-  int filesize, n;
+  unsigned int filesize, n;
   size_t count;
   fileinfo filetype;
   chunkheader libheader;
@@ -425,7 +427,7 @@
 ** returns 'TRUE' if it is okay, otherwise it returns 'FALSE'.
 */
 static bool scan_chunkhdr(filelist *fp) {
-  int i;
+  unsigned int i;
   unsigned int start, size;
   chunkindex *cp;
   cp = chunkhdrbase;
@@ -536,7 +538,7 @@
 ** The proc returns 'TRUE' if all this worked otherwise it
 ** returns 'FALSE'
 */
-bool process_file(char *filename, unsigned int filesize) {
+static bool process_file(char *filename, unsigned int filesize) {
   filelist *fp;
   bool ok;
   ok = FALSE;
@@ -566,7 +568,7 @@
 ** been loaded. It returns 'TRUE' if it has not.
 */
 static bool unread(char *filename) {
-  int hashval;
+  unsigned int hashval;
   filelist *fp;
   fp = aofilelist;
   hashval = hash(filename);
@@ -803,7 +805,7 @@
 ** returns FALSE.
 */
 static bool load_textfile(char* filename, char **where, int *size) {
-  int fsize;
+  unsigned int fsize;
   char *p;
   FILE *textfile;
   size_t count;
@@ -875,7 +877,7 @@
 ** 'loadaddr'. It returns 'true' if this went okay otherwise it
 ** returns 'false'
 */
-bool read_chunk(char *chunkid, int chunkaddr, int chunksize, void *loadaddr) {
+bool read_chunk(const char *chunkid, int chunkaddr, int chunksize, void *loadaddr) {
   int result;
   result = fseek(objectfile, chunkaddr, SEEK_SET);
   if (result!=0) {
@@ -971,7 +973,7 @@
 ** allocating memory needlessly.
 */
 bool read_libchunkhdr(libheader *lp) {
-  int size;
+  unsigned int size;
   size_t count;
   count = fread(&header, sizeof(header), 1, objectfile);
   if (count!=1) {
@@ -1059,7 +1061,7 @@
 ** worked as the only errors are fatal ones where the linker gives
 ** up on the spot.
 */
-void write_image(void *areaddr, int areasize) {
+void write_image(void *areaddr, unsigned int areasize) {
   if (filebuftop+areasize>=filebufend) {	/* No room in staging buffer */
     write_block(filebuffer, filebuftop-filebuffer);
     filebuftop = filebuffer;
@@ -1078,7 +1080,7 @@
 ** image file. This is only used when creating partially-linked
 ** AOF files
 */
-void write_string(char *p) {
+void write_string(const char *p) {
   int len;
   len = strlen(p)+sizeof(char);
   if (filebuftop+len>=filebufend) {	/* No room in staging buffer */
@@ -1093,7 +1095,7 @@
 ** 'write_zeroes' writes the specified number of zeroes to the
 ** image file
 */
-void write_zeroes(int count) {
+void write_zeroes(unsigned int count) {
   unsigned int zeroblock[] = {0,0,0,0,0,0,0,0};
   while (count>=sizeof(zeroblock)) {
     write_image(&zeroblock, sizeof(zeroblock));
@@ -1185,7 +1187,7 @@
 /*
 ** 'check_write' ensures that the last write to the symbol file worked
 */
-void check_write(void) {
+static void check_write(void) {
   if (ferror(symbolfile)) {
     error("Fatal: Error occured writing to symbol file '%s'", symbolname);
   }
Index: riscos-aof/drlink/libraries.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/libraries.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 libraries.c
--- riscos-aof/drlink/libraries.c	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/libraries.c	2002/03/30 15:13:23
@@ -135,7 +135,7 @@
 ** something is wrong
 */
 static bool scan_libchunkhdr(libheader *lp) {
-  int n, start, size;
+  unsigned int n, start, size;
   chunkindex *cp;
   bool datafound;
   dirystart = vsrnstart = symtstart = 0;
Index: riscos-aof/drlink/linkdebug.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/linkdebug.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 linkdebug.c
--- riscos-aof/drlink/linkdebug.c	2002/03/07 10:48:31	1.1.2.2
+++ riscos-aof/drlink/linkdebug.c	2002/03/30 15:13:23
@@ -17,7 +17,7 @@
 void list_areas(arealist *list) {
   arearef *rp;
   while (list!=NIL) {
-    printf("Area entry at %08p, areaname='%s', hash=%x, base entry at %p, file entry at %p, AT=%x\n",
+    printf("Area entry at %p, areaname='%s', hash=%x, base entry at %p, file entry at %p, AT=%x\n",
      list, list->arname, list->arhash, list->arbase, list->arfileptr, list->aratattr);
     printf("  OBJ_AREA at %p, size=%x, relocations at %p, number=%d, area address=%x",
      list->arobjdata, list->arobjsize, list->areldata, list->arnumrelocs, list->arplace);
@@ -31,7 +31,7 @@
     else {
       printf(", References:\n  ");
       while (rp!=NIL) {
-        printf("  %08p=%d", rp->arefarea, rp->arefcount);
+        printf("  %p=%d", rp->arefarea, rp->arefcount);
         rp = rp->arefnext;
       }
       printf("\n");
@@ -59,7 +59,7 @@
   symtentry *sp;
   while (list!=NIL) {
     sp = list->symtptr;
-    printf("    Symbol at %08p, symt at %08p, name='%s', hash=%x, attributes=%x, value=%x",
+    printf("    Symbol at %p, symt at %p, name='%s', hash=%x, attributes=%x, value=%x",
      list, sp, sp->symtname, list->symhash, sp->symtattr, sp->symtvalue);
     if (sp->symtarea.areaptr!=NIL) {
       printf(", area at %p", sp->symtarea.areaptr);
@@ -71,15 +71,15 @@
 
 void list_symtable(symbol *table[], unsigned int stsize) {
   symbol *list;
-  int n, low;
-  printf("  Symbol table at %08p\n", table);
+  unsigned int n, low;
+  printf("  Symbol table at %p\n", table);
   n = 0;
   do {
     low = n;
     while ((list = table[n])==NIL && n<stsize) n+=1;
     if (n!=low) printf("  Index=%2d..%-2d, no entries\n", low, n-1);
     if (n<stsize) {
-      printf("  Index=%2d, symbol list starts at %08p\n", n, list);
+      printf("  Index=%2d, symbol list starts at %p\n", n, list);
       list_symbols(list);
       n+=1;
     }
@@ -88,7 +88,7 @@
 
 void list_libentries(libentry *list) {
   while (list!=NIL) {
-    printf("    Lib entry at %08p, name='%s', hash=%x, member name='%s', offset in library=%x, size=%x\n",
+    printf("    Lib entry at %p, name='%s', hash=%x, member name='%s', offset in library=%x, size=%x\n",
      list, list->libname, list->libhash, list->libmember, list->liboffset, list->libsize);
     list = list->libflink;
   }
@@ -97,13 +97,13 @@
 void list_libtable(libtable *table) {
   libentry *list;
   int n;
-  printf("  Library symbol table at %08p\n", table);
+  printf("  Library symbol table at %p\n", table);
   for (n = 0; n<MAXENTRIES; n++) {
     if ((list = *table[n])==NIL) {
       printf("  Index=%2d, no entries\n", n);
     }
     else {
-      printf("  Index=%2d, symbol list starts at %08p\n", n, list);
+      printf("  Index=%2d, symbol list starts at %p\n", n, list);
       list_libentries(list);
     }
   }
@@ -111,7 +111,7 @@
 
 void list_filelist(filelist *list) {
   while (list!=NIL) {
-    printf("File def at %08p, name='%s', file size=%x\n",
+    printf("File def at %p, name='%s', file size=%x\n",
      list, list->chfilename, list->chfilesize);
     printf("  OBJ_HEAD is at %p, size=%x,   OBJ_SYMT is at %p, size=%x\n",
      list->objheadptr, list->objheadsize, list->objsymtptr, list->objsymtsize);
@@ -126,7 +126,7 @@
 
 void list_liblist(libheader *list) {
   while (list!=NIL) {
-    printf("Library def at %08p, name='%s', loaded at %08p, library size=%x\n",
+    printf("Library def at %p, name='%s', loaded at %p, library size=%x\n",
      list, list->libname, list->libase, list->libextent);
     list = list->libflink;
   }
Index: riscos-aof/drlink/linkedit.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/linkedit.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 linkedit.c
--- riscos-aof/drlink/linkedit.c	2002/03/01 16:49:24	1.1.2.2
+++ riscos-aof/drlink/linkedit.c	2002/03/30 15:13:23
@@ -48,7 +48,7 @@
 /*
 ** 'edit_error' lists the edit error message passed to it
 */
-static void edit_error(char *message) {
+static void edit_error(const char *message) {
   char text[MSGBUFLEN];
   strcpy(text, message);
   strcat(text, " at line %d in edit file '%s'");
@@ -102,7 +102,7 @@
 #define MAXLEN 6
 
 static editcommands find_cmd(void) {
-  typedef struct {char *cmdname; editcommands cmd;} commands;
+  typedef struct {const char *cmdname; editcommands cmd;} commands;
   commands cmdlist [] = {
 /* rename */	   {"rename", EDT_RENAME},
 /* change */	   {"change", EDT_CHANGE},
@@ -110,7 +110,7 @@
 /* reveal */	   {"reveal", EDT_REVEAL},
 /* entry */	   {"entry", EDT_ENTRY}
   };
-  int n;
+  unsigned int n;
   char *p;
   char name[10];
   n = 0;
@@ -281,7 +281,7 @@
 ** 'list_badedits' lists edits that were not carried out
 */
 static void list_badedits(editcmd *p) {
-  char *opnames [] = {"", "rename", "change", "hide", "reveal", "entry"};
+  const char *opnames [] = {"", "rename", "change", "hide", "reveal", "entry"};
   while (p!=NIL) {
     if (!p->edtdone) error("    %s '%s' in '%s'", opnames[p->edtoper], p->edtold, p->edtfile);
     p = p->edtnext;
Index: riscos-aof/drlink/messages.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/messages.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 messages.c
--- riscos-aof/drlink/messages.c	2002/03/07 10:48:31	1.1.2.2
+++ riscos-aof/drlink/messages.c	2002/03/30 15:13:24
@@ -47,7 +47,7 @@
  * reported via 'throwback' to start the throwback session. It
  * returns TRUE if this worked otherwise it returns FALSE
  */
-static bool start_throwback(char *filename) {
+static bool start_throwback(const char *filename) {
   _kernel_swi_regs regs;
   _kernel_oserror *swierror;
   swierror = _kernel_swi(DDEUtils_ThrowbackStart, &regs, &regs);
@@ -90,7 +90,7 @@
 */
 static void throwback_message(char *text) {
   int errlevel;
-  char *filename;
+  const char *filename;
   _kernel_oserror *swierror;
   _kernel_swi_regs regs;
   filename = imagename;
@@ -141,7 +141,7 @@
 ** the 'throwback' option is used, error messages are sent to a
 ** 'throwback' window otherwise they are just printed.
 */
-void error(char *msg, ...) {
+void error(const char *msg, ...) {
   char *p1, *p2, *p3, *p4;
   va_list parms;
   va_start(parms, msg);
Index: riscos-aof/drlink/procdefs.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/procdefs.h,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 procdefs.h
--- riscos-aof/drlink/procdefs.h	2002/03/07 10:48:31	1.1.2.2
+++ riscos-aof/drlink/procdefs.h	2002/03/30 15:13:24
@@ -38,7 +38,7 @@
 extern void resize_filebuffer(void);
 extern bool get_files(char *);
 extern int find_filesize(char *);
-extern bool read_chunk(char *, int, int, void *);
+extern bool read_chunk(const char *, int, int, void *);
 extern bool cache_files(void);
 extern void addto_debuglist(char *);
 extern void check_debuglist(void);
@@ -52,9 +52,9 @@
 extern bool extract_member(chunkindex *);
 extern void tidy_files(void);
 extern void open_image(void);
-extern void write_image(void *, int);
-extern void write_string(char *);
-extern void write_zeroes(int);
+extern void write_image(void *, unsigned int);
+extern void write_string(const char *);
+extern void write_zeroes(unsigned int);
 extern void close_image(void);
 extern void reset_image(unsigned int);
 extern void flush_image(void);
@@ -82,7 +82,7 @@
 /* -- In 'Messages' -- */
 
 extern void announce(void);
-extern void error(char *, ...);
+extern void error(const char *, ...);
 extern bool got_errors(void);
 #ifdef TARGET_RISCOS
 extern void end_throwback(void);
@@ -115,7 +115,7 @@
 /* -- In 'Symbols' -- */
 
 extern int stricmp(const char *, const char*);
-extern symbol *make_symbol(char *, unsigned int);
+extern symbol *make_symbol(const char *, unsigned int);
 extern void create_linksyms(void);
 extern symbol *create_externref(symtentry *);
 extern void init_symbols(void);
@@ -125,8 +125,8 @@
 extern bool resolve(void);
 extern void relocate_symbols(void);
 extern void define_symbol(symbol *, unsigned int);
-extern int hash(char *);
-extern char *find_areasymbol(arealist *);
+extern int hash(const char *);
+extern const char *find_areasymbol(arealist *);
 extern symtentry *find_nonstrong(symtentry *);
 extern symbol *search_common(symbol *);
 extern symbol *find_common(char *);
@@ -161,6 +161,6 @@
 
 /* -- In 'C++names' -- */
 
-extern char *decode_name(char *);
+extern char *decode_name(const char *);
 
 #endif
Index: riscos-aof/drlink/symbolhdr.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/symbolhdr.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 symbolhdr.h
--- riscos-aof/drlink/symbolhdr.h	2001/12/12 14:56:20	1.1.2.1
+++ riscos-aof/drlink/symbolhdr.h	2002/03/30 15:13:25
@@ -65,7 +65,7 @@
 #define REL_TYPE2 0x80000000		/* Type 2 relocation flag */
 
 typedef struct symtentry {		/* Entry in OBJ_SYMT chunk */
-  char *symtname;			/* Offset of symbol's name in OBJ_STRT chunk */
+  const char *symtname;			/* Offset of symbol's name in OBJ_STRT chunk */
   unsigned int symtattr;		/* Symbol attributes */
   unsigned int symtvalue;		/* Symbol's value */
   union {
Index: riscos-aof/drlink/symbols.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/drlink/symbols.c,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 symbols.c
--- riscos-aof/drlink/symbols.c	2002/03/01 16:49:24	1.1.2.4
+++ riscos-aof/drlink/symbols.c	2002/03/30 15:13:28
@@ -50,7 +50,7 @@
 /* Private declarations */
 
 typedef struct missing {
-  char *symname, *filename;	/* Symbol not found and the file that referenced it */
+  const char *symname, *filename;	/* Symbol not found and the file that referenced it */
   struct missing *nextsym;	/* Next missing symbol */
 } missing;
 
@@ -85,7 +85,7 @@
 ** any letters. I suppose it would be better to use 'tolower' but
 ** it's only a hashing function.
 */
-int hash(char *name) {
+int hash(const char *name) {
   int total;
   total = 0;
   while (*name!=0) {
@@ -169,7 +169,7 @@
 static void check_symedit(symtentry *symtp) {
   int fnhashval, syhashval;
   editcmd *ep;
-  char *symname;
+  const char *symname;
   symname = symtp->symtname;
   fnhashval = current_file->chfilehash;
   syhashval = hash(symname);
@@ -224,7 +224,7 @@
 static void check_refedit(symtentry *symtp) {
   int syhashval, fnhashval;
   editcmd *ep;
-  char *symname;
+  const char *symname;
   symname = symtp->symtname;
   fnhashval = current_file->chfilehash;
   syhashval = hash(symname);
@@ -285,8 +285,9 @@
 static bool add_symbol(symtentry *symtp) {
   symbol *p;
   symbol **table;
-  int hashval, attr;
-  char *name;
+  int hashval;
+  unsigned int attr;
+  const char *name;
   arealist *ap;
   symtp->symtname = symtp->symtname+COERCE(strtbase, unsigned int);
   if (current_symedit!=NIL) check_symedit(symtp);
@@ -368,7 +369,7 @@
 */
 static void add_externref(symtentry *symtp) {
   symbol *sp;
-  char *name;
+  const char *name;
   symtp->symtname = symtp->symtname+COERCE(strtbase, unsigned int);
   if (current_refedit!=NIL) check_refedit(symtp);
   name = symtp->symtname;
@@ -400,7 +401,7 @@
 symbol *create_externref(symtentry *stp) {
   symbol *sp;
   symtentry *newstp;
-  char *name;
+  const char *name;
   sp = allocmem(sizeof(symbol));
   newstp = allocmem(sizeof(symtentry));
   if (sp==NIL || newstp==NIL) error("Fatal: Out of memory in 'create_externref'");
@@ -430,7 +431,7 @@
 ** words 'bug fix' and 'hack' come to mind here).
 */
 static void add_commonref(symtentry *stp) {
-  char *name;
+  const char *name;
   symbol *sp;
   stp->symtname = stp->symtname+COERCE(strtbase, unsigned int);
   if (current_refedit!=NIL) check_refedit(stp);
@@ -522,7 +523,7 @@
 */
 static symbol *search_global(symbol *wantedsym) {
   symbol *p;
-  char *name;
+  const char *name;
   int hashval;
   hashval = wantedsym->symhash;
   if ((p = globalsyms[hashval & GLOBALMASK])==NIL) return NIL;
@@ -542,7 +543,7 @@
 */
 static symbol *search_local(symbol *wantedsym) {
   symbol *p;
-  char *name;
+  const char *name;
   int hashval;
   hashval = wantedsym->symhash;
   if ((p = (*current_table)[hashval & LOCALMASK])==NIL) return NIL;
@@ -562,7 +563,7 @@
 */
 symbol *search_common(symbol *wantedsym) {
   symbol *p;
-  char *name;
+  const char *name;
   int hashval;
   hashval = wantedsym->symhash;
   if ((p = commonsyms[hashval & COMMONMASK])==NIL) return NIL;
@@ -598,7 +599,7 @@
 */
 static void add_unresolved(missing **list, symbol *sp, filelist *fp) {
   missing *mp;
-  char *sname;
+  const char *sname;
   mp = *list;
   sname = sp->symtptr->symtname;
   if (opt_case || (sp->symtptr->symtattr & SYM_IGNCASE)!=0) {
@@ -670,7 +671,7 @@
 */
 static libentry *search_lib(symbol *wantedsym) {
   libentry *lp;
-  char *name;
+  const char *name;
   int hashval;
   hashval = wantedsym->symhash;
   name = wantedsym->symtptr->symtname;
@@ -1043,7 +1044,7 @@
 ** are marked as being relocatable although they are not relocated by
 ** the linker at all.
 */
-symbol *make_symbol(char *name, unsigned int attributes) {
+symbol *make_symbol(const char *name, unsigned int attributes) {
   unsigned int hashval;
   symbol *sp;
   symtentry *stp;
@@ -1074,7 +1075,7 @@
 ** 'new_symbol' is called to create a symbol that will be added to the
 ** low-level debugging tables
 */
-static symbol *new_symbol(char *name) {
+static symbol *new_symbol(const char *name) {
   if (opt_keepdebug) lldsize+=strlen(name)+sizeof(char);
   return make_symbol(name, SYM_GLOBAL);
 }
@@ -1084,10 +1085,10 @@
 ** from the area 'ap'. It returns a pointer to a name or NIL if it
 ** cannot find anything
 */
-char *find_areasymbol(arealist *ap) {
+const char *find_areasymbol(arealist *ap) {
   symtentry *sp;
   filelist *fp;
-  char *anp;
+  const char *anp;
   unsigned int symcount, n;
   anp = ap->arname;
   fp = ap->arfileptr;
@@ -1114,7 +1115,7 @@
 symtentry *find_nonstrong(symtentry *stp) {
   symbol dummysym;
   symtentry dummysymt;
-  char *name;
+  const char *name;
   symbol *sp;
   name = stp->symtname;
   dummysym.symhash = hash(name);
@@ -1199,7 +1200,7 @@
 /*
 ** 'symtcmp' compares the values of the two symbols passed to it
 */
-int symtcmp(const void *first, const void *second) {
+static int symtcmp(const void *first, const void *second) {
   if (((*COERCE(first, symtentry **)))->symtvalue<((*COERCE(second, symtentry **)))->symtvalue) return -1;
   if (((*COERCE(first, symtentry **)))->symtvalue>((*COERCE(second, symtentry **)))->symtvalue) return 1;
   return 0;


-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 Homepage                     -  http://www.chocky.org/
 RISC OS Projects Initiative  -  http://initiative.chocky.org/
 RISC OS C Programming        -  http://www.riscos.info/
------------------------------------------------------------------------



More information about the gcc mailing list