Run clang-format after removing ssnprintf
[collectd.git] / src / mcelog.c
index 4e6a6fd..b8731c7 100644 (file)
@@ -106,22 +106,22 @@ static int mcelog_config(oconfig_item_t *ci) {
           0) {
         ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
               child->key);
-        return (-1);
+        return -1;
       }
     } else if (strcasecmp("McelogLogfile", child->key) == 0) {
       if (cf_util_get_string_buffer(child, g_mcelog_config.logfile,
                                     sizeof(g_mcelog_config.logfile)) < 0) {
         ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
               child->key);
-        return (-1);
+        return -1;
       }
     } else {
       ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
             child->key);
-      return (-1);
+      return -1;
     }
   }
-  return (0);
+  return 0;
 }
 
 static int socket_close(socket_adapter_t *self) {
@@ -141,7 +141,7 @@ static int socket_close(socket_adapter_t *self) {
     }
   }
   pthread_rwlock_unlock(&self->lock);
-  return (ret);
+  return ret;
 }
 
 static int socket_write(socket_adapter_t *self, const char *msg,
@@ -151,7 +151,7 @@ static int socket_write(socket_adapter_t *self, const char *msg,
   if (swrite(self->sock_fd, msg, len) < 0)
     ret = -1;
   pthread_rwlock_unlock(&self->lock);
-  return (ret);
+  return ret;
 }
 
 static void mcelog_dispatch_notification(notification_t *n) {
@@ -181,7 +181,7 @@ static int socket_reinit(socket_adapter_t *self) {
     ERROR(MCELOG_PLUGIN ": Could not create a socket. %s",
           sstrerror(errno, errbuff, sizeof(errbuff)));
     pthread_rwlock_unlock(&self->lock);
-    return (ret);
+    return ret;
   }
 
   /* Set socket timeout option */
@@ -209,38 +209,38 @@ static int socket_reinit(socket_adapter_t *self) {
                           .type_instance = "mcelog_status"});
   }
   pthread_rwlock_unlock(&self->lock);
-  return (ret);
+  return ret;
 }
 
 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') &&
       (plugin_notification_meta_add_string(n, MCELOG_SOCKET_STR, mr->location) <
        0)) {
     ERROR(MCELOG_PLUGIN ": add memory location meta data failed");
-    return (-1);
+    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);
+    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",
@@ -248,20 +248,20 @@ static int mcelog_prepare_notification(notification_t *n,
        0)) {
     ERROR(MCELOG_PLUGIN ": add corrected errors period meta data failed");
     plugin_notification_meta_free(n->meta);
-    return (-1);
+    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",
@@ -269,17 +269,17 @@ static int mcelog_prepare_notification(notification_t *n,
        0)) {
     ERROR(MCELOG_PLUGIN ": add corrected errors period meta data failed");
     plugin_notification_meta_free(n->meta);
-    return (-1);
+    return -1;
   }
 
-  return (0);
+  return 0;
 }
 
 static int mcelog_submit(const mcelog_memory_rec_t *mr) {
 
   if (!mr) {
     ERROR(MCELOG_PLUGIN ": %s: NULL pointer", __FUNCTION__);
-    return (-1);
+    return -1;
   }
 
   value_list_t vl = {
@@ -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,13 +308,12 @@ 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);
 
-  return (0);
+  return 0;
 }
 
 static int parse_memory_info(FILE *p_file, mcelog_memory_rec_t *memory_record) {
@@ -323,7 +322,7 @@ static int parse_memory_info(FILE *p_file, mcelog_memory_rec_t *memory_record) {
     /* Got empty line or "done" */
     if ((!strncmp("\n", buf, strlen(buf))) ||
         (!strncmp(buf, "done\n", strlen(buf))))
-      return (1);
+      return 1;
     if (strlen(buf) < 5)
       continue;
     if (!strncmp(buf, MCELOG_SOCKET_STR, strlen(MCELOG_SOCKET_STR))) {
@@ -379,7 +378,7 @@ static int parse_memory_info(FILE *p_file, mcelog_memory_rec_t *memory_record) {
     memset(buf, 0, sizeof(buf));
   }
   /* parsing definitely finished */
-  return (0);
+  return 0;
 }
 
 static void poll_worker_cleanup(void *arg) {
@@ -404,7 +403,7 @@ static int socket_receive(socket_adapter_t *self, FILE **pp_file) {
             sstrerror(errno, errbuf, sizeof(errbuf)));
     }
     pthread_rwlock_unlock(&self->lock);
-    return (res);
+    return res;
   }
 
   if (poll_fd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
@@ -419,20 +418,20 @@ static int socket_receive(socket_adapter_t *self, FILE **pp_file) {
                             .type_instance = "mcelog_status"});
     }
     pthread_rwlock_unlock(&self->lock);
-    return (-1);
+    return -1;
   }
 
   if (!(poll_fd.revents & (POLLIN | POLLPRI))) {
     INFO(MCELOG_PLUGIN ": No data to read");
     pthread_rwlock_unlock(&self->lock);
-    return (0);
+    return 0;
   }
 
   if ((*pp_file = fdopen(dup(self->sock_fd), "r")) == NULL)
     res = -1;
 
   pthread_rwlock_unlock(&self->lock);
-  return (res);
+  return res;
 }
 
 static void *poll_worker(__attribute__((unused)) void *arg) {
@@ -492,21 +491,21 @@ static void *poll_worker(__attribute__((unused)) void *arg) {
 
   mcelog_thread_running = 0;
   pthread_cleanup_pop(1);
-  return (NULL);
+  return NULL;
 }
 
 static int mcelog_init(void) {
   if (socket_adapter.reinit(&socket_adapter) != 0) {
     ERROR(MCELOG_PLUGIN ": Cannot connect to client socket");
-    return (-1);
+    return -1;
   }
 
   if (plugin_thread_create(&g_mcelog_config.tid, NULL, poll_worker, NULL,
                            NULL) != 0) {
     ERROR(MCELOG_PLUGIN ": Error creating poll thread.");
-    return (-1);
+    return -1;
   }
-  return (0);
+  return 0;
 }
 
 static int get_memory_machine_checks(void) {
@@ -516,7 +515,7 @@ static int get_memory_machine_checks(void) {
     ERROR(MCELOG_PLUGIN ": SENT DUMP REQUEST FAILED");
   else
     DEBUG(MCELOG_PLUGIN ": SENT DUMP REQUEST OK");
-  return (ret);
+  return ret;
 }
 
 static int mcelog_read(__attribute__((unused)) user_data_t *ud) {
@@ -525,7 +524,7 @@ static int mcelog_read(__attribute__((unused)) user_data_t *ud) {
   if (get_memory_machine_checks() != 0)
     ERROR(MCELOG_PLUGIN ": MACHINE CHECK INFO NOT AVAILABLE");
 
-  return (0);
+  return 0;
 }
 
 static int mcelog_shutdown(void) {
@@ -540,7 +539,7 @@ static int mcelog_shutdown(void) {
 
   ret = socket_adapter.close(&socket_adapter) || ret;
   pthread_rwlock_destroy(&(socket_adapter.lock));
-  return (-ret);
+  return -ret;
 }
 
 void module_register(void) {