X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_redis.c;h=f7215b50dbfaaadf38a2f6ff4c9f60d240b0fade;hb=307c875e5a78a2729fbbe1a588d232e9a129d75a;hp=6c9d40809bcb697a3423af4fe66349d5d1ae762f;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f;p=collectd.git diff --git a/src/write_redis.c b/src/write_redis.c index 6c9d4080..f7215b50 100644 --- a/src/write_redis.c +++ b/src/write_redis.c @@ -69,7 +69,7 @@ static int wr_write(const data_set_t *ds, /* {{{ */ status = FORMAT_VL(ident, sizeof(ident), vl); if (status != 0) - return (status); + return status; ssnprintf(key, sizeof(key), "%s%s", (node->prefix != NULL) ? node->prefix : REDIS_DEFAULT_PREFIX, ident); @@ -79,7 +79,7 @@ static int wr_write(const data_set_t *ds, /* {{{ */ value_ptr = &value[0]; status = format_values(value_ptr, value_size, ds, vl, node->store_rates); if (status != 0) - return (status); + return status; pthread_mutex_lock(&node->lock); @@ -92,14 +92,14 @@ static int wr_write(const data_set_t *ds, /* {{{ */ (node->host != NULL) ? node->host : "localhost", (node->port != 0) ? node->port : 6379); pthread_mutex_unlock(&node->lock); - return (-1); + return -1; } else if (node->conn->err) { ERROR( "write_redis plugin: Connecting to host \"%s\" (port %i) failed: %s", (node->host != NULL) ? node->host : "localhost", (node->port != 0) ? node->port : 6379, node->conn->errstr); pthread_mutex_unlock(&node->lock); - return (-1); + return -1; } rr = redisCommand(node->conn, "SELECT %d", node->database); @@ -140,7 +140,7 @@ static int wr_write(const data_set_t *ds, /* {{{ */ pthread_mutex_unlock(&node->lock); - return (0); + return 0; } /* }}} int wr_write */ static void wr_config_free(void *ptr) /* {{{ */ @@ -167,7 +167,7 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ node = calloc(1, sizeof(*node)); if (node == NULL) - return (ENOMEM); + return ENOMEM; node->host = NULL; node->port = 0; node->timeout.tv_sec = 0; @@ -182,7 +182,7 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name)); if (status != 0) { sfree(node); - return (status); + return status; } for (int i = 0; i < ci->children_num; i++) { @@ -221,15 +221,16 @@ static int wr_config_node(oconfig_item_t *ci) /* {{{ */ ssnprintf(cb_name, sizeof(cb_name), "write_redis/%s", node->name); - user_data_t ud = {.data = node, .free_func = wr_config_free}; - - status = plugin_register_write(cb_name, wr_write, &ud); + status = plugin_register_write( + cb_name, wr_write, &(user_data_t){ + .data = node, .free_func = wr_config_free, + }); } if (status != 0) wr_config_free(node); - return (status); + return status; } /* }}} int wr_config_node */ static int wr_config(oconfig_item_t *ci) /* {{{ */ @@ -245,11 +246,9 @@ static int wr_config(oconfig_item_t *ci) /* {{{ */ child->key); } - return (0); + return 0; } /* }}} int wr_config */ void module_register(void) { plugin_register_complex_config("write_redis", wr_config); } - -/* vim: set sw=2 sts=2 tw=78 et fdm=marker : */