n.severity = NOTIF_WARNING;
break;
default:
- ERROR(OVS_EVENTS_PLUGIN, ": unknown interface link status");
+ ERROR(OVS_EVENTS_PLUGIN ": unknown interface link status");
return;
}
/* add interface metadata to the notification */
if (plugin_notification_meta_add_string(&n, "uuid", ifinfo->uuid) < 0) {
- ERROR(OVS_EVENTS_PLUGIN, ": add interface uuid meta data failed");
+ ERROR(OVS_EVENTS_PLUGIN ": add interface uuid meta data failed");
return;
}
if (strlen(ifinfo->ext_vm_uuid) > 0)
if (plugin_notification_meta_add_string
(&n, "vm-uuid", ifinfo->ext_vm_uuid) < 0) {
- ERROR(OVS_EVENTS_PLUGIN, ": add interface vm-uuid meta data failed");
+ ERROR(OVS_EVENTS_PLUGIN ": add interface vm-uuid meta data failed");
return;
}
if (strlen(ifinfo->ext_iface_id) > 0)
if (plugin_notification_meta_add_string
(&n, "iface-id", ifinfo->ext_iface_id) < 0) {
- ERROR(OVS_EVENTS_PLUGIN, ": add interface iface-id meta data failed");
+ ERROR(OVS_EVENTS_PLUGIN ": add interface iface-id meta data failed");
return;
}
/* add interface metadata to the submit value */
if ((meta = meta_data_create()) != NULL) {
if (meta_data_add_string(meta, "uuid", ifinfo->uuid) < 0)
- ERROR(OVS_EVENTS_PLUGIN, ": add interface uuid meta data failed");
+ ERROR(OVS_EVENTS_PLUGIN ": add interface uuid meta data failed");
if (strlen(ifinfo->ext_vm_uuid) > 0)
if (meta_data_add_string(meta, "vm-uuid", ifinfo->ext_vm_uuid) < 0)
- ERROR(OVS_EVENTS_PLUGIN, ": add interface vm-uuid meta data failed");
+ ERROR(OVS_EVENTS_PLUGIN ": add interface vm-uuid meta data failed");
if (strlen(ifinfo->ext_iface_id) > 0)
if (meta_data_add_string(meta, "iface-id", ifinfo->ext_iface_id) < 0)
- ERROR(OVS_EVENTS_PLUGIN, ": add interface iface-id meta data failed");
+ ERROR(OVS_EVENTS_PLUGIN ": add interface iface-id meta data failed");
vl.meta = meta;
} else
ERROR(OVS_EVENTS_PLUGIN ": create metadata failed");
{
notification_t n = {NOTIF_FAILURE, cdtime(), "", "", OVS_EVENTS_PLUGIN,
"", "", "", NULL};
- ssnprintf(n.message, sizeof(n.message), msg);
+ sstrncpy(n.message, msg, sizeof(n.message));
sstrncpy(n.host, hostname_g, sizeof(n.host));
plugin_dispatch_notification(&n);
}
yajl_val jexternal_ids = NULL;
yajl_val jvalue = NULL;
yajl_val juuid = NULL;
+ const char *state = NULL;
/* check YAJL type */
if (!YAJL_IS_OBJECT(jobject))
- return NULL;
+ return (-1);
/* try to find external_ids, name and link_state fields */
jexternal_ids = ovs_utils_get_value_by_key(jobject, "external_ids");
/* get OVS DB interface link status */
jvalue = ovs_utils_get_value_by_key(jobject, "link_state");
- if (jvalue != NULL && YAJL_IS_STRING(jvalue)) {
+ if (jvalue != NULL && ((state = YAJL_GET_STRING(jvalue)) != NULL)) {
/* convert OVS table link state to link status */
- if (strcmp(YAJL_GET_STRING(jvalue), "up") == 0)
+ if (strcmp(state, "up") == 0)
ifinfo->link_status = UP;
- else if (strcmp(YAJL_GET_STRING(jvalue), "down") == 0)
+ else if (strcmp(state, "down") == 0)
ifinfo->link_status = DOWN;
}
return (0);
return (0);
failure:
- OVS_ERROR("%s() : invalid OVS DB URL provided");
+ OVS_ERROR("invalid OVS DB URL provided [url=%s]", surl);
sfree(in_str);
return (-1);
}
return (-1);
sstrncpy(sjson, data, len + 1);
- OVS_DEBUG("[len=%d] %s", len, sjson);
+ OVS_DEBUG("[len=%zu] %s", len, sjson);
/* parse json data */
jnode = yajl_tree_parse(sjson, yajl_errbuf, sizeof(yajl_errbuf));
size_t array_len = 0;
yajl_val *map_values = NULL;
yajl_val *array_values = NULL;
+ const char *str_val = NULL;
/* check YAJL array */
if (!YAJL_IS_ARRAY(jval) || (key == NULL))
return NULL;
/* check first element of the array */
- if (strcmp("map", YAJL_GET_STRING(array_values[0])) != 0)
+ str_val = YAJL_GET_STRING(array_values[0]);
+ if (strcmp("map", str_val) != 0)
return NULL;
/* try to find map value by map key */
break;
/* return map value if given key equals map key */
- if (strcmp(key, YAJL_GET_STRING(array_values[0])) == 0)
+ str_val = YAJL_GET_STRING(array_values[0]);
+ if (strcmp(key, str_val) == 0)
return array_values[1];
}
return NULL;