]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
String tests: fixed too strict strcmp checks
authorMaria Matejka <mq@ucw.cz>
Wed, 27 Nov 2024 11:01:58 +0000 (12:01 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 27 Nov 2024 11:01:58 +0000 (12:01 +0100)
The strcmp function is not guaranteed to return -1 or +1
but any negative or positive value if the input strings
are different. Fixed the false assumption which triggered
a build bug on emulated arm64.

lib/printf_test.c

index 88ecf05e2c9fe5789d2209d621dc69261c873707..996f34ae8ab8d3681be183979e0a71a19e3d0bd4 100644 (file)
@@ -108,8 +108,8 @@ static int
 t_bstrcmp(void)
 {
   bt_assert(bstrcmp("aa", "aa") == 0);
-  bt_assert(bstrcmp("aa", "bb") == -1);
-  bt_assert(bstrcmp("bb", "aa") == 1);
+  bt_assert(bstrcmp("aa", "bb") < 0);
+  bt_assert(bstrcmp("bb", "aa") > 0);
   bt_assert(bstrcmp(NULL, NULL) == 0);
   bt_assert(bstrcmp(NULL, "bb") == -1);
   bt_assert(bstrcmp("bb", NULL) == 1);