* Taras Chornyi <tarasx.chornyi@intel.com>
*/
-#include "common.h"
+#include "utils/common/common.h"
-#include "utils_ovs.h" /* OvS helpers */
+#include "utils/ovs/ovs.h" /* OvS helpers */
/* Plugin name */
static const char plugin_name[] = "ovs_stats";
if (strlen(iface->ex_iface_id))
meta_data_add_string(meta, "iface-id", iface->ex_iface_id);
}
- snprintf(devname, sizeof(devname), "%s.%s.%s", bridge->name, port->name,
- iface->name);
+ strjoin(devname, sizeof(devname),
+ (char *[]){
+ bridge->name, port->name, iface->name,
+ },
+ 3, ".");
ovs_stats_submit_one(devname, "if_collisions", NULL,
iface->stats[collisions], meta);
ovs_stats_submit_two(devname, "if_dropped", NULL, iface->stats[rx_dropped],
interface_list_t *iface = ovs_stats_get_port_interface(port, uuid);
if (iface == NULL) {
- iface = (interface_list_t *)calloc(1, sizeof(interface_list_t));
- if (!iface) {
+ iface = calloc(1, sizeof(*iface));
+ if (iface == NULL) {
ERROR("%s: Error allocating interface", plugin_name);
return NULL;
}
port_list_t *port = ovs_stats_get_port(uuid);
if (port == NULL) {
- port = (port_list_t *)calloc(1, sizeof(port_list_t));
- if (!port) {
+ port = calloc(1, sizeof(*port));
+ if (port == NULL) {
ERROR("%s: Error allocating port", plugin_name);
return NULL;
}
ovs_stats_get_bridge(g_bridge_list_head, YAJL_GET_STRING(br_name));
if (br == NULL) {
br = calloc(1, sizeof(*br));
- if (!br) {
+ if (br == NULL) {
ERROR("%s: calloc(%zu) failed.", plugin_name, sizeof(*br));
return -1;
}
char const *br_name = child->values[j].value.string;
if ((bridge = ovs_stats_get_bridge(g_monitored_bridge_list_head,
br_name)) == NULL) {
- if ((bridge = calloc(1, sizeof(bridge_list_t))) == NULL) {
+ if ((bridge = calloc(1, sizeof(*bridge))) == NULL) {
ERROR("%s: Error allocating memory for bridge", plugin_name);
goto cleanup_fail;
} else {