Merge pull request #3329 from efuss/fix-3311
[collectd.git] / src / xencpu.c
index 01904b2..e63a766 100644 (file)
@@ -21,8 +21,8 @@
 
 #include "collectd.h"
 
-#include "common.h"
 #include "plugin.h"
+#include "utils/common/common.h"
 
 #include <xenctrl.h>
 
@@ -51,23 +51,23 @@ static int xencpu_init(void) {
   xc_handle = xc_interface_open(XC_INTERFACE_INIT_ARGS);
   if (!xc_handle) {
     ERROR("xencpu: xc_interface_open() failed");
-    return (-1);
+    return -1;
   }
 
   xc_physinfo_t *physinfo;
 
-  physinfo = calloc(1, sizeof(xc_physinfo_t));
+  physinfo = calloc(1, sizeof(*physinfo));
   if (physinfo == NULL) {
     ERROR("xencpu plugin: calloc() for physinfo failed.");
     xc_interface_close(xc_handle);
-    return (ENOMEM);
+    return ENOMEM;
   }
 
   if (xc_physinfo(xc_handle, physinfo) < 0) {
     ERROR("xencpu plugin: xc_physinfo() failed");
     xc_interface_close(xc_handle);
     free(physinfo);
-    return (-1);
+    return -1;
   }
 
   num_cpus = physinfo->nr_cpus;
@@ -75,22 +75,22 @@ static int xencpu_init(void) {
 
   INFO("xencpu plugin: Found %" PRIu32 " processors.", num_cpus);
 
-  cpu_info = calloc(num_cpus, sizeof(xc_cpuinfo_t));
+  cpu_info = calloc(num_cpus, sizeof(*cpu_info));
   if (cpu_info == NULL) {
     ERROR("xencpu plugin: calloc() for num_cpus failed.");
     xc_interface_close(xc_handle);
-    return (ENOMEM);
+    return ENOMEM;
   }
 
-  cpu_states = calloc(num_cpus, sizeof(value_to_rate_state_t));
+  cpu_states = calloc(num_cpus, sizeof(*cpu_states));
   if (cpu_states == NULL) {
     ERROR("xencpu plugin: calloc() for cpu_states failed.");
     xc_interface_close(xc_handle);
     free(cpu_info);
-    return (ENOMEM);
+    return ENOMEM;
   }
 
-  return (0);
+  return 0;
 } /* static int xencpu_init */
 
 static int xencpu_shutdown(void) {
@@ -112,7 +112,7 @@ static void submit_value(int cpu_num, gauge_t value) {
   sstrncpy(vl.type_instance, "load", sizeof(vl.type_instance));
 
   if (cpu_num >= 0) {
-    ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", cpu_num);
+    snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%i", cpu_num);
   }
   plugin_dispatch_values(&vl);
 } /* static void submit_value */
@@ -126,7 +126,7 @@ static int xencpu_read(void) {
   if (rc < 0) {
     ERROR("xencpu: xc_getcpuinfo() Failed: %d %s\n", rc,
           xc_strerror(xc_handle, errno));
-    return (-1);
+    return -1;
   }
 
   int status;
@@ -140,7 +140,7 @@ static int xencpu_read(void) {
     }
   }
 
-  return (0);
+  return 0;
 } /* static int xencpu_read */
 
 void module_register(void) {