This is the mail archive of the
libc-alpha@sourceware.cygnus.com
mailing list for the glibc project.
warning about __strndup
- To: libc-alpha at sourceware dot cygnus dot com
- Subject: warning about __strndup
- From: Bruno Haible <haible at ilog dot fr>
- Date: Tue, 2 May 2000 15:39:46 +0200 (MET DST)
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