Bug Summary

File:build-scan/../src/test/test-hashmap.c
Warning:line 42, column 9
Value stored to 'm' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name test-hashmap.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -menable-no-infs -menable-no-nans -menable-unsafe-fp-math -fno-signed-zeros -mreassociate -freciprocal-math -fdenormal-fp-math=preserve-sign,preserve-sign -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/lib64/clang/12.0.0 -include config.h -I test-hashmap.p -I . -I .. -I src/basic -I ../src/basic -I src/shared -I ../src/shared -I src/systemd -I ../src/systemd -I src/journal -I ../src/journal -I src/journal-remote -I ../src/journal-remote -I src/nspawn -I ../src/nspawn -I src/resolve -I ../src/resolve -I src/timesync -I ../src/timesync -I ../src/time-wait-sync -I src/login -I ../src/login -I src/udev -I ../src/udev -I src/libudev -I ../src/libudev -I src/core -I ../src/core -I ../src/libsystemd/sd-bus -I ../src/libsystemd/sd-device -I ../src/libsystemd/sd-hwdb -I ../src/libsystemd/sd-id128 -I ../src/libsystemd/sd-netlink -I ../src/libsystemd/sd-network -I src/libsystemd-network -I ../src/libsystemd-network -I src/test -D _FILE_OFFSET_BITS=64 -internal-isystem /usr/local/include -internal-isystem /usr/lib64/clang/12.0.0/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wwrite-strings -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Wno-error=nonnull -std=gnu99 -fconst-strings -fdebug-compilation-dir /home/mrc0mmand/repos/@redhat-plumbers/systemd-rhel8/build-scan -ferror-limit 19 -fvisibility hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -analyzer-output=html -faddrsig -o /tmp/scan-build-2021-07-16-221226-1465241-1 -x c ../src/test/test-hashmap.c
1/* SPDX-License-Identifier: LGPL-2.1+ */
2/***
3 Copyright © 2013 Daniel Buch
4***/
5
6#include "hashmap.h"
7#include "util.h"
8
9void test_hashmap_funcs(void);
10void test_ordered_hashmap_funcs(void);
11
12static void test_ordered_hashmap_next(void) {
13 _cleanup_ordered_hashmap_free___attribute__((cleanup(ordered_hashmap_freep))) OrderedHashmap *m = NULL((void*)0);
14 int i;
15
16 assert_se(m = ordered_hashmap_new(NULL))do { if ((__builtin_expect(!!(!(m = internal_ordered_hashmap_new
(((void*)0) ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("m = ordered_hashmap_new(NULL)"), "../src/test/test-hashmap.c"
, 16, __PRETTY_FUNCTION__); } while (0)
;
17 for (i = -2; i <= 2; i++)
18 assert_se(ordered_hashmap_put(m, INT_TO_PTR(i), INT_TO_PTR(i+10)) == 1)do { if ((__builtin_expect(!!(!(ordered_hashmap_put(m, ((void
*) ((intptr_t) (i))), ((void *) ((intptr_t) (i+10)))) == 1))
,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("ordered_hashmap_put(m, INT_TO_PTR(i), INT_TO_PTR(i+10)) == 1"
), "../src/test/test-hashmap.c", 18, __PRETTY_FUNCTION__); } while
(0)
;
19 for (i = -2; i <= 1; i++)
20 assert_se(ordered_hashmap_next(m, INT_TO_PTR(i)) == INT_TO_PTR(i+11))do { if ((__builtin_expect(!!(!(ordered_hashmap_next(m, ((void
*) ((intptr_t) (i)))) == ((void *) ((intptr_t) (i+11))))),0)
)) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("ordered_hashmap_next(m, INT_TO_PTR(i)) == INT_TO_PTR(i+11)"
), "../src/test/test-hashmap.c", 20, __PRETTY_FUNCTION__); } while
(0)
;
21 assert_se(!ordered_hashmap_next(m, INT_TO_PTR(2)))do { if ((__builtin_expect(!!(!(!ordered_hashmap_next(m, ((void
*) ((intptr_t) (2)))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("!ordered_hashmap_next(m, INT_TO_PTR(2))"), "../src/test/test-hashmap.c"
, 21, __PRETTY_FUNCTION__); } while (0)
;
22 assert_se(!ordered_hashmap_next(NULL, INT_TO_PTR(1)))do { if ((__builtin_expect(!!(!(!ordered_hashmap_next(((void*
)0), ((void *) ((intptr_t) (1)))))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("!ordered_hashmap_next(NULL, INT_TO_PTR(1))"
), "../src/test/test-hashmap.c", 22, __PRETTY_FUNCTION__); } while
(0)
;
23 assert_se(!ordered_hashmap_next(m, INT_TO_PTR(3)))do { if ((__builtin_expect(!!(!(!ordered_hashmap_next(m, ((void
*) ((intptr_t) (3)))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("!ordered_hashmap_next(m, INT_TO_PTR(3))"), "../src/test/test-hashmap.c"
, 23, __PRETTY_FUNCTION__); } while (0)
;
24}
25
26typedef struct Item {
27 int seen;
28} Item;
29static void item_seen(Item *item) {
30 item->seen++;
31}
32
33static void test_hashmap_free_with_destructor(void) {
34 Hashmap *m;
35 struct Item items[4] = {};
36 unsigned i;
37
38 assert_se(m = hashmap_new(NULL))do { if ((__builtin_expect(!!(!(m = internal_hashmap_new(((void
*)0) ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("m = hashmap_new(NULL)"
), "../src/test/test-hashmap.c", 38, __PRETTY_FUNCTION__); } while
(0)
;
39 for (i = 0; i < ELEMENTSOF(items)__extension__ (__builtin_choose_expr( !__builtin_types_compatible_p
(typeof(items), typeof(&*(items))), sizeof(items)/sizeof(
(items)[0]), ((void)0)))
- 1; i++)
40 assert_se(hashmap_put(m, INT_TO_PTR(i), items + i) == 1)do { if ((__builtin_expect(!!(!(hashmap_put(m, ((void *) ((intptr_t
) (i))), items + i) == 1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_put(m, INT_TO_PTR(i), items + i) == 1"), "../src/test/test-hashmap.c"
, 40, __PRETTY_FUNCTION__); } while (0)
;
41
42 m = hashmap_free_with_destructor(m, item_seen)({ ({ void *_item; while ((_item = hashmap_steal_first(m))) item_seen
(_item); }); hashmap_free(m); })
;
Value stored to 'm' is never read
43 assert_se(items[0].seen == 1)do { if ((__builtin_expect(!!(!(items[0].seen == 1)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("items[0].seen == 1"), "../src/test/test-hashmap.c"
, 43, __PRETTY_FUNCTION__); } while (0)
;
44 assert_se(items[1].seen == 1)do { if ((__builtin_expect(!!(!(items[1].seen == 1)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("items[1].seen == 1"), "../src/test/test-hashmap.c"
, 44, __PRETTY_FUNCTION__); } while (0)
;
45 assert_se(items[2].seen == 1)do { if ((__builtin_expect(!!(!(items[2].seen == 1)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("items[2].seen == 1"), "../src/test/test-hashmap.c"
, 45, __PRETTY_FUNCTION__); } while (0)
;
46 assert_se(items[3].seen == 0)do { if ((__builtin_expect(!!(!(items[3].seen == 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("items[3].seen == 0"), "../src/test/test-hashmap.c"
, 46, __PRETTY_FUNCTION__); } while (0)
;
47}
48
49static void test_uint64_compare_func(void) {
50 const uint64_t a = 0x100, b = 0x101;
51
52 assert_se(uint64_compare_func(&a, &a) == 0)do { if ((__builtin_expect(!!(!(uint64_compare_func(&a, &
a) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("uint64_compare_func(&a, &a) == 0"
), "../src/test/test-hashmap.c", 52, __PRETTY_FUNCTION__); } while
(0)
;
53 assert_se(uint64_compare_func(&a, &b) == -1)do { if ((__builtin_expect(!!(!(uint64_compare_func(&a, &
b) == -1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("uint64_compare_func(&a, &b) == -1"
), "../src/test/test-hashmap.c", 53, __PRETTY_FUNCTION__); } while
(0)
;
54 assert_se(uint64_compare_func(&b, &a) == 1)do { if ((__builtin_expect(!!(!(uint64_compare_func(&b, &
a) == 1)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("uint64_compare_func(&b, &a) == 1"
), "../src/test/test-hashmap.c", 54, __PRETTY_FUNCTION__); } while
(0)
;
55}
56
57static void test_trivial_compare_func(void) {
58 assert_se(trivial_compare_func(INT_TO_PTR('a'), INT_TO_PTR('a')) == 0)do { if ((__builtin_expect(!!(!(trivial_compare_func(((void *
) ((intptr_t) ('a'))), ((void *) ((intptr_t) ('a')))) == 0)),
0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("trivial_compare_func(INT_TO_PTR('a'), INT_TO_PTR('a')) == 0"
), "../src/test/test-hashmap.c", 58, __PRETTY_FUNCTION__); } while
(0)
;
59 assert_se(trivial_compare_func(INT_TO_PTR('a'), INT_TO_PTR('b')) == -1)do { if ((__builtin_expect(!!(!(trivial_compare_func(((void *
) ((intptr_t) ('a'))), ((void *) ((intptr_t) ('b')))) == -1))
,0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("trivial_compare_func(INT_TO_PTR('a'), INT_TO_PTR('b')) == -1"
), "../src/test/test-hashmap.c", 59, __PRETTY_FUNCTION__); } while
(0)
;
60 assert_se(trivial_compare_func(INT_TO_PTR('b'), INT_TO_PTR('a')) == 1)do { if ((__builtin_expect(!!(!(trivial_compare_func(((void *
) ((intptr_t) ('b'))), ((void *) ((intptr_t) ('a')))) == 1)),
0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("trivial_compare_func(INT_TO_PTR('b'), INT_TO_PTR('a')) == 1"
), "../src/test/test-hashmap.c", 60, __PRETTY_FUNCTION__); } while
(0)
;
61}
62
63static void test_string_compare_func(void) {
64 assert_se(string_compare_func("fred", "wilma") != 0)do { if ((__builtin_expect(!!(!(string_compare_func("fred", "wilma"
) != 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("string_compare_func(\"fred\", \"wilma\") != 0"
), "../src/test/test-hashmap.c", 64, __PRETTY_FUNCTION__); } while
(0)
;
65 assert_se(string_compare_func("fred", "fred") == 0)do { if ((__builtin_expect(!!(!(string_compare_func("fred", "fred"
) == 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("string_compare_func(\"fred\", \"fred\") == 0"
), "../src/test/test-hashmap.c", 65, __PRETTY_FUNCTION__); } while
(0)
;
66}
67
68static void compare_cache(Hashmap *map, IteratedCache *cache) {
69 const void **keys = NULL((void*)0), **values = NULL((void*)0);
70 unsigned num, idx;
71 Iterator iter;
72 void *k, *v;
73
74 assert_se(iterated_cache_get(cache, &keys, &values, &num) == 0)do { if ((__builtin_expect(!!(!(iterated_cache_get(cache, &
keys, &values, &num) == 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("iterated_cache_get(cache, &keys, &values, &num) == 0"
), "../src/test/test-hashmap.c", 74, __PRETTY_FUNCTION__); } while
(0)
;
75 assert_se(num == 0 || keys)do { if ((__builtin_expect(!!(!(num == 0 || keys)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("num == 0 || keys"), "../src/test/test-hashmap.c"
, 75, __PRETTY_FUNCTION__); } while (0)
;
76 assert_se(num == 0 || values)do { if ((__builtin_expect(!!(!(num == 0 || values)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("num == 0 || values"), "../src/test/test-hashmap.c"
, 76, __PRETTY_FUNCTION__); } while (0)
;
77
78 idx = 0;
79 HASHMAP_FOREACH_KEY(v, k, map, iter)for ((iter) = ((Iterator) { .idx = ((2147483647 *2U +1U) - 1)
, .next_key = ((void*)0) }); hashmap_iterate((map), &(iter
), (void**)&(v), (const void**) &(k)); )
{
80 assert_se(v == values[idx])do { if ((__builtin_expect(!!(!(v == values[idx])),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("v == values[idx]"), "../src/test/test-hashmap.c"
, 80, __PRETTY_FUNCTION__); } while (0)
;
81 assert_se(k == keys[idx])do { if ((__builtin_expect(!!(!(k == keys[idx])),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("k == keys[idx]"), "../src/test/test-hashmap.c"
, 81, __PRETTY_FUNCTION__); } while (0)
;
82
83 idx++;
84 }
85
86 assert_se(idx == num)do { if ((__builtin_expect(!!(!(idx == num)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("idx == num"), "../src/test/test-hashmap.c"
, 86, __PRETTY_FUNCTION__); } while (0)
;
87}
88
89static void test_iterated_cache(void) {
90 Hashmap *m;
91 IteratedCache *c;
92
93 assert_se(m = hashmap_new(NULL))do { if ((__builtin_expect(!!(!(m = internal_hashmap_new(((void
*)0) ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("m = hashmap_new(NULL)"
), "../src/test/test-hashmap.c", 93, __PRETTY_FUNCTION__); } while
(0)
;
94 assert_se(c = hashmap_iterated_cache_new(m))do { if ((__builtin_expect(!!(!(c = hashmap_iterated_cache_new
(m))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("c = hashmap_iterated_cache_new(m)"
), "../src/test/test-hashmap.c", 94, __PRETTY_FUNCTION__); } while
(0)
;
95 compare_cache(m, c);
96
97 for (int stage = 0; stage < 100; stage++) {
98
99 for (int i = 0; i < 100; i++) {
100 int foo = stage * 1000 + i;
101
102 assert_se(hashmap_put(m, INT_TO_PTR(foo), INT_TO_PTR(foo + 777)) == 1)do { if ((__builtin_expect(!!(!(hashmap_put(m, ((void *) ((intptr_t
) (foo))), ((void *) ((intptr_t) (foo + 777)))) == 1)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_put(m, INT_TO_PTR(foo), INT_TO_PTR(foo + 777)) == 1"
), "../src/test/test-hashmap.c", 102, __PRETTY_FUNCTION__); }
while (0)
;
103 }
104
105 compare_cache(m, c);
106
107 if (!(stage % 10)) {
108 for (int i = 0; i < 100; i++) {
109 int foo = stage * 1000 + i;
110
111 assert_se(hashmap_remove(m, INT_TO_PTR(foo)) == INT_TO_PTR(foo + 777))do { if ((__builtin_expect(!!(!(hashmap_remove(m, ((void *) (
(intptr_t) (foo)))) == ((void *) ((intptr_t) (foo + 777))))),
0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hashmap_remove(m, INT_TO_PTR(foo)) == INT_TO_PTR(foo + 777)"
), "../src/test/test-hashmap.c", 111, __PRETTY_FUNCTION__); }
while (0)
;
112 }
113
114 compare_cache(m, c);
115 }
116 }
117
118 hashmap_clear(m);
119 compare_cache(m, c);
120
121 assert_se(hashmap_free(m) == NULL)do { if ((__builtin_expect(!!(!(hashmap_free(m) == ((void*)0)
)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("hashmap_free(m) == NULL"
), "../src/test/test-hashmap.c", 121, __PRETTY_FUNCTION__); }
while (0)
;
122 assert_se(iterated_cache_free(c) == NULL)do { if ((__builtin_expect(!!(!(iterated_cache_free(c) == ((void
*)0))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("iterated_cache_free(c) == NULL"
), "../src/test/test-hashmap.c", 122, __PRETTY_FUNCTION__); }
while (0)
;
123}
124
125static void test_path_hashmap(void) {
126 _cleanup_hashmap_free___attribute__((cleanup(hashmap_freep))) Hashmap *h = NULL((void*)0);
127
128 assert_se(h = hashmap_new(&path_hash_ops))do { if ((__builtin_expect(!!(!(h = internal_hashmap_new(&
path_hash_ops ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("h = hashmap_new(&path_hash_ops)"), "../src/test/test-hashmap.c"
, 128, __PRETTY_FUNCTION__); } while (0)
;
129
130 assert_se(hashmap_put(h, "foo", INT_TO_PTR(1)) >= 0)do { if ((__builtin_expect(!!(!(hashmap_put(h, "foo", ((void *
) ((intptr_t) (1)))) >= 0)),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_put(h, \"foo\", INT_TO_PTR(1)) >= 0"), "../src/test/test-hashmap.c"
, 130, __PRETTY_FUNCTION__); } while (0)
;
131 assert_se(hashmap_put(h, "/foo", INT_TO_PTR(2)) >= 0)do { if ((__builtin_expect(!!(!(hashmap_put(h, "/foo", ((void
*) ((intptr_t) (2)))) >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_put(h, \"/foo\", INT_TO_PTR(2)) >= 0"
), "../src/test/test-hashmap.c", 131, __PRETTY_FUNCTION__); }
while (0)
;
132 assert_se(hashmap_put(h, "//foo", INT_TO_PTR(3)) == -EEXIST)do { if ((__builtin_expect(!!(!(hashmap_put(h, "//foo", ((void
*) ((intptr_t) (3)))) == -17)),0))) log_assert_failed_realm(
LOG_REALM_SYSTEMD, ("hashmap_put(h, \"//foo\", INT_TO_PTR(3)) == -EEXIST"
), "../src/test/test-hashmap.c", 132, __PRETTY_FUNCTION__); }
while (0)
;
133 assert_se(hashmap_put(h, "//foox/", INT_TO_PTR(4)) >= 0)do { if ((__builtin_expect(!!(!(hashmap_put(h, "//foox/", ((void
*) ((intptr_t) (4)))) >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_put(h, \"//foox/\", INT_TO_PTR(4)) >= 0"
), "../src/test/test-hashmap.c", 133, __PRETTY_FUNCTION__); }
while (0)
;
134 assert_se(hashmap_put(h, "/foox////", INT_TO_PTR(5)) == -EEXIST)do { if ((__builtin_expect(!!(!(hashmap_put(h, "/foox////", (
(void *) ((intptr_t) (5)))) == -17)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_put(h, \"/foox////\", INT_TO_PTR(5)) == -EEXIST"
), "../src/test/test-hashmap.c", 134, __PRETTY_FUNCTION__); }
while (0)
;
135 assert_se(hashmap_put(h, "foo//////bar/quux//", INT_TO_PTR(6)) >= 0)do { if ((__builtin_expect(!!(!(hashmap_put(h, "foo//////bar/quux//"
, ((void *) ((intptr_t) (6)))) >= 0)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_put(h, \"foo//////bar/quux//\", INT_TO_PTR(6)) >= 0"
), "../src/test/test-hashmap.c", 135, __PRETTY_FUNCTION__); }
while (0)
;
136 assert_se(hashmap_put(h, "foo/bar//quux/", INT_TO_PTR(8)) == -EEXIST)do { if ((__builtin_expect(!!(!(hashmap_put(h, "foo/bar//quux/"
, ((void *) ((intptr_t) (8)))) == -17)),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_put(h, \"foo/bar//quux/\", INT_TO_PTR(8)) == -EEXIST"
), "../src/test/test-hashmap.c", 136, __PRETTY_FUNCTION__); }
while (0)
;
137
138 assert_se(hashmap_get(h, "foo") == INT_TO_PTR(1))do { if ((__builtin_expect(!!(!(hashmap_get(h, "foo") == ((void
*) ((intptr_t) (1))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"foo\") == INT_TO_PTR(1)"), "../src/test/test-hashmap.c"
, 138, __PRETTY_FUNCTION__); } while (0)
;
139 assert_se(hashmap_get(h, "foo/") == INT_TO_PTR(1))do { if ((__builtin_expect(!!(!(hashmap_get(h, "foo/") == ((void
*) ((intptr_t) (1))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"foo/\") == INT_TO_PTR(1)"), "../src/test/test-hashmap.c"
, 139, __PRETTY_FUNCTION__); } while (0)
;
140 assert_se(hashmap_get(h, "foo////") == INT_TO_PTR(1))do { if ((__builtin_expect(!!(!(hashmap_get(h, "foo////") == (
(void *) ((intptr_t) (1))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"foo////\") == INT_TO_PTR(1)"), "../src/test/test-hashmap.c"
, 140, __PRETTY_FUNCTION__); } while (0)
;
141 assert_se(hashmap_get(h, "/foo") == INT_TO_PTR(2))do { if ((__builtin_expect(!!(!(hashmap_get(h, "/foo") == ((void
*) ((intptr_t) (2))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"/foo\") == INT_TO_PTR(2)"), "../src/test/test-hashmap.c"
, 141, __PRETTY_FUNCTION__); } while (0)
;
142 assert_se(hashmap_get(h, "//foo") == INT_TO_PTR(2))do { if ((__builtin_expect(!!(!(hashmap_get(h, "//foo") == ((
void *) ((intptr_t) (2))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"//foo\") == INT_TO_PTR(2)"), "../src/test/test-hashmap.c"
, 142, __PRETTY_FUNCTION__); } while (0)
;
143 assert_se(hashmap_get(h, "/////foo////") == INT_TO_PTR(2))do { if ((__builtin_expect(!!(!(hashmap_get(h, "/////foo////"
) == ((void *) ((intptr_t) (2))))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_get(h, \"/////foo////\") == INT_TO_PTR(2)"
), "../src/test/test-hashmap.c", 143, __PRETTY_FUNCTION__); }
while (0)
;
144 assert_se(hashmap_get(h, "/////foox////") == INT_TO_PTR(4))do { if ((__builtin_expect(!!(!(hashmap_get(h, "/////foox////"
) == ((void *) ((intptr_t) (4))))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_get(h, \"/////foox////\") == INT_TO_PTR(4)"
), "../src/test/test-hashmap.c", 144, __PRETTY_FUNCTION__); }
while (0)
;
145 assert_se(hashmap_get(h, "/foox/") == INT_TO_PTR(4))do { if ((__builtin_expect(!!(!(hashmap_get(h, "/foox/") == (
(void *) ((intptr_t) (4))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"/foox/\") == INT_TO_PTR(4)"), "../src/test/test-hashmap.c"
, 145, __PRETTY_FUNCTION__); } while (0)
;
146 assert_se(hashmap_get(h, "/foox") == INT_TO_PTR(4))do { if ((__builtin_expect(!!(!(hashmap_get(h, "/foox") == ((
void *) ((intptr_t) (4))))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD
, ("hashmap_get(h, \"/foox\") == INT_TO_PTR(4)"), "../src/test/test-hashmap.c"
, 146, __PRETTY_FUNCTION__); } while (0)
;
147 assert_se(!hashmap_get(h, "foox"))do { if ((__builtin_expect(!!(!(!hashmap_get(h, "foox"))),0))
) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!hashmap_get(h, \"foox\")"
), "../src/test/test-hashmap.c", 147, __PRETTY_FUNCTION__); }
while (0)
;
148 assert_se(hashmap_get(h, "foo/bar/quux") == INT_TO_PTR(6))do { if ((__builtin_expect(!!(!(hashmap_get(h, "foo/bar/quux"
) == ((void *) ((intptr_t) (6))))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_get(h, \"foo/bar/quux\") == INT_TO_PTR(6)"
), "../src/test/test-hashmap.c", 148, __PRETTY_FUNCTION__); }
while (0)
;
149 assert_se(hashmap_get(h, "foo////bar////quux/////") == INT_TO_PTR(6))do { if ((__builtin_expect(!!(!(hashmap_get(h, "foo////bar////quux/////"
) == ((void *) ((intptr_t) (6))))),0))) log_assert_failed_realm
(LOG_REALM_SYSTEMD, ("hashmap_get(h, \"foo////bar////quux/////\") == INT_TO_PTR(6)"
), "../src/test/test-hashmap.c", 149, __PRETTY_FUNCTION__); }
while (0)
;
150 assert_se(!hashmap_get(h, "/foo////bar////quux/////"))do { if ((__builtin_expect(!!(!(!hashmap_get(h, "/foo////bar////quux/////"
))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("!hashmap_get(h, \"/foo////bar////quux/////\")"
), "../src/test/test-hashmap.c", 150, __PRETTY_FUNCTION__); }
while (0)
;
151}
152
153int main(int argc, const char *argv[]) {
154 test_hashmap_funcs();
155 test_ordered_hashmap_funcs();
156
157 test_ordered_hashmap_next();
158 test_hashmap_free_with_destructor();
159 test_uint64_compare_func();
160 test_trivial_compare_func();
161 test_string_compare_func();
162 test_iterated_cache();
163 test_path_hashmap();
164
165 return 0;
166}