mm: move MAP_SYNC to asm-generic/mman-common.h
[linux-2.6-block.git] / lib / string.c
index 6016eb3ac73d9e6516a63fd6845edd998db23524..461fb620f85f315afcc2ad9577d510ddf039fb68 100644 (file)
@@ -400,6 +400,9 @@ EXPORT_SYMBOL(strncmp);
  * strchr - Find the first occurrence of a character in a string
  * @s: The string to be searched
  * @c: The character to search for
+ *
+ * Note that the %NUL-terminator is considered part of the string, and can
+ * be searched for.
  */
 char *strchr(const char *s, int c)
 {
@@ -453,12 +456,18 @@ EXPORT_SYMBOL(strrchr);
  * @s: The string to be searched
  * @count: The number of characters to be searched
  * @c: The character to search for
+ *
+ * Note that the %NUL-terminator is considered part of the string, and can
+ * be searched for.
  */
 char *strnchr(const char *s, size_t count, int c)
 {
-       for (; count-- && *s != '\0'; ++s)
+       while (count--) {
                if (*s == (char)c)
                        return (char *)s;
+               if (*s++ == '\0')
+                       break;
+       }
        return NULL;
 }
 EXPORT_SYMBOL(strnchr);