X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftokyotyrant.c;h=aca0a4e36e506fa878791805dbf4415c11e18ab8;hb=7f07c55bac640c7a50d516248a3152235a14af59;hp=dd1fb3a050825187b17dec0291e77454399cc311;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f;p=collectd.git diff --git a/src/tokyotyrant.c b/src/tokyotyrant.c index dd1fb3a0..aca0a4e3 100644 --- a/src/tokyotyrant.c +++ b/src/tokyotyrant.c @@ -33,10 +33,10 @@ static const char *config_keys[] = {"Host", "Port"}; static int config_keys_num = STATIC_ARRAY_SIZE(config_keys); -static char *config_host = NULL; -static char *config_port = NULL; +static char *config_host; +static char *config_port; -static TCRDB *rdb = NULL; +static TCRDB *rdb; static int tt_config(const char *key, const char *value) { if (strcasecmp("Host", key) == 0) { @@ -45,7 +45,7 @@ static int tt_config(const char *key, const char *value) { temp = strdup(value); if (temp == NULL) { ERROR("tokyotyrant plugin: Host strdup failed."); - return (1); + return 1; } sfree(config_host); config_host = temp; @@ -55,16 +55,16 @@ static int tt_config(const char *key, const char *value) { temp = strdup(value); if (temp == NULL) { ERROR("tokyotyrant plugin: Port strdup failed."); - return (1); + return 1; } sfree(config_port); config_port = temp; } else { ERROR("tokyotyrant plugin: error: unrecognized configuration key %s", key); - return (-1); + return -1; } - return (0); + return 0; } static void printerr(void) { @@ -72,14 +72,11 @@ static void printerr(void) { ERROR("tokyotyrant plugin: error: %d, %s", ecode, tcrdberrmsg(ecode)); } -static void tt_submit(gauge_t val, const char *type) { - value_t values[1]; +static void tt_submit(gauge_t value, const char *type) { value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = val; - - vl.values = values; - vl.values_len = STATIC_ARRAY_SIZE(values); + vl.values = &(value_t){.gauge = value}; + vl.values_len = 1; sstrncpy(vl.host, config_host, sizeof(vl.host)); sstrncpy(vl.plugin, "tokyotyrant", sizeof(vl.plugin)); @@ -119,7 +116,7 @@ static int tt_read(void) { tt_open_db(); if (rdb == NULL) - return (-1); + return -1; rnum = tcrdbrnum(rdb); tt_submit(rnum, "records"); @@ -127,7 +124,7 @@ static int tt_read(void) { size = tcrdbsize(rdb); tt_submit(size, "file_size"); - return (0); + return 0; } static int tt_shutdown(void) { @@ -138,13 +135,13 @@ static int tt_shutdown(void) { if (!tcrdbclose(rdb)) { printerr(); tcrdbdel(rdb); - return (1); + return 1; } tcrdbdel(rdb); rdb = NULL; } - return (0); + return 0; } void module_register(void) { @@ -153,5 +150,3 @@ void module_register(void) { plugin_register_read("tokyotyrant", tt_read); plugin_register_shutdown("tokyotyrant", tt_shutdown); } - -/* vim: set sw=8 ts=8 tw=78 : */