X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Ftape.c;h=26bd969ac83c1c03b8060df1ed6cb7fa86009d3d;hp=368acc45635027ec525a609826bf7f41653e8fbc;hb=d486225f89ea52d8ed2b4242eba2ad94c409f837;hpb=79963d13c1884d1d92667cc502ad20758b084a12 diff --git a/src/tape.c b/src/tape.c index 368acc45..26bd969a 100644 --- a/src/tape.c +++ b/src/tape.c @@ -29,10 +29,14 @@ #error "No applicable input method." #endif +#if HAVE_KSTAT_H +#include +#endif + #define MAX_NUMTAPE 256 extern kstat_ctl_t *kc; static kstat_t *ksp[MAX_NUMTAPE]; -static int numtape = 0; +static int numtape; static int tape_init(void) { kstat_t *ksp_chain; @@ -40,7 +44,7 @@ static int tape_init(void) { numtape = 0; if (kc == NULL) - return (-1); + return -1; for (numtape = 0, ksp_chain = kc->kc_chain; (numtape < MAX_NUMTAPE) && (ksp_chain != NULL); @@ -52,20 +56,18 @@ static int tape_init(void) { ksp[numtape++] = ksp_chain; } - return (0); + return 0; } /* int tape_init */ static void tape_submit(const char *plugin_instance, const char *type, derive_t read, derive_t write) { - value_t values[2]; value_list_t vl = VALUE_LIST_INIT; - - values[0].derive = read; - values[1].derive = write; + value_t values[] = { + {.derive = read}, {.derive = write}, + }; vl.values = values; - vl.values_len = 2; - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); + vl.values_len = STATIC_ARRAY_SIZE(values); sstrncpy(vl.plugin, "tape", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, plugin_instance, sizeof(vl.plugin_instance)); sstrncpy(vl.type, type, sizeof(vl.type)); @@ -96,10 +98,10 @@ static int tape_read(void) { static kstat_io_t kio; if (kc == NULL) - return (-1); + return -1; if (numtape <= 0) - return (-1); + return -1; for (int i = 0; i < numtape; i++) { if (kstat_read(kc, ksp[i], &kio) == -1) @@ -114,7 +116,7 @@ static int tape_read(void) { } } - return (0); + return 0; } void module_register(void) {