X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_tsdb.c;h=c562596b6d753525aafa663ee532d71bcec5d873;hb=5c2993e4121feae745551be182221b31bc23ff97;hp=27ea4738051c9d6f6192b5cb76149816a5831c8a;hpb=9b7dee8838f56233cea2854a7ddbcad2790609ce;p=collectd.git diff --git a/src/write_tsdb.c b/src/write_tsdb.c index 27ea4738..c562596b 100644 --- a/src/write_tsdb.c +++ b/src/write_tsdb.c @@ -49,7 +49,6 @@ #include "utils_cache.h" #include -#include #include #ifndef WT_DEFAULT_NODE @@ -212,7 +211,6 @@ static int wt_callback_init(struct wt_callback *cb) ERROR("write_tsdb plugin: Connecting to %s:%s failed. " "The last error was: %s", node, service, sstrerror (errno, errbuf, sizeof(errbuf))); - close(cb->sock_fd); return -1; } @@ -348,7 +346,7 @@ static int wt_format_name(char *ret, int ret_len, { int status; char *temp = NULL; - char *prefix = ""; + const char *prefix = ""; const char *meta_prefix = "tsdb_prefix"; if (vl->meta) { @@ -411,11 +409,11 @@ static int wt_send_message (const char* key, const char* value, const char* host, meta_data_t *md) { int status; - int message_len; + size_t message_len; char *temp = NULL; - char *tags = ""; + const char *tags = ""; char message[1024]; - char *host_tags = cb->host_tags ? cb->host_tags : ""; + const char *host_tags = cb->host_tags ? cb->host_tags : ""; const char *meta_tsdb = "tsdb_tags"; /* skip if value is NaN */ @@ -436,7 +434,7 @@ static int wt_send_message (const char* key, const char* value, } } - message_len = ssnprintf (message, + status = ssnprintf (message, sizeof(message), "put %s %.0f %s fqdn=%s %s %s\r\n", key, @@ -445,12 +443,14 @@ static int wt_send_message (const char* key, const char* value, host, tags, host_tags); - sfree(temp); + if (status < 0) + return -1; + message_len = (size_t) status; if (message_len >= sizeof(message)) { ERROR("write_tsdb plugin: message buffer too small: " - "Need %d bytes.", message_len + 1); + "Need %zu bytes.", message_len + 1); return -1; } @@ -506,7 +506,8 @@ static int wt_write_messages(const data_set_t *ds, const value_list_t *vl, char key[10*DATA_MAX_NAME_LEN]; char values[512]; - int status, i; + int status; + size_t i; if (0 != strcmp(ds->type, vl->type)) {