Skip to content

Commit be37ebb

Browse files
committed
Coverity: Fix 1584357, 1584358 and 1584359
1 parent 547379a commit be37ebb

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

tests/test_sendqueue.c

+7-15
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ t_sendqueue9(void) {
254254
CU_ASSERT_PTR_NULL(ctx->sendqueue->next);
255255
}
256256

257+
static int t_sendqueue_tests_remove(void);
258+
257259
static void
258260
t_sendqueue10(void) {
259261
coap_queue_t *tmp_node;
@@ -304,18 +306,7 @@ t_sendqueue_tests_create(void) {
304306
}
305307

306308
if (error) {
307-
/* destroy all test nodes and set entry to zero */
308-
for (n = 0; n < sizeof(node)/sizeof(coap_queue_t *); n++) {
309-
if (node[n]) {
310-
/* As coap_delete_node() is not in the Public API, need to lock */
311-
coap_lock_lock(ctx, continue);
312-
coap_delete_node(node[n]);
313-
coap_lock_unlock(ctx);
314-
node[n] = NULL;
315-
}
316-
}
317-
coap_free_context(ctx);
318-
ctx = NULL;
309+
t_sendqueue_tests_remove();
319310
}
320311

321312
return error;
@@ -324,16 +315,17 @@ t_sendqueue_tests_create(void) {
324315
static int
325316
t_sendqueue_tests_remove(void) {
326317
size_t n;
318+
/* As coap_delete_node() is not in the Public API, need to lock */
319+
coap_lock_lock(ctx, return 1);
327320
for (n = 0; n < sizeof(node)/sizeof(coap_queue_t *); n++) {
328321
if (node[n]) {
329-
/* As coap_delete_node() is not in the Public API, need to lock */
330-
coap_lock_lock(ctx, continue);
331322
coap_delete_node(node[n]);
332-
coap_lock_unlock(ctx);
333323
node[n] = NULL;
334324
}
335325
}
326+
coap_lock_unlock(ctx);
336327
coap_free_context(ctx);
328+
ctx = NULL;
337329
return 0;
338330
}
339331

0 commit comments

Comments
 (0)