]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
string: remove memscan()
authorJan Beulich <jbeulich@suse.com>
Wed, 13 Mar 2019 10:25:04 +0000 (11:25 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 13 Mar 2019 10:25:04 +0000 (11:25 +0100)
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@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/string.c
xen/include/xen/string.h

index b8639dd30db780c5391987ba60d4b87eb6959934..dafeaa827d3fbb5136f194ac7e7c27493652487e 100644 (file)
@@ -380,30 +380,6 @@ int (memcmp)(const void *cs, const void *ct, size_t count)
 }
 #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 char *s2)
 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
 
 /*
index 853db2f6b40d9470b1139b8e8485f705602834f1..711cb60a7de69867e486ce03ac6c42f86eb4d208 100644 (file)
@@ -96,10 +96,6 @@ void *memmove(void *, const void *, size_t);
 #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)