This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


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

Re: warning about __strndup


>>>>> Bruno Haible writes:

 > In glibc-2000-04-28, programs using 'strndup' get annoying warnings.

 > $ cat foo.c
 > #define _GNU_SOURCE /* so that <string.h> declares strndup */
 > #include <string.h>
 > char *call_strdup (char *s) { return strdup(s); }
 > char *call_strndup (char *s) { return strndup(s,4); }

 > $ gcc -O -S -Wall foo.c
 > foo.c: In function `call_strndup':
 > foo.c:4: warning: implicit declaration of function `__strndup'
 > foo.c:4: warning: pointer/integer type mismatch in conditional expression

 > Here is a fix:


 > 2000-04-30  Bruno Haible  <haible@clisp.cons.org>

 > 	* string/string.h: Add declaration of __strndup.

 > *** string/string.h.bak	Sun Apr 30 23:37:16 2000
 > --- string/string.h	Mon May  1 00:20:01 2000
 > ***************
 > *** 120,125 ****
 > --- 120,127 ----
 >      resultant string is terminated even if no null terminator
 >      appears before STRING[N].  */
 >   #if defined __USE_GNU
 > + extern char *__strndup (__const char *__string, size_t __n)
 > +      __THROW __attribute_malloc__;
 >   extern char *strndup (__const char *__string, size_t __n)
 >        __THROW __attribute_malloc__;
 >   #endif

I would prefer to move __strndup and also __strdup into
strings/bits/string2.h.  Uli, what do you think?

Andreas
-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.rhein-neckar.de

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