From beb85cc662beda891989872b90bfd2a95e3c7a5a Mon Sep 17 00:00:00 2001 From: Gabriel Ganne Date: Tue, 7 Nov 2017 14:24:56 +0100 Subject: add warning control macro set Add a way to toggle on and off a warning for a specific section of code. This supports clang and gcc, and has no effect for any other compilers. This follows commit bfc29ba442dbb65599f29fe5aa44c6219ed0d3a8 and provides a generic way to handle warnings in such corner cases. To disable a warning enabled by "-Wsome-warning" for a specific code: WARN_OFF(some-warning) // disable compiler warning ; /* some code */ WARN_ON(some-warning) // enable the warning again Change-Id: I0101caa0aa775e2b905c7b3b5fef3bbdce281673 Signed-off-by: Gabriel Ganne --- src/vnet/bfd/bfd_cli.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/vnet/bfd') diff --git a/src/vnet/bfd/bfd_cli.c b/src/vnet/bfd/bfd_cli.c index a533bb74ea5..0e73172b7cb 100644 --- a/src/vnet/bfd/bfd_cli.c +++ b/src/vnet/bfd/bfd_cli.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -385,20 +386,11 @@ static const unsigned optional = 0; have_##n = 1; \ } -#if __GNUC__ >= 6 -#define PRAGMA_STR1 \ - _Pragma ("GCC diagnostic ignored \"-Wtautological-compare\""); -#define PRAGMA_STR2 _Pragma ("GCC diagnostic pop"); -#else -#define PRAGMA_STR1 -#define PRAGMA_STR2 -#endif - #define CHECK_MANDATORY(t, n, s, r, ...) \ - PRAGMA_STR1 \ +WARN_OFF(tautological-compare) \ if (mandatory == r && !have_##n) \ { \ - PRAGMA_STR2 \ + WARN_ON(tautological-compare) \ ret = clib_error_return (0, "Required parameter `%s' missing.", s); \ goto out; \ } -- cgit 1.2.3-korg