Warning Fixes

Peter Naulls peter at chocky.org
Wed Aug 21 08:21:14 PDT 2002


Minor warning fixes:

Fix alignment warning.

Index: alloc.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/alloc.c,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 alloc.c
--- alloc.c	7 Feb 2002 10:19:30 -0000	1.2.2.2
+++ alloc.c	21 Aug 2002 14:54:56 -0000
@@ -1828,7 +1828,7 @@
   size = (size + SIZE_SZ + page_mask) & ~page_mask;
 
 #ifdef MAP_ANONYMOUS
-  p = (mchunkptr)mmap(0, size, PROT_READ|PROT_WRITE,
+  p = (mchunkptr)(void *)mmap(0, size, PROT_READ|PROT_WRITE,
 		      MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
 #else /* !MAP_ANONYMOUS */
   if (fd < 0)


Retain type consistency

Index: strcmp.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/strcmp.c,v
retrieving revision 1.2
diff -u -r1.2 strcmp.c
--- strcmp.c	29 Jan 2001 15:10:19 -0000	1.2
+++ strcmp.c	21 Aug 2002 14:54:56 -0000
@@ -23,5 +23,5 @@
   while ((i = *s1) && i == *s2)
     s1++, s2++;
 
-  return (*(unsigned char *) s1 - *(unsigned char *) s2);
+  return (*(const unsigned char *) s1 - *(const unsigned char *) s2);
 }


Declare gethostbyname2

Index: clib/netdb.h
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/clib/netdb.h,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 netdb.h
--- clib/netdb.h	18 Aug 2002 15:19:06 -0000	1.2.2.2
+++ clib/netdb.h	21 Aug 2002 14:55:02 -0000
@@ -45,6 +45,7 @@
 extern struct hostent *gethostent (void);
 extern int endhostent (void);
 extern struct hostent *gethostbyname (const char *__name);
+extern struct hostent *gethostbyname2 (const char *__name, int af);
 extern struct hostent *_gethostbyname (const char *__name);
 extern struct hostent *gethostbyaddr (const char *__addr, int __len, int __type);
 extern struct hostent *_gethostbyaddr (const char *__addr, int __len, int __type);


Signed/unsigned comparison:

Index: common/riscosify.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/common/riscosify.c,v
retrieving revision 1.2.2.4
diff -u -r1.2.2.4 riscosify.c
--- common/riscosify.c	18 Aug 2002 19:57:19 -0000	1.2.2.4
+++ common/riscosify.c	21 Aug 2002 14:55:09 -0000
@@ -1081,7 +1081,7 @@
       to_copy = truncate[__RISCOSIFY_TRUNCATE_VALUE(flags)];
 
       name--; /* Copying from name - 1.  */
-      if (to_copy < last_dot - name)
+      if (to_copy < (size_t)(last_dot - name))
 	drop_vowels = flags & __RISCOSIFY_DROP_VOWEL;
       else
 	to_copy = last_dot - name;


Fix warnings about uninitialised variables:

Index: math/expm1.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/math/expm1.c,v
retrieving revision 1.2
diff -u -r1.2 expm1.c
--- math/expm1.c	29 Jan 2001 15:10:19 -0000	1.2
+++ math/expm1.c	21 Aug 2002 14:55:12 -0000
@@ -208,7 +208,10 @@
       return x - (t - (huge + x));
     }
   else
-    k = 0;
+    {
+      c = 0;
+      k = 0;
+    }
 
   /* x is now in primary range */
   hfx = 0.5 * x;


Fix function type usage:

Index: stdio/scanf.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/stdio/scanf.c,v
retrieving revision 1.2
diff -u -r1.2 scanf.c
--- stdio/scanf.c	29 Jan 2001 15:10:21 -0000	1.2
+++ stdio/scanf.c	21 Aug 2002 14:55:18 -0000
@@ -124,7 +124,8 @@
 	int nconversions;	/* number of conversions */
 	int nread;		/* number of characters consumed from fp */
 	int base;		/* base argument to strtol/strtoul */
-	u_long (*ccfn)();	/* conversion function (strtol/strtoul) */
+	u_long (*ccfn)(const char *, char **, int);
+				/* conversion function (strtol/strtoul) */
 	char ccltab[256];	/* character class table for %[...] */
 	char buf[BUF];		/* buffer for numeric conversions */
 
@@ -208,13 +209,13 @@
 			/* FALLTHROUGH */
 		case 'd':
 			c = CT_INT;
-			ccfn = (u_long (*)())strtol;
+			ccfn = (u_long (*)(const char *, char **, int))strtol;
 			base = 10;
 			break;
 
 		case 'i':
 			c = CT_INT;
-			ccfn = (u_long (*)())strtol;
+			ccfn = (u_long (*)(const char *, char **, int))strtol;
 			base = 0;
 			break;
 
@@ -297,7 +298,7 @@
 			if (isupper(c))
 				flags |= LONG;
 			c = CT_INT;
-			ccfn = (u_long (*)())strtol;
+			ccfn = (u_long (*)(const char *, char **, int))strtol;
 			base = 10;
 			break;
 		}


Fix type consistency:

Index: stdio/tmpfile.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/stdio/tmpfile.c,v
retrieving revision 1.2.2.4
diff -u -r1.2.2.4 tmpfile.c
--- stdio/tmpfile.c	10 Jun 2002 09:57:12 -0000	1.2.2.4
+++ stdio/tmpfile.c	21 Aug 2002 14:55:18 -0000
@@ -38,7 +38,7 @@
 {
   char *s = buf;
   unsigned long idx;
-  const int maxidx = (sizeof (letters) - 1) * (sizeof (letters) - 1)
+  const unsigned int maxidx = (sizeof (letters) - 1) * (sizeof (letters) - 1)
     * (sizeof (letters) - 1) * (sizeof (letters) - 1)
     * (sizeof (letters) - 1) * (sizeof (letters) - 1);
   int loop = 0;


 
Avoid alignment warning:


Index: sys/exec.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/unixlib/source/sys/exec.c,v
retrieving revision 1.2.2.9
diff -u -r1.2.2.9 exec.c
--- sys/exec.c	14 Sep 2001 14:01:17 -0000	1.2.2.9
+++ sys/exec.c	21 Aug 2002 14:55:21 -0000
@@ -564,7 +564,7 @@
 	}
       ushift (process->tty, variable, code);
 
-      __exec = (void (*)(char *)) ((char *) __stack_limit + __codeshift);
+      __exec = (void (*)(char *))(void *)((char *) __stack_limit + __codeshift);
     }
   else
     __exec = __exptr;


More soon.  I seem to have a bunch of patches which didn't get noticed
first time they were submitted.

Peter

-- 
------------------------------------------------------------------------
 Peter Naulls - peter at chocky.org
 Homepage                     -  http://www.chocky.org/
 RISC OS C Programming        -  http://www.riscos.info/
 Unix Programs on RISC OS     -  http://www.chocky.org/unix/
------------------------------------------------------------------------
 



More information about the gcc mailing list