X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fapple_sensors.c;h=17c822ff3c91ca9f44a52188ac2d9ecb5faebd18;hb=c76419c0cf983f1ecd3d36aa236cc4e3f9cff733;hp=19d5a49f31731ead712a4d78409bdd87b492007e;hpb=b4cc5c7399adf79198aea816d44a42df25431d15;p=collectd.git diff --git a/src/apple_sensors.c b/src/apple_sensors.c index 19d5a49f..17c822ff 100644 --- a/src/apple_sensors.c +++ b/src/apple_sensors.c @@ -25,6 +25,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -59,7 +60,7 @@ static mach_port_t io_master_port = MACH_PORT_NULL; static int as_init (void) { kern_return_t status; - + if (io_master_port != MACH_PORT_NULL) { mach_port_deallocate (mach_task_self (), @@ -82,19 +83,11 @@ static int as_init (void) static void as_submit (const char *type, const char *type_instance, double val) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - DEBUG ("type = %s; type_instance = %s; val = %f;", - type, type_instance, val); - - values[0].gauge = val; - - vl.values = values; + vl.values = &(value_t) { .gauge = val }; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "apple_sensors", sizeof (vl.plugin)); - sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); sstrncpy (vl.type, type, sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -113,8 +106,6 @@ static int as_read (void) char inst[128]; int value_int; double value_double; - int i; - if (!io_master_port || (io_master_port == MACH_PORT_NULL)) return (-1); @@ -169,7 +160,7 @@ static int as_read (void) kCFStringEncodingASCII)) continue; inst[sizeof (inst) - 1] = '\0'; - for (i = 0; i < 128; i++) + for (int i = 0; i < 128; i++) { if (inst[i] == '\0') break;