From 355df251d423992fd52b602535d1ae92daffc9c0 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 17 Nov 2017 15:29:07 +0100 Subject: [PATCH] src/utils_ovs.c: Random coding style improvements. --- src/utils_ovs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/utils_ovs.c b/src/utils_ovs.c index e9e841e8..ae82253b 100644 --- a/src/utils_ovs.c +++ b/src/utils_ovs.c @@ -263,12 +263,11 @@ static void ovs_db_callback_remove(ovs_db_t *pdb, ovs_callback_t *del_cb) { /* Remove all callbacks form OVS DB object */ static void ovs_db_callback_remove_all(ovs_db_t *pdb) { pthread_mutex_lock(&pdb->mutex); - for (ovs_callback_t *del_cb = pdb->remote_cb; pdb->remote_cb; - del_cb = pdb->remote_cb) { + while (pdb->remote_cb != NULL) { + ovs_callback_t *del_cb = pdb->remote_cb; pdb->remote_cb = del_cb->next; - free(del_cb); + sfree(del_cb); } - pdb->remote_cb = NULL; pthread_mutex_unlock(&pdb->mutex); } @@ -935,6 +934,7 @@ static int ovs_db_event_thread_init(ovs_db_t *pdb) { } /* Destroy EVENT thread */ +/* XXX: Must hold pdb->mutex when calling! */ static int ovs_db_event_thread_destroy(ovs_db_t *pdb) { if (pthread_equal(pdb->event_thread.tid, (pthread_t){0})) { /* already destroyed */ @@ -974,6 +974,7 @@ static int ovs_db_poll_thread_init(ovs_db_t *pdb) { } /* Destroy POLL thread */ +/* XXX: Must hold pdb->mutex when calling! */ static int ovs_db_poll_thread_destroy(ovs_db_t *pdb) { if (pthread_equal(pdb->poll_thread.tid, (pthread_t){0})) { /* already destroyed */ @@ -1261,13 +1262,13 @@ int ovs_db_destroy(ovs_db_t *pdb) { /* stop poll thread */ if (ovs_db_event_thread_destroy(pdb) < 0) { OVS_ERROR("destroy poll thread failed"); - ovs_db_ret = (-1); + ovs_db_ret = -1; } /* stop event thread */ if (ovs_db_poll_thread_destroy(pdb) < 0) { OVS_ERROR("stop event thread failed"); - ovs_db_ret = (-1); + ovs_db_ret = -1; } pthread_mutex_unlock(&pdb->mutex); -- 2.11.0