curl stats: Use cf_util_get_boolean().
authorSebastian Harl <sh@tokkee.org>
Mon, 30 May 2016 21:29:05 +0000 (23:29 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 10 Jun 2016 19:04:49 +0000 (21:04 +0200)
src/utils_curl_stats.c

index 0f2f56e..ff2eb64 100644 (file)
@@ -173,6 +173,8 @@ curl_stats_t *curl_stats_from_config (oconfig_item_t *ci)
                oconfig_item_t *c = ci->children + i;
                size_t field;
 
+               _Bool enabled = 0;
+
                for (field = 0; field < STATIC_ARRAY_SIZE (field_specs); ++field) {
                        if (! strcasecmp (c->key, field_specs[field].config_key))
                                break;
@@ -186,14 +188,12 @@ curl_stats_t *curl_stats_from_config (oconfig_item_t *ci)
                        return NULL;
                }
 
-               if ((c->values_num != 1)
-                               || (c->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
-                       ERROR ("curl stats: `%s' expects a single boolean argument", c->key);
+
+               if (cf_util_get_boolean (c, &enabled) != 0) {
                        free (s);
                        return NULL;
                }
-
-               if (c->values[0].value.boolean)
+               if (enabled)
                        enable_field (s, field_specs[field].offset);
        }