Merge pull request #1821 from rubenk/memset
[collectd.git] / src / daemon / configfile.c
index 93e90e3..0654ad7 100644 (file)
@@ -273,7 +273,7 @@ static int dispatch_loadplugin (oconfig_item_t *ci)
        int i;
        const char *name;
        unsigned int flags = 0;
-       plugin_ctx_t ctx;
+       plugin_ctx_t ctx = { 0 };
        plugin_ctx_t old_ctx;
        int ret_val;
 
@@ -289,7 +289,6 @@ static int dispatch_loadplugin (oconfig_item_t *ci)
                name = "virt";
 
        /* default to the global interval set before loading this plugin */
-       memset (&ctx, 0, sizeof (ctx));
        ctx.interval = cf_get_default_interval ();
        ctx.flush_interval = 0;
        ctx.flush_timeout = 0;
@@ -406,12 +405,11 @@ static int dispatch_block_plugin (oconfig_item_t *ci)
 
        if (IS_TRUE (global_option_get ("AutoLoadPlugin")))
        {
-               plugin_ctx_t ctx;
+               plugin_ctx_t ctx = { 0 };
                plugin_ctx_t old_ctx;
                int status;
 
                /* default to the global interval set before loading this plugin */
-               memset (&ctx, 0, sizeof (ctx));
                ctx.interval = cf_get_default_interval ();
 
                old_ctx = plugin_set_ctx (ctx);
@@ -939,11 +937,14 @@ int global_option_set (const char *option, const char *value, _Bool from_cli)
                        break;
 
        if (i >= cf_global_options_num)
+       {
+               ERROR ("configfile: Cannot set unknown global option `%s'.", option);
                return (-1);
+       }
 
        if (cf_global_options[i].from_cli && (! from_cli))
        {
-               DEBUG ("Configfile: Ignoring %s `%s' option because "
+               DEBUG ("configfile: Ignoring %s `%s' option because "
                                "it was overriden by a command-line option.",
                                option, value);
                return (0);
@@ -970,7 +971,10 @@ const char *global_option_get (const char *option)
                        break;
 
        if (i >= cf_global_options_num)
+       {
+               ERROR ("configfile: Cannot get unknown global option `%s'.", option);
                return (NULL);
+       }
 
        return ((cf_global_options[i].value != NULL)
                        ? cf_global_options[i].value