This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Avoid some warnings in make check


Hi!

This patch kills quite a few warnings during make check (seen on sparc64).

Notes:
- What format string modifier should be used for wint_t type arguments?
  Some archs define it as unsigned long int, some as unsigned int...
  This causes most of the warnings not fixed by this patch.
- We should avoid direct casts between void * and int, because at least
  sparc64 gcc warns about those casts. Casting to long in between makes it
  go away.
- Is gcc right in emitting:
  test.c:
  long long x = -9223372036854775808LL;
  test.c:1: warning: decimal constant is so large that it is unsigned
  warning? All of egcs 1.1.2, gcc 2.95, RH gcc 2.96 and CVS gcc 2.97 emit it,
  but it looks pretty bogus to me, I know what would need to change but I'm
  not sure if gcc is not for some reason right about it.

2000-11-20  Jakub Jelinek  <jakub@redhat.com>

	* iconvdata/bug-iconv2.c (main): Use %zd in format string.
	* io/test-lfs.c (do_test): Cast statbuf.st_size to long long.
	* malloc/tst-valloc.c (main): Cast valloc return value to long.
	* malloc/tst-obstack.c (verbose_malloc): Use %zd in format string.
	* math/test-fpucw.c (main): Use %lx in format string, cast
	control words to long.
	* stdio-common/tst-fmemopen.c (main): Use %td in format strings.
	* stdlib/tst-strtol.c (tests): Avoid (bogus?) decimal constant is so
	large that it is unsigned warning.
	* sysdeps/unix/sysv/linux/sparc/bits/types.h (__ssize_t): Changing
	it to long on sparc64.

linuxthreads:
	* Examples/ex3.c (main): Cast int to long before casting to void *.
	(search): Cast void * to long, not int.
	* Examples/ex8.c (main, thread): Similarly.
	* Examples/ex11.c (main): Similarly.
	* Examples/ex14.c (worker, do_test): Similarly.
	* ecmutex.c (worker, do_test): Similarly.
	(nlocks): Cast to int.

--- libc/iconvdata/bug-iconv2.c.jj	Tue Aug 29 23:11:06 2000
+++ libc/iconvdata/bug-iconv2.c	Mon Nov 20 13:55:57 2000
@@ -38,7 +38,7 @@ main (void)
     exit (1);
 
   puts ("This used to crash");
-  printf ("%d\n", iconv (cd_a, &from, &from_left, &to, &to_left));
+  printf ("%zd\n", iconv (cd_a, &from, &from_left, &to, &to_left));
   iconv_close (cd_a);
 
   puts ("works now");
--- libc/io/test-lfs.c.jj	Thu Nov  2 08:51:41 2000
+++ libc/io/test-lfs.c	Mon Nov 20 15:14:06 2000
@@ -124,7 +124,7 @@ do_test (int argc, char *argv[])
     error (EXIT_FAILURE, errno, "cannot stat file `%s'", name);
   else if (statbuf.st_size != (TWO_GB+100+5))
     error (EXIT_FAILURE, 0, "stat reported size %lld instead of %lld.",
-	   statbuf.st_size, (TWO_GB+100+5));
+	   (long long int) statbuf.st_size, (TWO_GB+100+5));
 
   return 0;
 }
--- libc/linuxthreads/Examples/ex3.c.jj	Sun Dec 13 19:01:50 1998
+++ libc/linuxthreads/Examples/ex3.c	Mon Nov 20 15:21:38 2000
@@ -35,7 +35,7 @@ int main(int argc, char ** argv)
 
   /* Create the searching threads */
   for (started=0; started<NUM_THREADS; started++)
-    pthread_create(&threads[started], NULL, search, (void *)pid);
+    pthread_create(&threads[started], NULL, search, (void *)(long) pid);
 
   /* Wait for (join) all the searching threads */
   for (i=0; i<NUM_THREADS; i++)
@@ -66,7 +66,7 @@ void print_it(void *arg)
 
 void *search(void *arg)
 {
-  int num = (int) arg;
+  int num = (long) arg;
   int i, j, ntries;
   pthread_t tid;
 
--- libc/linuxthreads/Examples/ex8.c.jj	Tue Jul 18 10:43:51 2000
+++ libc/linuxthreads/Examples/ex8.c	Mon Nov 20 15:22:24 2000
@@ -68,7 +68,7 @@ main (void)
 
   pthread_join (th, &res);
 
-  return (int) res;
+  return (int)(long) res;
 }
 
 
@@ -97,5 +97,5 @@ thread (void *arg)
   if (status == 0)
     status = var != (PREPARE_BIT | PARENT_BIT);
 
-  return (void *) status;
+  return (void *)(long) status;
 }
--- libc/linuxthreads/Examples/ex11.c.jj	Mon Jun 26 10:01:03 2000
+++ libc/linuxthreads/Examples/ex11.c	Mon Nov 20 15:23:06 2000
@@ -128,7 +128,8 @@ main (void)
 
   for (n = 0; n < NWRITERS; ++n)
     {
-      int err = pthread_create (&thwr[n], NULL, writer_thread, (void *) n);
+      int err = pthread_create (&thwr[n], NULL, writer_thread,
+				(void *)(long) n);
 
       if (err != 0)
 	error (EXIT_FAILURE, err, "cannot create writer thread");
@@ -136,7 +137,8 @@ main (void)
 
   for (n = 0; n < NREADERS; ++n)
     {
-      int err = pthread_create (&thrd[n], NULL, reader_thread, (void *) n);
+      int err = pthread_create (&thrd[n], NULL, reader_thread,
+				(void *)(long) n);
 
       if (err != 0)
 	error (EXIT_FAILURE, err, "cannot create reader thread");
--- libc/linuxthreads/Examples/ex14.c.jj	Thu Nov  2 08:51:41 2000
+++ libc/linuxthreads/Examples/ex14.c	Mon Nov 20 15:26:23 2000
@@ -19,7 +19,7 @@ static void *
 worker (void *arg)
 {
   void *result = NULL;
-  int nr = (int) arg;
+  int nr = (long) arg;
   int i;
 
   for (i = 0; i < ROUNDS; ++i)
@@ -110,7 +110,7 @@ do_test (void)
 
   /* Start the threads.  */
   for (i = 0; i < NTHREADS; ++i)
-    if (pthread_create (&threads[i], NULL, worker, (void *) i) != 0)
+    if (pthread_create (&threads[i], NULL, worker, (void *)(long) i) != 0)
       {
 	printf ("Failed to start thread %d\n", i);
 	exit (1);
--- libc/linuxthreads/ecmutex.c.jj	Tue Sep  5 10:33:32 2000
+++ libc/linuxthreads/ecmutex.c	Mon Nov 20 15:25:54 2000
@@ -14,7 +14,7 @@ static pthread_mutex_t locks[] =
   PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP,
   PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
 };
-#define nlocks (sizeof (locks) / sizeof (locks[0]))
+#define nlocks ((int) (sizeof (locks) / sizeof (locks[0])))
 
 static pthread_barrier_t barrier;
 #define SYNC pthread_barrier_wait (&barrier)
@@ -30,7 +30,7 @@ worker (void *arg)
   /* We are locking the and unlocked the locks and check the errors.
      Since we are using the error-checking variant the implementation
      should report them.  */
-  int nr = (int) arg;
+  int nr = (long) arg;
   int i;
   void *result = NULL;
   int retval;
@@ -141,7 +141,7 @@ do_test (void)
   pthread_barrier_init (&barrier, NULL, NTHREADS);
 
   for (i = 0; i < NTHREADS; ++i)
-    if (pthread_create (&threads[i], NULL, worker, (void *) i) != 0)
+    if (pthread_create (&threads[i], NULL, worker, (void *)(long) i) != 0)
       {
 	printf ("failed to create thread %d: %m\n", i);
 	exit (1);
--- libc/malloc/tst-valloc.c.jj	Tue Feb 22 06:23:04 2000
+++ libc/malloc/tst-valloc.c	Mon Nov 20 15:10:00 2000
@@ -10,7 +10,7 @@ int main(void)
   int i;
 
   p = valloc (pagesize);
-  i = (int) p;
+  i = (long int) p;
 
   if ((i & (pagesize-1)) != 0) {
     fprintf (stderr, "Alignment problem: valloc returns %p\n", p);
--- libc/malloc/tst-obstack.c.jj	Tue Oct 24 10:30:36 2000
+++ libc/malloc/tst-obstack.c	Mon Nov 20 15:11:19 2000
@@ -14,7 +14,7 @@ static void *
 verbose_malloc (size_t size)
 {
   void *buf = malloc (size);
-  printf ("malloc (%u) => %p\n", size, buf);
+  printf ("malloc (%zu) => %p\n", size, buf);
   return buf;
 }
 
--- libc/math/test-fpucw.c.jj	Wed Aug  2 21:36:29 2000
+++ libc/math/test-fpucw.c	Mon Nov 20 14:11:22 2000
@@ -32,8 +32,8 @@ main (void)
   cw &= ~_FPU_RESERVED;
 
   if (cw != (_FPU_DEFAULT & ~_FPU_RESERVED))
-    printf ("control word is 0x%x but should be 0x%x.\n",
-	    cw, (_FPU_DEFAULT & ~_FPU_RESERVED));
+    printf ("control word is 0x%lx but should be 0x%lx.\n",
+	    (long int) cw, (long int) (_FPU_DEFAULT & ~_FPU_RESERVED));
 
   return cw != (_FPU_DEFAULT & ~_FPU_RESERVED);
 
--- libc/stdio-common/tst-fmemopen.c.jj	Tue Oct 31 06:17:06 2000
+++ libc/stdio-common/tst-fmemopen.c	Mon Nov 20 15:08:09 2000
@@ -34,7 +34,7 @@ main (void)
       fputc (ch, stdout);
       if (ch != *cp)
 	{
-	  printf ("\ncharacter %d: '%c' instead of '%c'\n",
+	  printf ("\ncharacter %td: '%c' instead of '%c'\n",
 		  cp - blah, ch, *cp);
 	  exit (1);
 	}
@@ -79,7 +79,7 @@ main (void)
       fputc (ch, stdout);
       if (ch != *cp)
 	{
-	  printf ("%d character: '%c' instead of '%c'\n",
+	  printf ("%td character: '%c' instead of '%c'\n",
 		  cp - blah, ch, *cp);
 	  exit (1);
 	}
--- libc/stdlib/tst-limits.c.jj	Sat Sep 16 03:28:25 2000
+++ libc/stdlib/tst-limits.c	Mon Nov 20 14:52:51 2000
@@ -62,8 +62,8 @@ main (void)
   TEST (PAGE_SIZE, "d", getpagesize ());
 #endif
 
-  TEST (WORD_BIT, "d", sizeof (int) * CHAR_BIT);
-  TEST (LONG_BIT, "d", sizeof (long int) * CHAR_BIT);
+  TEST (WORD_BIT, "zd", sizeof (int) * CHAR_BIT);
+  TEST (LONG_BIT, "zd", sizeof (long int) * CHAR_BIT);
 
   return result;
 }
--- libc/stdlib/tst-strtol.c.jj	Tue Aug 22 10:12:59 2000
+++ libc/stdlib/tst-strtol.c	Mon Nov 20 14:49:13 2000
@@ -70,8 +70,8 @@ static const struct ltest tests[] =
   {"922337203685477580777", 9223372036854775807, 0, 0, ERANGE},
   {"9223372036854775810", 9223372036854775807, 0, 0, ERANGE},
   {"-2147483648", -2147483648, 0, 0, 0},
-  {"-9223372036854775808", -9223372036854775808, 0, 0, 0},
-  {"-9223372036854775809", -9223372036854775808, 0, 0, ERANGE},
+  {"-9223372036854775808", 0x8000000000000000, 0, 0, 0},
+  {"-9223372036854775809", 0x8000000000000000, 0, 0, ERANGE},
   {"0x112233445566778899z", 9223372036854775807, 16, 'z', ERANGE},
   {"0xFFFFFFFFFFFF00FF" , 9223372036854775807, 0, 0, ERANGE},
 #endif
--- libc/sysdeps/unix/sysv/linux/sparc/bits/types.h.jj	Mon Aug 14 07:08:25 2000
+++ libc/sysdeps/unix/sysv/linux/sparc/bits/types.h	Mon Nov 20 14:59:44 2000
@@ -81,7 +81,7 @@ typedef __quad_t  __off64_t;		/*  "" (LF
 typedef __quad_t __loff_t;		/* Type of file sizes and offsets.  */
 typedef int __pid_t;			/* Type of process identifications.  */
 #if __WORDSIZE == 64
-typedef long long int __ssize_t;	/* Type of a byte count, or error.  */
+typedef long int __ssize_t;		/* Type of a byte count, or error.  */
 #else
 typedef int __ssize_t;			/* Type of a byte count, or error.  */
 #endif

	Jakub

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