Merge remote-tracking branch 'origin/collectd-5.8'
[collectd.git] / src / fhcount.c
index 3fbabf0..97f0438 100644 (file)
@@ -49,22 +49,17 @@ static int fhcount_config(const char *key, const char *value) {
     ret = 0;
   }
 
-  return (ret);
+  return ret;
 }
 
 static void fhcount_submit(const char *type, const char *type_instance,
                            gauge_t value) {
-
-  value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;
 
-  values[0].gauge = value;
-
-  vl.values = values;
+  vl.values = &(value_t){.gauge = value};
   vl.values_len = 1;
 
   // Compose the metric
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
   sstrncpy(vl.plugin, "fhcount", sizeof(vl.plugin));
   sstrncpy(vl.type, type, sizeof(vl.type));
   sstrncpy(vl.type_instance, type_instance, sizeof(vl.type_instance));
@@ -80,19 +75,18 @@ static int fhcount_read(void) {
   int prc_used, prc_unused;
   char *fields[3];
   char buffer[buffer_len];
-  char errbuf[1024];
   FILE *fp;
 
   // Open file
   fp = fopen("/proc/sys/fs/file-nr", "r");
   if (fp == NULL) {
-    ERROR("fhcount: fopen: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
-    return (EXIT_FAILURE);
+    ERROR("fhcount: fopen: %s", STRERRNO);
+    return EXIT_FAILURE;
   }
   if (fgets(buffer, buffer_len, fp) == NULL) {
-    ERROR("fhcount: fgets: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
+    ERROR("fhcount: fgets: %s", STRERRNO);
     fclose(fp);
-    return (EXIT_FAILURE);
+    return EXIT_FAILURE;
   }
   fclose(fp);
 
@@ -101,7 +95,7 @@ static int fhcount_read(void) {
 
   if (numfields != 3) {
     ERROR("fhcount: Line doesn't contain 3 fields");
-    return (EXIT_FAILURE);
+    return EXIT_FAILURE;
   }
 
   // Define the values
@@ -122,7 +116,7 @@ static int fhcount_read(void) {
     fhcount_submit("percent", "unused", (gauge_t)prc_unused);
   }
 
-  return (0);
+  return 0;
 }
 
 void module_register(void) {