Merge branch 'collectd-5.5'
[collectd.git] / src / varnish.c
index 682e362..aee7247 100644 (file)
@@ -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.");
@@ -957,7 +959,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);
@@ -1000,6 +1002,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
        {
                WARNING ("Varnish plugin: \"Instance\" blocks accept only "
                                "one argument.");
+               sfree (conf);
                return (EINVAL);
        }
 
@@ -1107,6 +1110,7 @@ static int varnish_config_instance (const oconfig_item_t *ci) /* {{{ */
                WARNING ("Varnish plugin: No metric has been configured for "
                                "instance \"%s\". Disabling this instance.",
                                (conf->instance == NULL) ? "localhost" : conf->instance);
+               sfree (conf);
                return (EINVAL);
        }
 
@@ -1119,7 +1123,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;