From 47cb204f324be21ae54084fbe9e338d854b87bf5 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 17 Nov 2017 15:38:59 +0100 Subject: [PATCH] ovs_stats plugin: Minor code cleanup. --- src/ovs_stats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ovs_stats.c b/src/ovs_stats.c index 8309223b..e7859da2 100644 --- a/src/ovs_stats.c +++ b/src/ovs_stats.c @@ -330,10 +330,10 @@ static int ovs_stats_update_bridge(yajl_val bridge) { br = ovs_stats_get_bridge(g_bridge_list_head, YAJL_GET_STRING(br_name)); pthread_mutex_lock(&g_stats_lock); if (br == NULL) { - br = (bridge_list_t *)calloc(1, sizeof(bridge_list_t)); + br = calloc(1, sizeof(*br)); if (!br) { pthread_mutex_unlock(&g_stats_lock); - ERROR("%s: Error allocating memory for bridge", plugin_name); + ERROR("%s: calloc(%zu) failed.", plugin_name, sizeof(*br)); return -1; } char *tmp = YAJL_GET_STRING(br_name); @@ -343,6 +343,7 @@ static int ovs_stats_update_bridge(yajl_val bridge) { if (br->name == NULL) { sfree(br); pthread_mutex_unlock(&g_stats_lock); + ERROR("%s: strdup failed.", plugin_name); return -1; } br->next = g_bridge_list_head; -- 2.30.2