mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 22:53:20 +00:00
b3f4f51ea6
The C standard says that memcmp() must treat the buffers as consisting
of "unsigned chars". If char happens to be unsigned, the casts are ok,
but then obviously the c1 variable can never contain a negative
value. And when char is signed, the casts are wrong, and there's still
a problem with using an 8-bit quantity to hold the difference, because
that can range from -255 to +255.
For example, assuming char is signed, comparing two 1-byte buffers,
one containing 0x00 and another 0x80, the current implementation would
return -128 for both memcmp(a, b, 1) and memcmp(b, a, 1), whereas one
of those should of course return something positive.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Fixes:
|
||
---|---|---|
.. | ||
arch-aarch64.h | ||
arch-arm.h | ||
arch-i386.h | ||
arch-mips.h | ||
arch-riscv.h | ||
arch-x86_64.h | ||
arch.h | ||
ctype.h | ||
errno.h | ||
Makefile | ||
nolibc.h | ||
signal.h | ||
std.h | ||
stdio.h | ||
stdlib.h | ||
string.h | ||
sys.h | ||
time.h | ||
types.h | ||
unistd.h |