From 48fbf21a6d6085d561757afb162d9f7b98792bf9 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Fri, 5 Dec 2025 21:54:50 -0700 Subject: map: stop setting errno on error the return of these functions already give all the necessary information. this is not c standard library code, we have no need of such a nonsensical error reporting mechanism NOTE: since errno needs to be thread local accessing it from non-libc code ends up being a function call and serves as a pointless optimization barrier. --- test/core/map-test.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/core/map-test.c b/test/core/map-test.c index 7a23d57..beb6ba2 100644 --- a/test/core/map-test.c +++ b/test/core/map-test.c @@ -2,7 +2,6 @@ #include #include #include -#include #include "tap.h" #include "map.h" @@ -52,16 +51,16 @@ int main(int argc, char *argv[]) { ok(!map_get(map, "404"), "Get non-existing key"); ok(!map_contains(map, "404"), "Contains non-existing key"); - ok(!map_closest(map, "404") && errno == ENOENT, "Closest non-existing key"); + ok(!map_closest(map, "404"), "Closest non-existing key"); - ok(!map_put(map, "a", NULL) && errno == EINVAL && map_empty(map) && !map_get(map, "a"), "Put NULL value"); + ok(!map_put(map, "a", NULL) && map_empty(map) && !map_get(map, "a"), "Put NULL value"); ok(map_put(map, "a", &values[0]) && !map_empty(map) && get(map, "a", &values[0]), "Put 1"); ok(map_first(map, &key) == &values[0] && strcmp(key, "a") == 0, "First on map with 1 value"); key = NULL; ok(map_first(map_prefix(map, "a"), &key) == &values[0] && strcmp(key, "a") == 0, "First on prefix map"); ok(map_contains(map, "a"), "Contains existing key"); ok(map_closest(map, "a") == &values[0], "Closest match existing key"); - ok(!map_put(map, "a", &values[1]) && errno == EEXIST && get(map, "a", &values[0]), "Put duplicate"); + ok(!map_put(map, "a", &values[1]) && get(map, "a", &values[0]), "Put duplicate"); ok(map_put(map, "cafebabe", &values[2]) && get(map, "cafebabe", &values[2]), "Put 2"); ok(map_put(map, "cafe", &values[1]) && get(map, "cafe", &values[1]), "Put 3"); key = NULL; @@ -77,7 +76,7 @@ int main(int argc, char *argv[]) { map_iterate(copy, once, &counter); ok(counter == 1, "Iterate stop condition"); - ok(!map_get(map, "ca") && !map_closest(map, "ca") && errno == 0, "Closest ambigious"); + ok(!map_get(map, "ca") && !map_closest(map, "ca"), "Closest ambigious"); int visited[] = { 0, 0, 0 }; -- cgit v1.2.3