aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r--src/include/gnunet_common.h42
1 files changed, 30 insertions, 12 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index df1ccff26..3ee2a070a 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
@@ -135,7 +135,7 @@ enum GNUNET_GenericReturnValue
135 * tree where gnunet_config.h is unavailable 135 * tree where gnunet_config.h is unavailable
136 */ 136 */
137#ifndef GNUNET_EXTRA_LOGGING 137#ifndef GNUNET_EXTRA_LOGGING
138#define GNUNET_EXTRA_LOGGING 0 138#define GNUNET_EXTRA_LOGGING 1
139#endif 139#endif
140 140
141/** 141/**
@@ -875,19 +875,37 @@ 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)) \
882 { \ 885 { \
883 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ 886 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
884 _ ("Assertion failed at %s:%d. Aborting.\n"), \ 887 dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \
885 __FILE__, \ 888 __FILE__, \
886 __LINE__); \ 889 __LINE__); \
887 GNUNET_abort_ (); \ 890 GNUNET_abort_ (); \
888 } \ 891 } \
892 _Pragma("GCC diagnostic pop") \
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 dgettext ("gnunet", "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
@@ -899,7 +917,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
899 if (! (cond)) \ 917 if (! (cond)) \
900 { \ 918 { \
901 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ 919 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
902 _ ("Assertion failed at %s:%d. Aborting.\n"), \ 920 dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \
903 f, \ 921 f, \
904 l); \ 922 l); \
905 GNUNET_abort_ (); \ 923 GNUNET_abort_ (); \
@@ -921,7 +939,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
921 { \ 939 { \
922 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ 940 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
923 comp, \ 941 comp, \
924 _ ("Assertion failed at %s:%d. Aborting.\n"), \ 942 dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \
925 __FILE__, \ 943 __FILE__, \
926 __LINE__); \ 944 __LINE__); \
927 GNUNET_abort_ (); \ 945 GNUNET_abort_ (); \
@@ -962,7 +980,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
962 if (! (cond)) \ 980 if (! (cond)) \
963 { \ 981 { \
964 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ 982 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
965 _ ("Assertion failed at %s:%d.\n"), \ 983 dgettext ("gnunet", "Assertion failed at %s:%d.\n"), \
966 __FILE__, \ 984 __FILE__, \
967 __LINE__); \ 985 __LINE__); \
968 } \ 986 } \
@@ -984,7 +1002,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
984 if (! (cond)) \ 1002 if (! (cond)) \
985 { \ 1003 { \
986 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ 1004 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
987 _ ("External protocol violation detected at %s:%d.\n"), \ 1005 dgettext ("gnunet", "External protocol violation detected at %s:%d.\n"), \
988 __FILE__, \ 1006 __FILE__, \
989 __LINE__); \ 1007 __LINE__); \
990 } \ 1008 } \
@@ -1001,7 +1019,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
1001 do \ 1019 do \
1002 { \ 1020 { \
1003 GNUNET_log (level, \ 1021 GNUNET_log (level, \
1004 _ ("`%s' failed at %s:%d with error: %s\n"), \ 1022 dgettext ("gnunet", "`%s' failed at %s:%d with error: %s\n"), \
1005 cmd, \ 1023 cmd, \
1006 __FILE__, \ 1024 __FILE__, \
1007 __LINE__, \ 1025 __LINE__, \
@@ -1020,7 +1038,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
1020 { \ 1038 { \
1021 GNUNET_log_from (level, \ 1039 GNUNET_log_from (level, \
1022 component, \ 1040 component, \
1023 _ ("`%s' failed at %s:%d with error: %s\n"), \ 1041 dgettext ("gnunet", "`%s' failed at %s:%d with error: %s\n"), \
1024 cmd, \ 1042 cmd, \
1025 __FILE__, \ 1043 __FILE__, \
1026 __LINE__, \ 1044 __LINE__, \
@@ -1038,7 +1056,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
1038 do \ 1056 do \
1039 { \ 1057 { \
1040 GNUNET_log (level, \ 1058 GNUNET_log (level, \
1041 _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ 1059 dgettext ("gnunet", "`%s' failed on file `%s' at %s:%d with error: %s\n"), \
1042 cmd, \ 1060 cmd, \
1043 filename, \ 1061 filename, \
1044 __FILE__, \ 1062 __FILE__, \
@@ -1058,7 +1076,7 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind);
1058 { \ 1076 { \
1059 GNUNET_log_from (level, \ 1077 GNUNET_log_from (level, \
1060 component, \ 1078 component, \
1061 _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \ 1079 dgettext ("gnunet", "`%s' failed on file `%s' at %s:%d with error: %s\n"), \
1062 cmd, \ 1080 cmd, \
1063 filename, \ 1081 filename, \
1064 __FILE__, \ 1082 __FILE__, \