arm-trusted-firmware/lib/stdlib
dp-arm afc03aebd3 stdlib: Fix signedness issue in memcmp()
There is no guarantee on the signedness of char.  It can be either
signed or unsigned.  On ARM it is unsigned and hence this memcmp()
implementation works as intended.

On other machines, char can be signed (x86 for example).  In that case
(and assuming a 2's complement implementation), interpreting a
bit-pattern of 0xFF as signed char can yield -1.  If *s1 is 0 and *s2
is 255 then the difference *s1 - *s2 should be negative.  The C
integer promotion rules guarantee that the unsigned chars will be
converted to int before the operation takes place.  The current
implementation will return a positive value (0 - (-1)) instead, which
is wrong.

Fix it by changing the signedness to unsigned to avoid surprises for
anyone using this code on non-ARM systems.

Change-Id: Ie222fcaa7c0c4272d7a521a6f2f51995fd5130cc
Signed-off-by: dp-arm <dimitris.papastamos@arm.com>
2016-12-13 11:16:31 +00:00
..
abort.c Rationalize console log output 2014-08-12 16:51:18 +01:00
assert.c Rationalize console log output 2014-08-12 16:51:18 +01:00
exit.c stdlib: add missing features to build PolarSSL 2015-01-28 18:26:59 +00:00
mem.c stdlib: Fix signedness issue in memcmp() 2016-12-13 11:16:31 +00:00
printf.c Update year in copyright text to 2014 2014-01-17 10:27:53 +00:00
putchar.c Update year in copyright text to 2014 2014-01-17 10:27:53 +00:00
puts.c Update year in copyright text to 2014 2014-01-17 10:27:53 +00:00
sscanf.c stdlib: add missing features to build PolarSSL 2015-01-28 18:26:59 +00:00
stdlib.mk Move stdlib header files to include/lib/stdlib 2016-06-03 14:20:48 +01:00
strchr.c Update year in copyright text to 2014 2014-01-17 10:27:53 +00:00
strcmp.c stdlib: add missing features to build PolarSSL 2015-01-28 18:26:59 +00:00
strlen.c Update year in copyright text to 2014 2014-01-17 10:27:53 +00:00
strncmp.c Add IO abstraction framework 2014-02-17 18:51:43 +00:00
subr_prf.c Update year in copyright text to 2014 2014-01-17 10:27:53 +00:00