X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvarnish.c;h=d7da95a35b629a4207597327c6d45f9114221f61;hb=edd9af8a874ebc9f2a7f02846807229a648917db;hp=a138d1813ffaa5109a9310714744a3404e9d6891;hpb=6d13532642c934667697842e4ff021e070ddf34d;p=collectd.git diff --git a/src/varnish.c b/src/varnish.c index a138d181..d7da95a3 100644 --- a/src/varnish.c +++ b/src/varnish.c @@ -793,6 +793,7 @@ static int varnish_read (user_data_t *ud) /* {{{ */ { struct VSM_data *vd; const c_varnish_stats_t *stats; + _Bool ok; user_config_t *conf; @@ -822,10 +823,11 @@ static int varnish_read (user_data_t *ud) /* {{{ */ } #if HAVE_VARNISH_V3 - if (VSC_Open (vd, /* diag = */ 1)) + ok = (VSC_Open (vd, /* diag = */ 1) == 0); #else /* if HAVE_VARNISH_V4 */ - if (VSM_Open (vd)) + ok = (VSM_Open (vd) == 0); #endif + if (!ok) { VSM_Delete (vd); ERROR ("varnish plugin: Unable to open connection."); @@ -941,10 +943,9 @@ static int varnish_init (void) /* {{{ */ if (have_instance) return (0); - conf = malloc (sizeof (*conf)); + conf = calloc (1, sizeof (*conf)); if (conf == NULL) return (ENOMEM); - memset (conf, 0, sizeof (*conf)); /* Default settings: */ conf->instance = NULL; @@ -957,7 +958,7 @@ static int varnish_init (void) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ "varnish/localhost", /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); return (0); @@ -970,10 +971,9 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ char callback_name[DATA_MAX_NAME_LEN]; int i; - conf = malloc (sizeof (*conf)); + conf = calloc (1, sizeof (*conf)); if (conf == NULL) return (ENOMEM); - memset (conf, 0, sizeof (*conf)); conf->instance = NULL; varnish_config_apply_default (conf); @@ -1121,7 +1121,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */ plugin_register_complex_read (/* group = */ "varnish", /* name = */ callback_name, /* callback = */ varnish_read, - /* interval = */ NULL, + /* interval = */ 0, /* user data = */ &ud); have_instance = 1;