aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-08-04 20:41:25 +0200
committerChristian Grothoff <christian@grothoff.org>2021-08-04 20:41:30 +0200
commitff5075e7f149ffeb9934cb4a505660fc80a9c655 (patch)
tree73d524e70df16f11c7ff031280cfceb76d6de368 /src
parent087337ed13af01c2016a6f084024de14d02a5851 (diff)
downloadgnunet-ff5075e7f149ffeb9934cb4a505660fc80a9c655.tar.gz
gnunet-ff5075e7f149ffeb9934cb4a505660fc80a9c655.zip
do not generate tautological comparisson warnings for assertions (if gcc/clang version supports them)
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_common.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index df1ccff26..8cfeab1cc 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2006-2020 GNUnet e.V. 3 Copyright (C) 2006-2021 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -875,10 +875,14 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
875 * @ingroup logging 875 * @ingroup logging
876 * Use this for fatal errors that cannot be handled 876 * Use this for fatal errors that cannot be handled
877 */ 877 */
878#if __GNUC__ >= 6 || __clang_major__ >= 6
878#define GNUNET_assert(cond) \ 879#define GNUNET_assert(cond) \
879 do \ 880 do \
880 { \ 881 { \
882 _Pragma("GCC diagnostic push") \
883 _Pragma("GCC diagnostic ignored \"-Wtautological-compare\"") \
881 if (! (cond)) \ 884 if (! (cond)) \
885 _Pragma("GCC diagnostic pop") \
882 { \ 886 { \
883 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ 887 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
884 _ ("Assertion failed at %s:%d. Aborting.\n"), \ 888 _ ("Assertion failed at %s:%d. Aborting.\n"), \
@@ -887,7 +891,21 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
887 GNUNET_abort_ (); \ 891 GNUNET_abort_ (); \
888 } \ 892 } \
889 } while (0) 893 } while (0)
890 894#else
895/* older GCC/clangs do not support -Wtautological-compare */
896#define GNUNET_assert(cond) \
897 do \
898 { \
899 if (! (cond)) \
900 { \
901 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
902 _ ("Assertion failed at %s:%d. Aborting.\n"), \
903 __FILE__, \
904 __LINE__); \
905 GNUNET_abort_ (); \
906 } \
907 } while (0)
908#endif
891 909
892/** 910/**
893 * @ingroup logging 911 * @ingroup logging