From 2e8ce8c5ecb6d1f1c8f0af244d9f9b75dc6050ea Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 6 Feb 2013 14:54:53 +0100 Subject: Fix various clang analyzer warnings * Add annotations to our precondition functions so that they don't make the analyzer complain --- common/compat.h | 13 +++++++++++++ common/debug.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/compat.h b/common/compat.h index 7f848d2..5bcdfe2 100644 --- a/common/compat.h +++ b/common/compat.h @@ -51,6 +51,19 @@ #define GNUC_NULL_TERMINATED #endif +/* For detecting clang features */ +#ifndef __has_feature +#define __has_feature(x) 0 +#endif + +#ifndef CLANG_ANALYZER_NORETURN +#if __has_feature(attribute_analyzer_noreturn) +#define CLANG_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) +#else +#define CLANG_ANALYZER_NORETURN +#endif +#endif + #ifndef HAVE_GETPROGNAME const char * getprogname (void); #endif diff --git a/common/debug.h b/common/debug.h index ff2af0f..eb2afa9 100644 --- a/common/debug.h +++ b/common/debug.h @@ -55,7 +55,8 @@ void p11_debug_message (int flag, ...) GNUC_PRINTF (2, 3); void p11_debug_precond (const char *format, - ...) GNUC_PRINTF (1, 2); + ...) GNUC_PRINTF (1, 2) + CLANG_ANALYZER_NORETURN; #define assert_not_reached() \ (assert (false && "this code should not be reached")) -- cgit v1.1