File: | build-scan/../src/test/test-set.c |
Warning: | line 41, column 9 Value stored to 'm' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
2 | |
3 | #include "set.h" |
4 | |
5 | static void test_set_steal_first(void) { |
6 | _cleanup_set_free___attribute__((cleanup(set_freep))) Set *m = NULL((void*)0); |
7 | int seen[3] = {}; |
8 | char *val; |
9 | |
10 | m = set_new(&string_hash_ops)internal_set_new(&string_hash_ops ); |
11 | assert_se(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/test/test-set.c", 11, __PRETTY_FUNCTION__ ); } while (0); |
12 | |
13 | assert_se(set_put(m, (void*) "1") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "1") == 1) ),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"1\") == 1" ), "../src/test/test-set.c", 13, __PRETTY_FUNCTION__); } while (0); |
14 | assert_se(set_put(m, (void*) "22") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "22") == 1 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"22\") == 1" ), "../src/test/test-set.c", 14, __PRETTY_FUNCTION__); } while (0); |
15 | assert_se(set_put(m, (void*) "333") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "333") == 1 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"333\") == 1" ), "../src/test/test-set.c", 15, __PRETTY_FUNCTION__); } while (0); |
16 | |
17 | while ((val = set_steal_first(m))) |
18 | seen[strlen(val) - 1]++; |
19 | |
20 | assert_se(seen[0] == 1 && seen[1] == 1 && seen[2] == 1)do { if ((__builtin_expect(!!(!(seen[0] == 1 && seen[ 1] == 1 && seen[2] == 1)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("seen[0] == 1 && seen[1] == 1 && seen[2] == 1" ), "../src/test/test-set.c", 20, __PRETTY_FUNCTION__); } while (0); |
21 | |
22 | assert_se(set_isempty(m))do { if ((__builtin_expect(!!(!(set_isempty(m))),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("set_isempty(m)"), "../src/test/test-set.c" , 22, __PRETTY_FUNCTION__); } while (0); |
23 | } |
24 | |
25 | typedef struct Item { |
26 | int seen; |
27 | } Item; |
28 | static void item_seen(Item *item) { |
29 | item->seen++; |
30 | } |
31 | |
32 | static void test_set_free_with_destructor(void) { |
33 | Set *m; |
34 | struct Item items[4] = {}; |
35 | unsigned i; |
36 | |
37 | assert_se(m = set_new(NULL))do { if ((__builtin_expect(!!(!(m = internal_set_new(((void*) 0) ))),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("m = set_new(NULL)" ), "../src/test/test-set.c", 37, __PRETTY_FUNCTION__); } while (0); |
38 | 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++) |
39 | assert_se(set_put(m, items + i) == 1)do { if ((__builtin_expect(!!(!(set_put(m, items + i) == 1)), 0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, items + i) == 1" ), "../src/test/test-set.c", 39, __PRETTY_FUNCTION__); } while (0); |
40 | |
41 | m = set_free_with_destructor(m, item_seen)({ ({ void *_item; while ((_item = set_steal_first(m))) item_seen (_item); }); set_free(m); }); |
Value stored to 'm' is never read | |
42 | 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-set.c" , 42, __PRETTY_FUNCTION__); } while (0); |
43 | 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-set.c" , 43, __PRETTY_FUNCTION__); } while (0); |
44 | 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-set.c" , 44, __PRETTY_FUNCTION__); } while (0); |
45 | 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-set.c" , 45, __PRETTY_FUNCTION__); } while (0); |
46 | } |
47 | |
48 | static void test_set_put(void) { |
49 | _cleanup_set_free___attribute__((cleanup(set_freep))) Set *m = NULL((void*)0); |
50 | |
51 | m = set_new(&string_hash_ops)internal_set_new(&string_hash_ops ); |
52 | assert_se(m)do { if ((__builtin_expect(!!(!(m)),0))) log_assert_failed_realm (LOG_REALM_SYSTEMD, ("m"), "../src/test/test-set.c", 52, __PRETTY_FUNCTION__ ); } while (0); |
53 | |
54 | assert_se(set_put(m, (void*) "1") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "1") == 1) ),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"1\") == 1" ), "../src/test/test-set.c", 54, __PRETTY_FUNCTION__); } while (0); |
55 | assert_se(set_put(m, (void*) "22") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "22") == 1 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"22\") == 1" ), "../src/test/test-set.c", 55, __PRETTY_FUNCTION__); } while (0); |
56 | assert_se(set_put(m, (void*) "333") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "333") == 1 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"333\") == 1" ), "../src/test/test-set.c", 56, __PRETTY_FUNCTION__); } while (0); |
57 | assert_se(set_put(m, (void*) "333") == 0)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "333") == 0 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"333\") == 0" ), "../src/test/test-set.c", 57, __PRETTY_FUNCTION__); } while (0); |
58 | assert_se(set_remove(m, (void*) "333"))do { if ((__builtin_expect(!!(!(set_remove(m, (void*) "333")) ),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_remove(m, (void*) \"333\")" ), "../src/test/test-set.c", 58, __PRETTY_FUNCTION__); } while (0); |
59 | assert_se(set_put(m, (void*) "333") == 1)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "333") == 1 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"333\") == 1" ), "../src/test/test-set.c", 59, __PRETTY_FUNCTION__); } while (0); |
60 | assert_se(set_put(m, (void*) "333") == 0)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "333") == 0 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"333\") == 0" ), "../src/test/test-set.c", 60, __PRETTY_FUNCTION__); } while (0); |
61 | assert_se(set_put(m, (void*) "22") == 0)do { if ((__builtin_expect(!!(!(set_put(m, (void*) "22") == 0 )),0))) log_assert_failed_realm(LOG_REALM_SYSTEMD, ("set_put(m, (void*) \"22\") == 0" ), "../src/test/test-set.c", 61, __PRETTY_FUNCTION__); } while (0); |
62 | } |
63 | |
64 | int main(int argc, const char *argv[]) { |
65 | test_set_steal_first(); |
66 | test_set_free_with_destructor(); |
67 | test_set_put(); |
68 | |
69 | return 0; |
70 | } |