X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=1d81a6528c027e46c71de7fdc8c52c4ccf9ba9fc;hb=43aca8ed8b22a7a5a14f8c740948d6ce06efbc95;hp=5f49a9e6fc0848d1ff2975e696d3e87e39ae12b9;hpb=1ebf2f31bd2e080e6f42de640f0a3899a61501c0;p=collectd.git diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 5f49a9e6..1d81a652 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -257,7 +257,7 @@ static int dispatch_value_typesdb (oconfig_item_t *ci) static int dispatch_value_plugindir (oconfig_item_t *ci) { assert (strcasecmp (ci->key, "PluginDir") == 0); - + if (ci->values_num != 1) return (-1); if (ci->values[0].type != OCONFIG_TYPE_STRING) @@ -717,14 +717,13 @@ static oconfig_item_t *cf_read_dir (const char *dir, return (NULL); } - root = malloc (sizeof (*root)); + root = calloc (1, sizeof (*root)); if (root == NULL) { - ERROR ("configfile: malloc failed."); + ERROR ("configfile: calloc failed."); closedir (dh); return (NULL); } - memset (root, 0, sizeof (oconfig_item_t)); while ((de = readdir (dh)) != NULL) { @@ -835,13 +834,12 @@ static oconfig_item_t *cf_read_generic (const char *path, return (NULL); } - root = malloc (sizeof (*root)); + root = calloc (1, sizeof (*root)); if (root == NULL) { - ERROR ("configfile: malloc failed."); + ERROR ("configfile: calloc failed."); return (NULL); } - memset (root, '\0', sizeof (oconfig_item_t)); /* wordexp() might return a sorted list already. That's not * documented though, so let's make sure we get what we want. */ @@ -926,7 +924,7 @@ static oconfig_item_t *cf_read_generic (const char *path, } /* oconfig_item_t *cf_read_generic */ #endif /* !HAVE_WORDEXP_H */ -/* +/* * Public functions */ int global_option_set (const char *option, const char *value) @@ -969,7 +967,7 @@ const char *global_option_get (const char *option) if (i >= cf_global_options_num) return (NULL); - + return ((cf_global_options[i].value != NULL) ? cf_global_options[i].value : cf_global_options[i].def);