mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-27 15:24:54 +00:00
libc: fix memchr implementation
The previous implementation could behave incorrectly because of the sign extension of the char when compared to the int. Change-Id: I397838b0ec87a6f1af6972d022a8c19a5184b447 Signed-off-by: Ambroise Vincent <ambroise.vincent@arm.com>
This commit is contained in:
parent
de3ad4f096
commit
294062fabf
1 changed files with 2 additions and 2 deletions
|
@ -9,10 +9,10 @@
|
||||||
|
|
||||||
void *memchr(const void *src, int c, size_t len)
|
void *memchr(const void *src, int c, size_t len)
|
||||||
{
|
{
|
||||||
const char *s = src;
|
const unsigned char *s = src;
|
||||||
|
|
||||||
while (len--) {
|
while (len--) {
|
||||||
if (*s == c)
|
if (*s == (unsigned char)c)
|
||||||
return (void *) s;
|
return (void *) s;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue