Run clang-format after removing ssnprintf
[collectd.git] / src / mcelog.c
index ec1a606..b8731c7 100644 (file)
@@ -121,7 +121,7 @@ static int mcelog_config(oconfig_item_t *ci) {
       return -1;
     }
   }
-  return (0);
+  return 0;
 }
 
 static int socket_close(socket_adapter_t *self) {
@@ -215,64 +215,64 @@ static int socket_reinit(socket_adapter_t *self) {
 static int mcelog_prepare_notification(notification_t *n,
                                        const mcelog_memory_rec_t *mr) {
   if (n == NULL || mr == NULL)
-    return (-1);
+    return -1;
 
-  if (mr->location[0] != '\0')
-    if (plugin_notification_meta_add_string(n, MCELOG_SOCKET_STR,
-                                            mr->location) < 0) {
-      ERROR(MCELOG_PLUGIN ": add memory location meta data failed");
-      return (-1);
-    }
-  if (mr->dimm_name[0] != '\0')
-    if (plugin_notification_meta_add_string(n, MCELOG_DIMM_NAME,
-                                            mr->dimm_name) < 0) {
-      ERROR(MCELOG_PLUGIN ": add DIMM name meta data failed");
-      plugin_notification_meta_free(n->meta);
-      return (-1);
-    }
+  if ((mr->location[0] != '\0') &&
+      (plugin_notification_meta_add_string(n, MCELOG_SOCKET_STR, mr->location) <
+       0)) {
+    ERROR(MCELOG_PLUGIN ": add memory location meta data failed");
+    return -1;
+  }
+  if ((mr->dimm_name[0] != '\0') &&
+      (plugin_notification_meta_add_string(n, MCELOG_DIMM_NAME, mr->dimm_name) <
+       0)) {
+    ERROR(MCELOG_PLUGIN ": add DIMM name meta data failed");
+    plugin_notification_meta_free(n->meta);
+    return -1;
+  }
   if (plugin_notification_meta_add_signed_int(n, MCELOG_CORRECTED_ERR,
                                               mr->corrected_err_total) < 0) {
     ERROR(MCELOG_PLUGIN ": add corrected errors meta data failed");
     plugin_notification_meta_free(n->meta);
-    return (-1);
+    return -1;
   }
   if (plugin_notification_meta_add_signed_int(
           n, "corrected memory timed errors", mr->corrected_err_timed) < 0) {
     ERROR(MCELOG_PLUGIN ": add corrected timed errors meta data failed");
     plugin_notification_meta_free(n->meta);
-    return (-1);
+    return -1;
+  }
+  if ((mr->corrected_err_timed_period[0] != '\0') &&
+      (plugin_notification_meta_add_string(n, "corrected errors time period",
+                                           mr->corrected_err_timed_period) <
+       0)) {
+    ERROR(MCELOG_PLUGIN ": add corrected errors period meta data failed");
+    plugin_notification_meta_free(n->meta);
+    return -1;
   }
-  if (mr->corrected_err_timed_period[0] != '\0')
-    if (plugin_notification_meta_add_string(n, "corrected errors time period",
-                                            mr->corrected_err_timed_period) <
-        0) {
-      ERROR(MCELOG_PLUGIN ": add corrected errors period meta data failed");
-      plugin_notification_meta_free(n->meta);
-      return (-1);
-    }
   if (plugin_notification_meta_add_signed_int(n, MCELOG_UNCORRECTED_ERR,
                                               mr->uncorrected_err_total) < 0) {
     ERROR(MCELOG_PLUGIN ": add corrected errors meta data failed");
     plugin_notification_meta_free(n->meta);
-    return (-1);
+    return -1;
   }
   if (plugin_notification_meta_add_signed_int(n,
                                               "uncorrected memory timed errors",
                                               mr->uncorrected_err_timed) < 0) {
     ERROR(MCELOG_PLUGIN ": add corrected timed errors meta data failed");
     plugin_notification_meta_free(n->meta);
-    return (-1);
+    return -1;
+  }
+  if ((mr->uncorrected_err_timed_period[0] != '\0') &&
+      (plugin_notification_meta_add_string(n, "uncorrected errors time period",
+                                           mr->uncorrected_err_timed_period) <
+       0)) {
+    ERROR(MCELOG_PLUGIN ": add corrected errors period meta data failed");
+    plugin_notification_meta_free(n->meta);
+    return -1;
   }
-  if (mr->uncorrected_err_timed_period[0] != '\0')
-    if (plugin_notification_meta_add_string(n, "uncorrected errors time period",
-                                            mr->uncorrected_err_timed_period) <
-        0) {
-      ERROR(MCELOG_PLUGIN ": add corrected errors period meta data failed");
-      plugin_notification_meta_free(n->meta);
-      return (-1);
-    }
 
-  return (0);
+  return 0;
 }
 
 static int mcelog_submit(const mcelog_memory_rec_t *mr) {
@@ -291,15 +291,15 @@ static int mcelog_submit(const mcelog_memory_rec_t *mr) {
       .type_instance = "corrected_memory_errors"};
 
   if (mr->dimm_name[0] != '\0')
-    ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s_%s",
-              mr->location, mr->dimm_name);
+    snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s_%s",
+             mr->location, mr->dimm_name);
   else
     sstrncpy(vl.plugin_instance, mr->location, sizeof(vl.plugin_instance));
 
   plugin_dispatch_values(&vl);
 
-  ssnprintf(vl.type_instance, sizeof(vl.type_instance),
-            "corrected_memory_errors_in_%s", mr->corrected_err_timed_period);
+  snprintf(vl.type_instance, sizeof(vl.type_instance),
+           "corrected_memory_errors_in_%s", mr->corrected_err_timed_period);
   vl.values = &(value_t){.derive = (derive_t)mr->corrected_err_timed};
   plugin_dispatch_values(&vl);
 
@@ -308,9 +308,8 @@ static int mcelog_submit(const mcelog_memory_rec_t *mr) {
   vl.values = &(value_t){.derive = (derive_t)mr->uncorrected_err_total};
   plugin_dispatch_values(&vl);
 
-  ssnprintf(vl.type_instance, sizeof(vl.type_instance),
-            "uncorrected_memory_errors_in_%s",
-            mr->uncorrected_err_timed_period);
+  snprintf(vl.type_instance, sizeof(vl.type_instance),
+           "uncorrected_memory_errors_in_%s", mr->uncorrected_err_timed_period);
   vl.values = &(value_t){.derive = (derive_t)mr->uncorrected_err_timed};
   plugin_dispatch_values(&vl);