summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2015-10-24 15:48:26 +0200
committerJakub Hrozek <jhrozek@redhat.com>2015-11-11 12:10:51 +0100
commit356eef72675cde4dc5627c1e2f1a01846ec6eb1d (patch)
treece1f1186e5c3b49d47fd203ccd5446667569c5a9
parentf4bcfcb1b91bfa6a568c4c99c2b3d16cd86090c6 (diff)
downloadsssd-356eef72675cde4dc5627c1e2f1a01846ec6eb1d.tar.gz
sssd-356eef72675cde4dc5627c1e2f1a01846ec6eb1d.tar.xz
sssd-356eef72675cde4dc5627c1e2f1a01846ec6eb1d.zip
TESTS: Add warning for unused result of leak check functions
Reviewed-by: Petr Cech <pcech@redhat.com>
-rw-r--r--configure.ac17
-rw-r--r--src/tests/common.h16
2 files changed, 30 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 51c0b0da8..c45787979 100644
--- a/configure.ac
+++ b/configure.ac
@@ -379,6 +379,23 @@ if test x"$sss_cv_attribute_format" = xyes ; then
[whether compiler supports __attribute__((format))])
fi
+AC_CACHE_CHECK([whether compiler supports __attribute__((warn_unused_result))],
+ sss_cv_attribute_warn_unused_result,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE(
+ [ char _check_leaks(int bytes) __attribute__ ((warn_unused_result)); ]
+ )],
+ [sss_cv_attribute_warn_unused_result=yes],
+ [
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([compiler does NOT support __attribute__((warn_unused_result))])
+ ])
+ ])
+if test x"$sss_cv_attribute_warn_unused_result" = xyes ; then
+ AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_WARN_UNUSED_RESULT, 1,
+ [whether compiler supports __attribute__((warn_unused_result))])
+fi
+
PKG_CHECK_MODULES([CHECK], [check >= 0.9.5], [have_check=1], [have_check=])
if test x$have_check = x; then
AC_MSG_WARN([Without the 'CHECK' libraries, you will be unable to run all tests in the 'make check' suite])
diff --git a/src/tests/common.h b/src/tests/common.h
index ac9ba4026..794218c5b 100644
--- a/src/tests/common.h
+++ b/src/tests/common.h
@@ -25,11 +25,20 @@
#ifndef __TESTS_COMMON_H__
#define __TESTS_COMMON_H__
+#include "config.h"
+
#include <talloc.h>
#include "util/util.h"
#include "providers/data_provider.h"
#include "providers/ldap/sdap.h"
+
+#ifdef HAVE_FUNCTION_ATTRIBUTE_WARN_UNUSED_RESULT
+#define SSS_ATTRIBUTE_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#else
+#define SSS_ATTRIBUTE_WARN_UNUSED_RESULT
+#endif
+
#define N_ELEMENTS(arr) (sizeof(arr) / sizeof(arr[0]))
extern TALLOC_CTX *global_talloc_context;
@@ -37,10 +46,11 @@ extern TALLOC_CTX *global_talloc_context;
void check_leaks_push(TALLOC_CTX *ctx);
#define check_leaks_pop(ctx) _check_leaks_pop((ctx), __location__)
-bool _check_leaks_pop(TALLOC_CTX *ctx, const char *location);
+bool _check_leaks_pop(TALLOC_CTX *ctx, const char *location)
+ SSS_ATTRIBUTE_WARN_UNUSED_RESULT;
-bool leak_check_setup(void);
-bool leak_check_teardown(void);
+bool leak_check_setup(void) SSS_ATTRIBUTE_WARN_UNUSED_RESULT;
+bool leak_check_teardown(void) SSS_ATTRIBUTE_WARN_UNUSED_RESULT;
const char *check_leaks_err_msg(void);
void tests_set_cwd(void);