[patch 167/192] lib: memscan() fixlet

From
Andrew Morton <akpm@linux-foundation.org>
Date
2021-07-01 01:56:04
Also in
mm-commits
Reply to
Andrew Morton, 2021-07-01
From: Alexey Dobriyan <redacted>
Subject: lib: memscan() fixlet

Generic version doesn't trucate second argument to char.

Older brother memchr() does as do s390, sparc and i386 assembly versions.

Fortunately, no code passes c >= 256.

Link: https://lkml.kernel.org/r/YLv4cCf0t5UPdyK+@localhost.localdomain (local)
Signed-off-by: Alexey Dobriyan <redacted>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 lib/string.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--- a/lib/string.c~lib-memscan-fixlet
+++ a/lib/string.c
@@ -977,7 +977,7 @@ void *memscan(void *addr, int c, size_t
 	unsigned char *p = addr;
 
 	while (size) {
-		if (*p == c)
+		if (*p == (unsigned char)c)
 			return (void *)p;
 		p++;
 		size--;
_
Thread (212 messages) 212 messages, 11 authors, last reply 2021-07-12
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help