Merge remote-tracking branch 'github/pr/1929'
[collectd.git] / src / daemon / common.c
index 45f9d53..7806c71 100644 (file)
@@ -1199,6 +1199,18 @@ int parse_values (char *buffer, value_list_t *vl, const data_set_t *ds)
        return (0);
 } /* int parse_values */
 
+int parse_value_file (char const *path, value_t *ret_value, int ds_type)
+{
+       char buffer[256];
+
+       if (read_file_contents (path, buffer, sizeof (buffer)) < 0)
+               return errno;
+
+       strstripnewline (buffer);
+
+       return parse_value (buffer, ret_value, ds_type);
+} /* int parse_value_file */
+
 #if !HAVE_GETPWNAM_R
 int getpwnam_r (const char *name, struct passwd *pwbuf, char *buf,
                size_t buflen, struct passwd **pwbufp)
@@ -1677,14 +1689,14 @@ 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");