[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 2/3] string: remove memscan()
It has no users, so rather than fixing its use of types (first and foremost c would need to be cast to unsigned char in the comparison expression) drop it altogether. memchr() ought to be fine for all purposes. Take the opportunity and also do some stylistic adjustments to its surviving sibling function memchr(). Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/xen/common/string.c +++ b/xen/common/string.c @@ -380,30 +380,6 @@ int (memcmp)(const void *cs, const void } #endif -#ifndef __HAVE_ARCH_MEMSCAN -/** - * memscan - Find a character in an area of memory. - * @addr: The memory area - * @c: The byte to search for - * @size: The size of the area. - * - * returns the address of the first occurrence of @c, or 1 byte past - * the area if @c is not found - */ -void * memscan(void * addr, int c, size_t size) -{ - unsigned char * p = (unsigned char *) addr; - - while (size) { - if (*p == c) - return (void *) p; - p++; - size--; - } - return (void *) p; -} -#endif - #ifndef __HAVE_ARCH_STRSTR /** * strstr - Find the first substring in a %NUL terminated string @@ -441,14 +417,13 @@ char *(strstr)(const char *s1, const cha void *(memchr)(const void *s, int c, size_t n) { const unsigned char *p = s; - while (n-- != 0) { - if ((unsigned char)c == *p++) { - return (void *)(p-1); - } - } + + while (n--) + if ((unsigned char)c == *p++) + return (void *)(p - 1); + return NULL; } - #endif /* --- a/xen/include/xen/string.h +++ b/xen/include/xen/string.h @@ -96,10 +96,6 @@ void *memmove(void *, const void *, size #define memmove(d, s, n) __builtin_memmove(d, s, n) #endif -#ifndef __HAVE_ARCH_MEMSCAN -void *memscan(void *, int, size_t); -#endif - #ifndef __HAVE_ARCH_MEMCMP int memcmp(const void *, const void *, size_t); #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n) _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |