ovs_events: Fix plugin collectd config file
authorMytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
Tue, 27 Sep 2016 13:36:26 +0000 (14:36 +0100)
committerMytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
Mon, 26 Dec 2016 13:26:05 +0000 (13:26 +0000)
- Fix Ubuntu compilation warnings.

Change-Id: I7bb72ec0ca732b00c4169e0174d64407d99a2751
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
src/collectd.conf.in
src/ovs_events.c
src/utils_ovs.c

index 7396286..ae4f602 100644 (file)
 #@BUILD_PLUGIN_OPENLDAP_TRUE@LoadPlugin openldap
 #@BUILD_PLUGIN_OPENVPN_TRUE@LoadPlugin openvpn
 #@BUILD_PLUGIN_ORACLE_TRUE@LoadPlugin oracle
-#@BUILD_PLUGIN_OVS_LINK_TRUE@LoadPlugin ovs_events
+#@BUILD_PLUGIN_OVS_EVENTS_TRUE@LoadPlugin ovs_events
 #@BUILD_PLUGIN_PERL_TRUE@LoadPlugin perl
 #@BUILD_PLUGIN_PINBA_TRUE@LoadPlugin pinba
 #@BUILD_PLUGIN_PING_TRUE@LoadPlugin ping
index f971d11..2eedf99 100644 (file)
@@ -276,27 +276,27 @@ ovs_events_dispatch_notification(const ovs_events_iface_info_t *ifinfo)
     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;
     }
 
@@ -322,15 +322,15 @@ ovs_events_link_status_submit(const ovs_events_iface_info_t *ifinfo)
   /* 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");
@@ -354,7 +354,7 @@ ovs_events_dispatch_terminate_notification(const char *msg)
 {
   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);
 }
@@ -367,10 +367,11 @@ ovs_events_get_iface_info(yajl_val jobject, ovs_events_iface_info_t *ifinfo)
   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");
@@ -407,11 +408,11 @@ ovs_events_get_iface_info(yajl_val jobject, ovs_events_iface_info_t *ifinfo)
 
   /* 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);
index 983f249..636a38d 100644 (file)
@@ -373,7 +373,7 @@ ovs_db_url_parse(const char *surl, ovs_conn_t *conn)
   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);
 }
@@ -636,7 +636,7 @@ ovs_db_json_data_process(ovs_db_t *pdb, const char *data, size_t len)
     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));
@@ -1309,6 +1309,7 @@ ovs_utils_get_map_value(yajl_val jval, const char *key)
   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))
@@ -1322,7 +1323,8 @@ ovs_utils_get_map_value(yajl_val jval, const char *key)
     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 */
@@ -1341,7 +1343,8 @@ ovs_utils_get_map_value(yajl_val jval, const char *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;