X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fascent.c;h=94a39386b0a45f74cba03ddd237588c3ba8edfb7;hb=31ee0e5282b59f89ac5c9bcaebb993450e45dba1;hp=2ad641dfede55d98b9a3cf92ebd288dd20881ed4;hpb=39ba035b60b509311874ccf89d11d240c0271a90;p=collectd.git diff --git a/src/ascent.c b/src/ascent.c index 2ad641df..94a39386 100644 --- a/src/ascent.c +++ b/src/ascent.c @@ -126,7 +126,6 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */ vl.values = values; vl.values_len = 1; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "ascent", sizeof (vl.plugin)); @@ -144,7 +143,7 @@ static int ascent_submit_gauge (const char *plugin_instance, /* {{{ */ } /* }}} int ascent_submit_gauge */ static size_t ascent_curl_callback (void *buf, size_t size, size_t nmemb, /* {{{ */ - void *stream) + void __attribute__((unused)) *stream) { size_t len = size * nmemb; @@ -175,7 +174,7 @@ static size_t ascent_curl_callback (void *buf, size_t size, size_t nmemb, /* {{{ static int ascent_submit_players (player_stats_t *ps) /* {{{ */ { - int i; + size_t i; gauge_t value; for (i = 0; i < RACES_LIST_LENGTH; i++) @@ -214,7 +213,7 @@ static int ascent_account_player (player_stats_t *ps, /* {{{ */ { if (pi->race >= 0) { - if ((pi->race >= RACES_LIST_LENGTH) + if (((size_t) pi->race >= RACES_LIST_LENGTH) || (races_list[pi->race] == NULL)) ERROR ("ascent plugin: Ignoring invalid numeric race %i.", pi->race); else @@ -223,7 +222,7 @@ static int ascent_account_player (player_stats_t *ps, /* {{{ */ if (pi->class >= 0) { - if ((pi->class >= CLASSES_LIST_LENGTH) + if (((size_t) pi->class >= CLASSES_LIST_LENGTH) || (classes_list[pi->class] == NULL)) ERROR ("ascent plugin: Ignoring invalid numeric class %i.", pi->class); else @@ -232,7 +231,7 @@ static int ascent_account_player (player_stats_t *ps, /* {{{ */ if (pi->gender >= 0) { - if ((pi->gender >= GENDERS_LIST_LENGTH) + if (((size_t) pi->gender >= GENDERS_LIST_LENGTH) || (genders_list[pi->gender] == NULL)) ERROR ("ascent plugin: Ignoring invalid numeric gender %i.", pi->gender); @@ -277,10 +276,12 @@ static int ascent_xml_submit_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */ value = strtod (str_ptr, &end_ptr); if (str_ptr == end_ptr) { + xmlFree(str_ptr); ERROR ("ascent plugin: ascent_xml_submit_gauge: strtod failed."); return (-1); } } + xmlFree(str_ptr); return (ascent_submit_gauge (plugin_instance, type, type_instance, value)); } /* }}} int ascent_xml_submit_gauge */ @@ -306,10 +307,12 @@ static int ascent_xml_read_int (xmlDoc *doc, xmlNode *node, /* {{{ */ value = strtol (str_ptr, &end_ptr, 0); if (str_ptr == end_ptr) { + xmlFree(str_ptr); ERROR ("ascent plugin: ascent_xml_read_int: strtol failed."); return (-1); } } + xmlFree(str_ptr); *ret_value = value; return (0); @@ -536,6 +539,7 @@ static int ascent_init (void) /* {{{ */ return (-1); } + curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1L); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ascent_curl_callback); curl_easy_setopt (curl, CURLOPT_USERAGENT, PACKAGE_NAME"/"PACKAGE_VERSION); curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, ascent_curl_error); @@ -546,7 +550,7 @@ static int ascent_init (void) /* {{{ */ status = ssnprintf (credentials, sizeof (credentials), "%s:%s", user, (pass == NULL) ? "" : pass); - if (status >= sizeof (credentials)) + if ((status < 0) || ((size_t) status >= sizeof (credentials))) { ERROR ("ascent plugin: ascent_init: Returning an error because the " "credentials have been truncated."); @@ -557,16 +561,18 @@ static int ascent_init (void) /* {{{ */ } curl_easy_setopt (curl, CURLOPT_URL, url); + curl_easy_setopt (curl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt (curl, CURLOPT_MAXREDIRS, 50L); - if ((verify_peer == NULL) || (strcmp (verify_peer, "true") == 0)) - curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1); + if ((verify_peer == NULL) || IS_TRUE (verify_peer)) + curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 1L); else - curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0); + curl_easy_setopt (curl, CURLOPT_SSL_VERIFYPEER, 0L); - if ((verify_host == NULL) || (strcmp (verify_host, "true") == 0)) - curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2); + if ((verify_host == NULL) || IS_TRUE (verify_host)) + curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 2L); else - curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0); + curl_easy_setopt (curl, CURLOPT_SSL_VERIFYHOST, 0L); if (cacert != NULL) curl_easy_setopt (curl, CURLOPT_CAINFO, cacert); @@ -591,7 +597,7 @@ static int ascent_read (void) /* {{{ */ } ascent_buffer_fill = 0; - if (curl_easy_perform (curl) != 0) + if (curl_easy_perform (curl) != CURLE_OK) { ERROR ("ascent plugin: curl_easy_perform failed: %s", ascent_curl_error);