X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcurl_json.c;h=510d9b621d0b9a32b235337856f455c82eef2b3e;hb=73de67494a4f5d9a698f2a5ab93f85e19bccb90a;hp=3a5a3ab87d7bd0a8320e88e5de5c4d08947d6222;hpb=dc7e14787cc4273927d5d0cdbd00fd41a0bee928;p=collectd.git diff --git a/src/curl_json.c b/src/curl_json.c index 3a5a3ab8..510d9b62 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -28,7 +28,6 @@ #include "utils_avltree.h" #include "utils_complain.h" -#include #include #include @@ -503,6 +502,7 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ { ERROR ("curl_json plugin: cj_config: " "Invalid key: %s", ci->key); + cj_key_free (key); return (-1); } @@ -552,7 +552,6 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ db->tree = cj_avl_create(); tree = db->tree; - name = key->path; ptr = key->path; if (*ptr == '/') ++ptr; @@ -563,7 +562,7 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ if (*ptr == '/') { c_avl_tree_t *value; - int len; + size_t len; len = ptr-name; if (len == 0) @@ -655,11 +654,9 @@ static int cj_init_curl (cj_t *db) /* {{{ */ if (db->timeout >= 0) curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, (long) db->timeout); else if (db->interval > 0) - curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, - CDTIME_T_TO_MS(db->timeout)); + curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, (long) CDTIME_T_TO_MS(db->timeout)); else - curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, - CDTIME_T_TO_MS(plugin_get_interval())); + curl_easy_setopt (db->curl, CURLOPT_TIMEOUT_MS, (long) CDTIME_T_TO_MS(plugin_get_interval())); #endif return (0); @@ -697,6 +694,7 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ { ERROR ("curl_json plugin: cj_config: " "Invalid key: %s", ci->key); + cj_free (db); return (-1); } if (status != 0) @@ -763,9 +761,6 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ { user_data_t ud; char *cb_name; - struct timespec interval = { 0, 0 }; - - CDTIME_T_TO_TIMESPEC (db->interval, &interval); if (db->instance == NULL) db->instance = strdup("default"); @@ -781,7 +776,7 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ db->instance, db->url ? db->url : db->sock); plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read, - /* interval = */ (db->interval > 0) ? &interval : NULL, + /* interval = */ db->interval, &ud); sfree (cb_name); }