Tree wide: Replace sstrerror() with STRERRNO.
[collectd.git] / src / bind.c
index b7308ad..b77a641 100644 (file)
@@ -440,18 +440,14 @@ static int bind_xml_read_timestamp(const char *xpath_expression, /* {{{ */
 #if HAVE_TIMEGM
   time_t t = timegm(&tm);
   if (t == ((time_t)-1)) {
-    char errbuf[1024];
-    ERROR("bind plugin: timegm() failed: %s",
-          sstrerror(errno, errbuf, sizeof(errbuf)));
+    ERROR("bind plugin: timegm() failed: %s", STRERRNO);
     return -1;
   }
   *ret_value = t;
 #else
   time_t t = mktime(&tm);
   if (t == ((time_t)-1)) {
-    char errbuf[1024];
-    ERROR("bind plugin: mktime() failed: %s",
-          sstrerror(errno, errbuf, sizeof(errbuf)));
+    ERROR("bind plugin: mktime() failed: %s", STRERRNO);
     return -1;
   }
   /* mktime assumes that tm is local time. Luckily, it also sets timezone to
@@ -737,8 +733,8 @@ static int bind_xml_stats_handle_zone(int version, xmlDoc *doc, /* {{{ */
                                          nsstats_translation_table_length,
                                          plugin_instance};
 
-    ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-zone-%s",
-              view->name, zone_name);
+    snprintf(plugin_instance, sizeof(plugin_instance), "%s-zone-%s", view->name,
+             zone_name);
 
     if (version == 3) {
       list_info_ptr_t list_info = {plugin_instance,
@@ -868,8 +864,7 @@ static int bind_xml_stats_handle_view(int version, xmlDoc *doc, /* {{{ */
     list_info_ptr_t list_info = {plugin_instance,
                                  /* type = */ "dns_qtype"};
 
-    ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-qtypes",
-              view->name);
+    snprintf(plugin_instance, sizeof(plugin_instance), "%s-qtypes", view->name);
     if (version == 3) {
       bind_parse_generic_name_attr_value_list(
           /* xpath = */ "counters[@type='resqtype']",
@@ -891,8 +886,8 @@ static int bind_xml_stats_handle_view(int version, xmlDoc *doc, /* {{{ */
                                          resstats_translation_table_length,
                                          plugin_instance};
 
-    ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-resolver_stats",
-              view->name);
+    snprintf(plugin_instance, sizeof(plugin_instance), "%s-resolver_stats",
+             view->name);
     if (version == 3) {
       bind_parse_generic_name_attr_value_list(
           "counters[@type='resstats']",
@@ -914,8 +909,8 @@ static int bind_xml_stats_handle_view(int version, xmlDoc *doc, /* {{{ */
     list_info_ptr_t list_info = {plugin_instance,
                                  /* type = */ "dns_qtype_cached"};
 
-    ssnprintf(plugin_instance, sizeof(plugin_instance), "%s-cache_rr_sets",
-              view->name);
+    snprintf(plugin_instance, sizeof(plugin_instance), "%s-cache_rr_sets",
+             view->name);
 
     bind_parse_generic_name_value(/* xpath = */ "cache/rrset",
                                   /* callback = */ bind_xml_list_callback,
@@ -1598,7 +1593,6 @@ static int bind_init(void) /* {{{ */
   curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, bind_curl_callback);
   curl_easy_setopt(curl, CURLOPT_USERAGENT, COLLECTD_USERAGENT);
   curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, bind_curl_error);
-  curl_easy_setopt(curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
   curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
   curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
 #ifdef HAVE_CURLOPT_TIMEOUT_MS
@@ -1620,6 +1614,9 @@ static int bind_read(void) /* {{{ */
   }
 
   bind_buffer_fill = 0;
+
+  curl_easy_setopt(curl, CURLOPT_URL, (url != NULL) ? url : BIND_DEFAULT_URL);
+
   if (curl_easy_perform(curl) != CURLE_OK) {
     ERROR("bind plugin: curl_easy_perform failed: %s", bind_curl_error);
     return -1;