Merge remote-tracking branch 'origin/collectd-5.8'
[collectd.git] / src / statsd.c
index e1b52cb..ccd15eb 100644 (file)
@@ -446,13 +446,11 @@ static void statsd_network_read(int fd) /* {{{ */
 
   status = recv(fd, buffer, sizeof(buffer), /* flags = */ MSG_DONTWAIT);
   if (status < 0) {
-    char errbuf[1024];
 
     if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
       return;
 
-    ERROR("statsd plugin: recv(2) failed: %s",
-          sstrerror(errno, errbuf, sizeof(errbuf)));
+    ERROR("statsd plugin: recv(2) failed: %s", STRERRNO);
     return;
   }
 
@@ -497,9 +495,7 @@ static int statsd_network_init(struct pollfd **ret_fds, /* {{{ */
 
     fd = socket(ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol);
     if (fd < 0) {
-      char errbuf[1024];
-      ERROR("statsd plugin: socket(2) failed: %s",
-            sstrerror(errno, errbuf, sizeof(errbuf)));
+      ERROR("statsd plugin: socket(2) failed: %s", STRERRNO);
       continue;
     }
 
@@ -511,9 +507,7 @@ static int statsd_network_init(struct pollfd **ret_fds, /* {{{ */
 
     status = bind(fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen);
     if (status != 0) {
-      char errbuf[1024];
-      ERROR("statsd plugin: bind(2) failed: %s",
-            sstrerror(errno, errbuf, sizeof(errbuf)));
+      ERROR("statsd plugin: bind(2) failed: %s", STRERRNO);
       close(fd);
       continue;
     }
@@ -561,13 +555,11 @@ static void *statsd_network_thread(void *args) /* {{{ */
   while (!network_thread_shutdown) {
     status = poll(fds, (nfds_t)fds_num, /* timeout = */ -1);
     if (status < 0) {
-      char errbuf[1024];
 
       if ((errno == EINTR) || (errno == EAGAIN))
         continue;
 
-      ERROR("statsd plugin: poll(2) failed: %s",
-            sstrerror(errno, errbuf, sizeof(errbuf)));
+      ERROR("statsd plugin: poll(2) failed: %s", STRERRNO);
       break;
     }
 
@@ -605,8 +597,9 @@ static int statsd_config_timer_percentile(oconfig_item_t *ci) /* {{{ */
     return ERANGE;
   }
 
-  tmp = realloc(conf_timer_percentile, sizeof(*conf_timer_percentile) *
-                                           (conf_timer_percentile_num + 1));
+  tmp =
+      realloc(conf_timer_percentile,
+              sizeof(*conf_timer_percentile) * (conf_timer_percentile_num + 1));
   if (tmp == NULL) {
     ERROR("statsd plugin: realloc failed.");
     return ENOMEM;
@@ -668,10 +661,8 @@ static int statsd_init(void) /* {{{ */
                             /* attr = */ NULL, statsd_network_thread,
                             /* args = */ NULL);
     if (status != 0) {
-      char errbuf[1024];
       pthread_mutex_unlock(&metrics_lock);
-      ERROR("statsd plugin: pthread_create failed: %s",
-            sstrerror(errno, errbuf, sizeof(errbuf)));
+      ERROR("statsd plugin: pthread_create failed: %s", STRERRNO);
       return status;
     }
   }
@@ -731,7 +722,7 @@ static int statsd_metric_submit_unsafe(char const *name,
     /* Make sure all timer metrics share the *same* timestamp. */
     vl.time = cdtime();
 
-    ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s-average", name);
+    snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-average", name);
     vl.values[0].gauge =
         have_events
             ? CDTIME_T_TO_DOUBLE(latency_counter_get_average(metric->latency))
@@ -739,7 +730,7 @@ static int statsd_metric_submit_unsafe(char const *name,
     plugin_dispatch_values(&vl);
 
     if (conf_timer_lower) {
-      ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s-lower", name);
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-lower", name);
       vl.values[0].gauge =
           have_events
               ? CDTIME_T_TO_DOUBLE(latency_counter_get_min(metric->latency))
@@ -748,7 +739,7 @@ static int statsd_metric_submit_unsafe(char const *name,
     }
 
     if (conf_timer_upper) {
-      ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s-upper", name);
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-upper", name);
       vl.values[0].gauge =
           have_events
               ? CDTIME_T_TO_DOUBLE(latency_counter_get_max(metric->latency))
@@ -757,7 +748,7 @@ static int statsd_metric_submit_unsafe(char const *name,
     }
 
     if (conf_timer_sum) {
-      ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s-sum", name);
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-sum", name);
       vl.values[0].gauge =
           have_events
               ? CDTIME_T_TO_DOUBLE(latency_counter_get_sum(metric->latency))
@@ -766,8 +757,8 @@ static int statsd_metric_submit_unsafe(char const *name,
     }
 
     for (size_t i = 0; i < conf_timer_percentile_num; i++) {
-      ssnprintf(vl.type_instance, sizeof(vl.type_instance),
-                "%s-percentile-%.0f", name, conf_timer_percentile[i]);
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-percentile-%.0f",
+               name, conf_timer_percentile[i]);
       vl.values[0].gauge =
           have_events ? CDTIME_T_TO_DOUBLE(latency_counter_get_percentile(
                             metric->latency, conf_timer_percentile[i]))
@@ -779,7 +770,7 @@ static int statsd_metric_submit_unsafe(char const *name,
      * vl.type's above are implicitly set to "latency". */
     if (conf_timer_count) {
       sstrncpy(vl.type, "gauge", sizeof(vl.type));
-      ssnprintf(vl.type_instance, sizeof(vl.type_instance), "%s-count", name);
+      snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-count", name);
       vl.values[0].gauge = latency_counter_get_num(metric->latency);
       plugin_dispatch_values(&vl);
     }