lib/string.c: simplify strnstr()
authorAndré Goddard Rosa <andre.goddard@gmail.com>
Fri, 5 Mar 2010 21:43:12 +0000 (13:43 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Mar 2010 19:26:35 +0000 (11:26 -0800)
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Joe Perches <joe@perches.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/string.c

index 0f86245320820b556e5c9f82effa938bc95801e3..f71bead1be3efaf5694cbbe1df1d59edb18b74ae 100644 (file)
@@ -689,13 +689,13 @@ EXPORT_SYMBOL(strstr);
  */
 char *strnstr(const char *s1, const char *s2, size_t len)
 {
-       size_t l1 = len, l2;
+       size_t l2;
 
        l2 = strlen(s2);
        if (!l2)
                return (char *)s1;
-       while (l1 >= l2) {
-               l1--;
+       while (len >= l2) {
+               len--;
                if (!memcmp(s1, s2, l2))
                        return (char *)s1;
                s1++;