Skip to content

Commit

Permalink
lib/string.c: simplify strnstr()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
André Goddard Rosa authored and Linus Torvalds committed Mar 6, 2010
1 parent a11d2b6 commit d6a2eed
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit d6a2eed

Please sign in to comment.