From 3946aa9bac1b4a784924fab1693bfebfdd357438 Mon Sep 17 00:00:00 2001 From: Aaron Young Date: Wed, 9 Jan 2019 11:35:39 -0800 Subject: [libc] Fix strcmp()/strncmp() to return proper values Fix strcmp() and strncmp() to return proper standard positive/negative values for unequal strings. Current implementation is backwards (i.e. the functions are returning negative when should be positive and vice-versa). Currently all consumers of these functions only check the return value for ==0 or !=0 and so we can safely change the implementation without breaking things. Signed-off-by: Aaron Young Modified-by: Michael Brown Signed-off-by: Michael Brown --- src/tests/string_test.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/tests') diff --git a/src/tests/string_test.c b/src/tests/string_test.c index 4693b5f6..a66501da 100644 --- a/src/tests/string_test.c +++ b/src/tests/string_test.c @@ -88,6 +88,7 @@ static void string_test_exec ( void ) { ok ( strcmp ( "Hello", "hello" ) != 0 ); ok ( strcmp ( "Hello", "Hello world!" ) != 0 ); ok ( strcmp ( "Hello world!", "Hello" ) != 0 ); + ok ( strcmp ( "abc", "def" ) < 0 ); /* Test strncmp() */ ok ( strncmp ( "", "", 0 ) == 0 ); -- cgit v1.2.3-55-g7522