From: Vincent Bernat Date: Fri, 7 Nov 2014 22:46:45 +0000 (+0100) Subject: libstatgrab: fix sg_init() invocation for libstatgrab >= 0.9 X-Git-Tag: collectd-5.5.0~147^2~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2bd9ed649bc73acdd12fd1a59ddf5eaf59a59413;p=collectd.git libstatgrab: fix sg_init() invocation for libstatgrab >= 0.9 In those versions, `sg_init()` need to be invoked with an additional argument. The need for such an argument is detected at configure-time. Fixes: #445 --- diff --git a/configure.ac b/configure.ac index a00eebb1..35f89464 100644 --- a/configure.ac +++ b/configure.ac @@ -4077,6 +4077,34 @@ then LDFLAGS="$SAVE_LDFLAGS" fi +if test "x$with_libstatgrab" = "xyes" +then + SAVE_CFLAGS="$CFLAGS" + SAVE_LDFLAGS="$LDFLAGS" + + CFLAGS="$CFLAGS $with_libstatgrab_cflags" + LDFLAGS="$LDFLAGS $with_libstatgrab_ldflags" + + AC_CACHE_CHECK([if sg_init() requires an argument], + [c_cv_have_libstatgrab_init_arg], + AC_LINK_IFELSE([AC_LANG_PROGRAM( +[[[ +#include +#include +]]], +[[[ + if (sg_init()) return 0; +]]] + )], + [c_cv_have_libstatgrab_init_arg="no"], + [c_cv_have_libstatgrab_init_arg="yes"] + ) + ) + + CFLAGS="$SAVE_CFLAGS" + LDFLAGS="$SAVE_LDFLAGS" +fi + AM_CONDITIONAL(BUILD_WITH_LIBSTATGRAB, test "x$with_libstatgrab" = "xyes") if test "x$with_libstatgrab" = "xyes" then @@ -4085,6 +4113,10 @@ then BUILD_WITH_LIBSTATGRAB_LDFLAGS="$with_libstatgrab_ldflags" AC_SUBST(BUILD_WITH_LIBSTATGRAB_CFLAGS) AC_SUBST(BUILD_WITH_LIBSTATGRAB_LDFLAGS) + if test "x$c_cv_have_libstatgrab_init_arg" = "xyes" + then + AC_DEFINE(HAVE_LIBSTATGRAB_INIT_ARG, 1, [Define to 1 if sg_init does require an argument]) + fi fi # }}} diff --git a/src/daemon/collectd.c b/src/daemon/collectd.c index 2e2d821a..8c4d6e66 100644 --- a/src/daemon/collectd.c +++ b/src/daemon/collectd.c @@ -307,7 +307,11 @@ static int do_init (void) #endif #if HAVE_LIBSTATGRAB - if (sg_init ()) + if (sg_init ( +# if HAVE_LIBSTATGRAB_INIT_ARG + 0 +# endif + )) { ERROR ("sg_init: %s", sg_str_error (sg_get_error ())); return (-1);