Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6a2eedf authored by André Goddard Rosa's avatar André Goddard Rosa Committed by Linus Torvalds
Browse files

lib/string.c: simplify strnstr()



Signed-off-by: default avatarAndré 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a11d2b64
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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++;