From be37ebb806b34be728edb857335b048c39dc1253 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Thu, 14 Mar 2024 14:22:48 +0000 Subject: [PATCH] Coverity: Fix 1584357, 1584358 and 1584359 --- tests/test_sendqueue.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/test_sendqueue.c b/tests/test_sendqueue.c index 0f390685..c4169c2c 100644 --- a/tests/test_sendqueue.c +++ b/tests/test_sendqueue.c @@ -254,6 +254,8 @@ t_sendqueue9(void) { CU_ASSERT_PTR_NULL(ctx->sendqueue->next); } +static int t_sendqueue_tests_remove(void); + static void t_sendqueue10(void) { coap_queue_t *tmp_node; @@ -304,18 +306,7 @@ t_sendqueue_tests_create(void) { } if (error) { - /* destroy all test nodes and set entry to zero */ - for (n = 0; n < sizeof(node)/sizeof(coap_queue_t *); n++) { - if (node[n]) { - /* As coap_delete_node() is not in the Public API, need to lock */ - coap_lock_lock(ctx, continue); - coap_delete_node(node[n]); - coap_lock_unlock(ctx); - node[n] = NULL; - } - } - coap_free_context(ctx); - ctx = NULL; + t_sendqueue_tests_remove(); } return error; @@ -324,16 +315,17 @@ t_sendqueue_tests_create(void) { static int t_sendqueue_tests_remove(void) { size_t n; + /* As coap_delete_node() is not in the Public API, need to lock */ + coap_lock_lock(ctx, return 1); for (n = 0; n < sizeof(node)/sizeof(coap_queue_t *); n++) { if (node[n]) { - /* As coap_delete_node() is not in the Public API, need to lock */ - coap_lock_lock(ctx, continue); coap_delete_node(node[n]); - coap_lock_unlock(ctx); node[n] = NULL; } } + coap_lock_unlock(ctx); coap_free_context(ctx); + ctx = NULL; return 0; }