Merge branch 'collectd-5.5' into collectd-5.6
[collectd.git] / src / daemon / common.c
index a522759..7898ffb 100644 (file)
@@ -1124,7 +1124,7 @@ int parse_value (const char *value_orig, value_t *ret_value, int ds_type)
   }
 
   if (value == endptr) {
-    ERROR ("parse_value: Failed to parse string as %s: %s.",
+    ERROR ("parse_value: Failed to parse string as %s: \"%s\".",
         DS_TYPE_TO_STRING (ds_type), value);
     sfree (value);
     return -1;
@@ -1572,8 +1572,6 @@ void set_sock_opts (int sockfd) /* {{{ */
 
        socklen_t socklen = sizeof (socklen_t);
        int so_keepalive = 1;
-       int tcp_keepidle = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 100 + 1);
-       int tcp_keepintvl = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 1000 + 1);
 
        status = getsockopt (sockfd, SOL_SOCKET, SO_TYPE, &socktype, &socklen);
        if (status != 0)
@@ -1590,6 +1588,7 @@ void set_sock_opts (int sockfd) /* {{{ */
                        WARNING ("set_sock_opts: failed to set socket keepalive flag");
 
 #ifdef TCP_KEEPIDLE
+               int tcp_keepidle = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 100 + 1);
                status = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPIDLE,
                                &tcp_keepidle, sizeof (tcp_keepidle));
                if (status != 0)
@@ -1597,6 +1596,7 @@ void set_sock_opts (int sockfd) /* {{{ */
 #endif
 
 #ifdef TCP_KEEPINTVL
+               int tcp_keepintvl = ((CDTIME_T_TO_MS(plugin_get_interval()) - 1) / 1000 + 1);
                status = setsockopt(sockfd, IPPROTO_TCP, TCP_KEEPINTVL,
                                &tcp_keepintvl, sizeof (tcp_keepintvl));
                if (status != 0)
@@ -1677,17 +1677,18 @@ void strarray_free (char **array, size_t array_len) /* {{{ */
 int check_capability (int capability) /* {{{ */
 {
 #ifdef _LINUX_CAPABILITY_VERSION_3
-       cap_user_header_t cap_header = calloc(sizeof (*cap_header), 1);
+       cap_user_header_t cap_header = calloc(1, sizeof (*cap_header));
        if (cap_header == NULL)
        {
                ERROR("check_capability: calloc failed");
                return (-1);
        }
 
-       cap_user_data_t cap_data = calloc(sizeof (*cap_data), 1);
+       cap_user_data_t cap_data = calloc(1, sizeof (*cap_data));
        if (cap_data == NULL)
        {
                ERROR("check_capability: calloc failed");
+               sfree(cap_header);
                return (-1);
        }