From efa4fea4298f3c2108557653d4fddf0b274dea2c Mon Sep 17 00:00:00 2001 From: Andrew Bays Date: Mon, 19 Nov 2018 09:31:51 -0500 Subject: [PATCH] Small snprintf optimization --- src/ovs_stats.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/ovs_stats.c b/src/ovs_stats.c index e33cd4d3..dd6d888f 100644 --- a/src/ovs_stats.c +++ b/src/ovs_stats.c @@ -333,19 +333,16 @@ static void ovs_stats_submit_port(bridge_list_t *bridge, port_list_t *port) { for (interface_list_t *iface = port->iface; iface != NULL; iface = iface->next) { - memset(key_str, '\0', DATA_MAX_NAME_LEN); - snprintf(key_str, 6, "uuid%d", i); + snprintf(key_str, sizeof(key_str), "uuid%d", i); meta_data_add_string(meta, key_str, iface->iface_uuid); if (strlen(iface->ex_vm_id)) { - memset(key_str, '\0', DATA_MAX_NAME_LEN); - snprintf(key_str, 9, "vm-uuid%d", i); + snprintf(key_str, sizeof(key_str), "vm-uuid%d", i); meta_data_add_string(meta, key_str, iface->ex_vm_id); } if (strlen(iface->ex_iface_id)) { - memset(key_str, '\0', DATA_MAX_NAME_LEN); - snprintf(key_str, 10, "iface-id%d", i); + snprintf(key_str, sizeof(key_str), "iface-id%d", i); meta_data_add_string(meta, key_str, iface->ex_iface_id); } @@ -1300,7 +1297,7 @@ static int ovs_stats_plugin_read(__attribute__((unused)) user_data_t *ud) { * is called after Interface Table update callback but before * Port table Update callback. Will add this port on next read */ continue; - + ovs_stats_submit_port(bridge, port); if (interface_stats) -- 2.11.0