This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
suppressing warnings, patch for string/bits/string2.h
- To: libc-alpha at sources dot redhat dot com
- Subject: suppressing warnings, patch for string/bits/string2.h
- From: GOTO Masanori <gotom at debian dot or dot jp>
- Date: Sat, 27 Jan 2001 23:40:33 +0900
- Cc: gotom at debian dot org
The declaration of __strsep() should move to
in front of the declaration of __strpbrk() in string/bits/string2.h,
because __strpbrk() uses __strsep().
For example:
---- test.c
#include <string.h>
int main( void ){ return 0; }
----
# gcc -Wall -Wconversion -O -o test test.c
In file included from /usr/include/string.h:346,
from test.c:2:
/usr/include/bits/string2.h: In function `__strsep_g':
/usr/include/bits/string2.h:1171: warning: passing arg 2 of `__strpbrk_c2' with different width due to prototype
/usr/include/bits/string2.h:1171: warning: passing arg 3 of `__strpbrk_c2' with different width due to prototype
/usr/include/bits/string2.h:1171: warning: passing arg 2 of `__strpbrk_c3' with different width due to prototype
/usr/include/bits/string2.h:1171: warning: passing arg 3 of `__strpbrk_c3' with different width due to prototype
/usr/include/bits/string2.h:1171: warning: passing arg 4 of `__strpbrk_c3' with different width due to prototype
In addition, these warnings did not occur
when I removed optimization option (-O) from gcc options.
This patch suppresses these warnings.
Regars,
-- GOTO Masanori
2001-01-27 GOTO Masanori <gotom@debian.or.jp>
* string/bits/string2.h: Changed the declaration order of
__strsep().
--- string/bits/string2.h Sat Dec 2 22:52:06 2000
+++ string/bits/string2.h.new Sat Jan 27 23:12:59 2001
@@ -963,6 +963,111 @@
#endif
+#ifndef _HAVE_STRING_ARCH_strsep
+
+# define __strsep(s, reject) \
+ __extension__ \
+ ({ char __r0, __r1, __r2; \
+ (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
+ && (__r0 = ((__const char *) (reject))[0], \
+ ((__const char *) (reject))[0] != '\0') \
+ ? ((__r1 = ((__const char *) (reject))[1], \
+ ((__const char *) (reject))[1] == '\0') \
+ ? __strsep_1c (s, __r0) \
+ : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0') \
+ ? __strsep_2c (s, __r0, __r1) \
+ : (((__const char *) (reject))[3] == '\0' \
+ ? __strsep_3c (s, __r0, __r1, __r2) \
+ : __strsep_g (s, reject)))) \
+ : __strsep_g (s, reject)); })
+
+__STRING_INLINE char *__strsep_1c (char **__s, char __reject);
+__STRING_INLINE char *
+__strsep_1c (char **__s, char __reject)
+{
+ register char *__retval = *__s;
+ if (__retval == NULL)
+ return *__s = NULL;
+ if (*__retval == __reject)
+ *(*__s)++ = '\0';
+ else
+ if ((*__s = strchr (__retval, __reject)) != NULL)
+ *(*__s)++ = '\0';
+ else
+ *__s = NULL;
+ return __retval;
+}
+
+__STRING_INLINE char *__strsep_2c (char **__s, char __reject1, char __reject2);
+__STRING_INLINE char *
+__strsep_2c (char **__s, char __reject1, char __reject2)
+{
+ register char *__retval = *__s;
+ if (__retval == NULL)
+ return *__s = NULL;
+ if (*__retval == __reject1 || *__retval == __reject2)
+ *(*__s)++ = '\0';
+ else
+ {
+ register char *__cp = __retval;
+ while (*__cp != '\0' && *__cp != __reject1 && *__cp != __reject2)
+ ++__cp;
+ if (*__cp != '\0')
+ {
+ *__s = __cp;
+ *(*__s)++ = '\0';
+ }
+ else
+ *__s = NULL;
+ }
+ return __retval;
+}
+
+__STRING_INLINE char *__strsep_3c (char **__s, char __reject1, char __reject2,
+ char __reject3);
+__STRING_INLINE char *
+__strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
+{
+ register char *__retval = *__s;
+ if (__retval == NULL)
+ return *__s = NULL;
+ if (*__retval == __reject1 || *__retval == __reject2
+ || *__retval == __reject3)
+ *(*__s)++ = '\0';
+ else
+ {
+ register char *__cp = __retval;
+ while (*__cp != '\0' && *__cp != __reject1 && *__cp != __reject2
+ && *__cp != __reject3)
+ ++__cp;
+ if (*__cp != '\0')
+ {
+ *__s = __cp;
+ *(*__s)++ = '\0';
+ }
+ else
+ *__s = NULL;
+ }
+ return __retval;
+}
+
+__STRING_INLINE char *__strsep_g (char **__s, __const char *__reject);
+__STRING_INLINE char *
+__strsep_g (char **__s, __const char *__reject)
+{
+ register char *__retval = *__s;
+ if (__retval == NULL)
+ return NULL;
+ if ((*__s = strpbrk (__retval, __reject)) != NULL)
+ *(*__s)++ = '\0';
+ return __retval;
+}
+# ifdef __USE_BSD
+# define strsep(s, reject) __strsep ((s), (reject))
+# endif
+#endif
+
+
/* Find the first occurrence in S of any character in ACCEPT. */
#ifndef _HAVE_STRING_ARCH_strpbrk
# define strpbrk(s, accept) \
@@ -1073,110 +1178,6 @@
# endif
#endif
-
-#ifndef _HAVE_STRING_ARCH_strsep
-
-# define __strsep(s, reject) \
- __extension__ \
- ({ char __r0, __r1, __r2; \
- (__builtin_constant_p (reject) && __string2_1bptr_p (reject) \
- && (__r0 = ((__const char *) (reject))[0], \
- ((__const char *) (reject))[0] != '\0') \
- ? ((__r1 = ((__const char *) (reject))[1], \
- ((__const char *) (reject))[1] == '\0') \
- ? __strsep_1c (s, __r0) \
- : ((__r2 = ((__const char *) (reject))[2], __r2 == '\0') \
- ? __strsep_2c (s, __r0, __r1) \
- : (((__const char *) (reject))[3] == '\0' \
- ? __strsep_3c (s, __r0, __r1, __r2) \
- : __strsep_g (s, reject)))) \
- : __strsep_g (s, reject)); })
-
-__STRING_INLINE char *__strsep_1c (char **__s, char __reject);
-__STRING_INLINE char *
-__strsep_1c (char **__s, char __reject)
-{
- register char *__retval = *__s;
- if (__retval == NULL)
- return *__s = NULL;
- if (*__retval == __reject)
- *(*__s)++ = '\0';
- else
- if ((*__s = strchr (__retval, __reject)) != NULL)
- *(*__s)++ = '\0';
- else
- *__s = NULL;
- return __retval;
-}
-
-__STRING_INLINE char *__strsep_2c (char **__s, char __reject1, char __reject2);
-__STRING_INLINE char *
-__strsep_2c (char **__s, char __reject1, char __reject2)
-{
- register char *__retval = *__s;
- if (__retval == NULL)
- return *__s = NULL;
- if (*__retval == __reject1 || *__retval == __reject2)
- *(*__s)++ = '\0';
- else
- {
- register char *__cp = __retval;
- while (*__cp != '\0' && *__cp != __reject1 && *__cp != __reject2)
- ++__cp;
- if (*__cp != '\0')
- {
- *__s = __cp;
- *(*__s)++ = '\0';
- }
- else
- *__s = NULL;
- }
- return __retval;
-}
-
-__STRING_INLINE char *__strsep_3c (char **__s, char __reject1, char __reject2,
- char __reject3);
-__STRING_INLINE char *
-__strsep_3c (char **__s, char __reject1, char __reject2, char __reject3)
-{
- register char *__retval = *__s;
- if (__retval == NULL)
- return *__s = NULL;
- if (*__retval == __reject1 || *__retval == __reject2
- || *__retval == __reject3)
- *(*__s)++ = '\0';
- else
- {
- register char *__cp = __retval;
- while (*__cp != '\0' && *__cp != __reject1 && *__cp != __reject2
- && *__cp != __reject3)
- ++__cp;
- if (*__cp != '\0')
- {
- *__s = __cp;
- *(*__s)++ = '\0';
- }
- else
- *__s = NULL;
- }
- return __retval;
-}
-
-__STRING_INLINE char *__strsep_g (char **__s, __const char *__reject);
-__STRING_INLINE char *
-__strsep_g (char **__s, __const char *__reject)
-{
- register char *__retval = *__s;
- if (__retval == NULL)
- return NULL;
- if ((*__s = strpbrk (__retval, __reject)) != NULL)
- *(*__s)++ = '\0';
- return __retval;
-}
-# ifdef __USE_BSD
-# define strsep(s, reject) __strsep ((s), (reject))
-# endif
-#endif
/* We need the memory allocation functions for inline strdup().
Referring to stdlib.h (even minimally) is not allowed