Warner Losh schrieb:
Author: imp Date: Tue Feb 3 20:25:36 2009 New Revision: 188098 URL: http://svn.freebsd.org/changeset/base/188098Log: Fix the functions to match prototypes. The K&R definitions differ from the ANSI-C prototype due to the 'int promotion' rule. Modified: head/lib/libc/string/memchr.c head/lib/libc/string/strmode.c head/lib/libc/string/wmemset.c Modified: head/lib/libc/string/memchr.c ============================================================================== --- head/lib/libc/string/memchr.c Tue Feb 3 20:01:51 2009 (r188097) +++ head/lib/libc/string/memchr.c Tue Feb 3 20:25:36 2009 (r188098) @@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$"); #include <string.h>void *-memchr(const void *s, unsigned char c, size_t n) +memchr(const void *s, int c, size_t n) { if (n != 0) { const unsigned char *p = s;
This is not correct either, because now *p (of type unsigned char) gets compared with c (now type int). The manpage of memchr() states that
"The memchr() function locates the first occurrence of c (converted to an unsigned char) in string b."
The part in parentheses now is missing. This will break when you pass a negative number (e.g. -1, which should locate a byte with all bits set) to memchr().
_______________________________________________ [email protected] mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "[email protected]"
