This is the mail archive of the libc-hacker@sourceware.cygnus.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] shut up warnings in bits/string2.h


Hi!

This patch shuts up gcc 2.96 warnings about long switch expressions not
converted to int.
BTW: I've seen pretty bad code as result of the string2.h inlines on sparc,
while -D__NO_STRING_INLINES gave me much better code as the compiler did the
job. I'll investigate why that happens and for which functions and submit a
sparc string.h which will disable those inlines from string2.h which result
in bad code. How does it work on other architectures?

1999-12-07  Jakub Jelinek  <jakub@redhat.com>

	* string/bits/string2.h (__memset_gc, __mempcpy_small, __strcpy_small,
	__stpcpy_small): Cast switch expressions to int to shut up compiler
	warnings.

--- string/bits/string2.h.jj12	Thu Oct 14 21:29:59 1999
+++ string/bits/string2.h	Mon Dec  6 12:18:37 1999
@@ -118,7 +118,7 @@ __STRING2_COPY_TYPE (8);
      __uint8_t __c = (__uint8_t) (c);					      \
 									      \
      /* This `switch' statement will be removed at compile-time.  */	      \
-     switch (n)								      \
+     switch ((unsigned int)n)						      \
        {								      \
        case 15:								      \
 	 __u->__ui = __c * 0x01010101;					      \
@@ -230,7 +230,7 @@ __mempcpy_small (void *__dest1,
     unsigned char __uc;
     unsigned char __c;
   } *__u = __dest1;
-  switch (__srclen)
+  switch ((unsigned int)__srclen)
     {
     case 1:
       __u->__c = __src0_1;
@@ -332,7 +332,7 @@ __mempcpy_small (void *__dest, char __sr
     __STRING2_COPY_ARR7 __sca7;
     __STRING2_COPY_ARR8 __sca8;
   } *__u = __dest;
-  switch (__srclen)
+  switch ((unsigned int)__srclen)
     {
     case 1:
       __u->__c = __src1;
@@ -405,7 +405,7 @@ __strcpy_small (char *__dest,
     __uint16_t __usi;
     unsigned char __uc;
   } *__u = (void *) __dest;
-  switch (__srclen)
+  switch ((unsigned int)__srclen)
     {
     case 1:
       __u->__uc = '\0';
@@ -498,7 +498,7 @@ __strcpy_small (char *__dest,
     __STRING2_COPY_ARR7 __sca7;
     __STRING2_COPY_ARR8 __sca8;
   } *__u = (void *) __dest;
-  switch (__srclen)
+  switch ((unsigned int)__srclen)
     {
     case 1:
       __u->__c = '\0';
@@ -565,7 +565,7 @@ __stpcpy_small (char *__dest,
     unsigned char __uc;
     char __c;
   } *__u = (void *) __dest;
-  switch (__srclen)
+  switch ((unsigned int)__srclen)
     {
     case 1:
       __u->__uc = '\0';
@@ -662,7 +662,7 @@ __stpcpy_small (char *__dest,
     __STRING2_COPY_ARR7 __sca7;
     __STRING2_COPY_ARR8 __sca8;
   } *__u = (void *) __dest;
-  switch (__srclen)
+  switch ((unsigned int)__srclen)
     {
     case 1:
       __u->__c = '\0';

Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jakub@redhat.com | http://sunsite.mff.cuni.cz/~jj
Linux version 2.3.18 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________

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