From 0b127312bead2b577b9e713130b667d34423ec94 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Sep 2019 22:30:38 +0200 Subject: test/linked_list: silence nonsense warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../misc/linked_list.h:71:34: warning: the address of ‘e6’ will always evaluate as ‘true’ [-Waddress] No shit, e6 is on the stack. But the macro argument is also allowed to be NULL. Add some dumb nonsense to shut up the useless warning. (It's probably useful in other contexts though, so don't disable it completely.) --- test/linked_list.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/linked_list.c b/test/linked_list.c index 6ad61f36ec..a7b5b6b171 100644 --- a/test/linked_list.c +++ b/test/linked_list.c @@ -14,6 +14,12 @@ struct the_list { struct list_item *head, *tail; }; +// This serves to remove some -Waddress "always true" warnings. +static struct list_item *STUPID_SHIT(struct list_item *item) +{ + return item; +} + static bool do_check_list(struct the_list *lst, int *c, int num_c) { if (!lst->head) @@ -100,13 +106,13 @@ static void test_linked_list(void **state) LL_INSERT_BEFORE(list_node, &lst, (struct list_item *)NULL, &e2); check_list(6, 1, 2); - LL_INSERT_BEFORE(list_node, &lst, &e6, &e3); + LL_INSERT_BEFORE(list_node, &lst, STUPID_SHIT(&e6), &e3); check_list(3, 6, 1, 2); - LL_INSERT_BEFORE(list_node, &lst, &e6, &e5); + LL_INSERT_BEFORE(list_node, &lst, STUPID_SHIT(&e6), &e5); check_list(3, 5, 6, 1, 2); - LL_INSERT_BEFORE(list_node, &lst, &e2, &e4); + LL_INSERT_BEFORE(list_node, &lst, STUPID_SHIT(&e2), &e4); check_list(3, 5, 6, 1, 4, 2); LL_REMOVE(list_node, &lst, &e6); @@ -142,13 +148,13 @@ static void test_linked_list(void **state) LL_INSERT_AFTER(list_node, &lst, (struct list_item *)NULL, &e3); check_list(3, 2, 1); - LL_INSERT_AFTER(list_node, &lst, &e3, &e4); + LL_INSERT_AFTER(list_node, &lst, STUPID_SHIT(&e3), &e4); check_list(3, 4, 2, 1); - LL_INSERT_AFTER(list_node, &lst, &e4, &e5); + LL_INSERT_AFTER(list_node, &lst, STUPID_SHIT(&e4), &e5); check_list(3, 4, 5, 2, 1); - LL_INSERT_AFTER(list_node, &lst, &e1, &e6); + LL_INSERT_AFTER(list_node, &lst, STUPID_SHIT(&e1), &e6); check_list(3, 4, 5, 2, 1, 6); } -- cgit v1.2.3