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] for bits/string2.h



Hi,

The patch:

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.

breaks a lot of programs. The following construct ends with a
compiler error:

memset(pwbuf, 0, p - pwbuf);

Reason: It will be resolved to "(unsinged int) p - pwbuf"

The attached Patch for glibc 2.1 and 2.2 fixes this.

  Thorsten
-- 
Thorsten Kukuk       http://www.suse.de/~kukuk/       kukuk@suse.de
SuSE GmbH            Schanzaeckerstr. 10            90443 Nuernberg
Linux is like a Vorlon.  It is incredibly powerful, gives terse,
cryptic answers and has a lot of things going on in the background.
1999-12-17  Thorsten Kukuk  <kukuk@suse.de>

	* string/bits/string2.h: Fix patch from 1999-12-07

--- string/bits/string2.h
+++ string/bits/string2.h	1999/12/17 10:59:17
@@ -118,7 +118,7 @@
      __uint8_t __c = (__uint8_t) (c);					      \
 									      \
      /* This `switch' statement will be removed at compile-time.  */	      \
-     switch ((unsigned int) n)						      \
+     switch ((unsigned int) (n))       					      \
        {								      \
        case 15:								      \
 	 __u->__ui = __c * 0x01010101;					      \
@@ -231,7 +231,7 @@
     unsigned char __uc;
     unsigned char __c;
   } *__u = __dest1;
-  switch ((unsigned int) __srclen)
+  switch ((unsigned int) (__srclen))
     {
     case 1:
       __u->__c = __src0_1;
@@ -406,7 +406,7 @@
     __uint16_t __usi;
     unsigned char __uc;
   } *__u = (void *) __dest;
-  switch ((unsigned int) __srclen)
+  switch ((unsigned int) (__srclen))
     {
     case 1:
       __u->__uc = '\0';
@@ -499,7 +499,7 @@
     __STRING2_COPY_ARR7 __sca7;
     __STRING2_COPY_ARR8 __sca8;
   } *__u = (void *) __dest;
-  switch ((unsigned int) __srclen)
+  switch ((unsigned int) (__srclen))
     {
     case 1:
       __u->__c = '\0';
@@ -566,7 +566,7 @@
     unsigned char __uc;
     char __c;
   } *__u = (void *) __dest;
-  switch ((unsigned int) __srclen)
+  switch ((unsigned int) (__srclen))
     {
     case 1:
       __u->__uc = '\0';
@@ -663,7 +663,7 @@
     __STRING2_COPY_ARR7 __sca7;
     __STRING2_COPY_ARR8 __sca8;
   } *__u = (void *) __dest;
-  switch ((unsigned int) __srclen)
+  switch ((unsigned int) (__srclen))
     {
     case 1:
       __u->__c = '\0';

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