summaryrefslogtreecommitdiff
path: root/legacy/eina/src/include/eina_safety_checks.h
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-10-23 06:41:45 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-10-23 06:41:45 +0000
commit0c27fd1a29a6a5c45febbe0f68d6286d69379123 (patch)
treeef5b57bb6c3cca1d2200bf9d82c34701cfbc6e4b /legacy/eina/src/include/eina_safety_checks.h
parent8074415ffc7f0412ba5cc1c50195a312a1edf28c (diff)
ecrustify testing: looked good so I'm committing for other people to review as well
SVN revision: 53800
Diffstat (limited to '')
-rw-r--r--legacy/eina/src/include/eina_safety_checks.h200
1 files changed, 99 insertions, 101 deletions
diff --git a/legacy/eina/src/include/eina_safety_checks.h b/legacy/eina/src/include/eina_safety_checks.h
index 29ebba07d3..3c4c5f0f15 100644
--- a/legacy/eina/src/include/eina_safety_checks.h
+++ b/legacy/eina/src/include/eina_safety_checks.h
@@ -64,7 +64,6 @@
64 * @{ 64 * @{
65 */ 65 */
66 66
67
68#include "eina_config.h" 67#include "eina_config.h"
69#include "eina_error.h" 68#include "eina_error.h"
70 69
@@ -78,112 +77,112 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
78 77
79#include "eina_log.h" 78#include "eina_log.h"
80 79
81#define EINA_SAFETY_ON_NULL_RETURN(exp) \ 80#define EINA_SAFETY_ON_NULL_RETURN(exp) \
82 do \ 81 do \
83 { \ 82 { \
84 if (EINA_UNLIKELY((exp) == NULL)) \ 83 if (EINA_UNLIKELY((exp) == NULL)) \
85 { \ 84 { \
86 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 85 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
87 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ 86 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
88 return; \ 87 return; \
89 } \ 88 } \
90 } \ 89 } \
91 while (0) 90 while (0)
92 91
93#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ 92#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
94 do \ 93 do \
95 { \ 94 { \
96 if (EINA_UNLIKELY((exp) == NULL)) \ 95 if (EINA_UNLIKELY((exp) == NULL)) \
97 { \ 96 { \
98 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 97 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
99 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ 98 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
100 return (val); \ 99 return (val); \
101 } \ 100 } \
102 } \ 101 } \
103 while (0) 102 while (0)
104 103
105#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ 104#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
106 do \ 105 do \
107 { \ 106 { \
108 if (EINA_UNLIKELY((exp) == NULL)) \ 107 if (EINA_UNLIKELY((exp) == NULL)) \
109 { \ 108 { \
110 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 109 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
111 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \ 110 EINA_LOG_ERR("%s", "safety check failed: " # exp " == NULL"); \
112 goto label; \ 111 goto label; \
113 } \ 112 } \
114 } \ 113 } \
115 while (0) 114 while (0)
116 115
117#define EINA_SAFETY_ON_TRUE_RETURN(exp) \ 116#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
118 do \ 117 do \
119 { \ 118 { \
120 if (EINA_UNLIKELY(exp)) \ 119 if (EINA_UNLIKELY(exp)) \
121 { \ 120 { \
122 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 121 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
123 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ 122 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
124 return; \ 123 return; \
125 } \ 124 } \
126 } \ 125 } \
127 while (0) 126 while (0)
128 127
129#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ 128#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
130 do \ 129 do \
131 { \ 130 { \
132 if (EINA_UNLIKELY(exp)) \ 131 if (EINA_UNLIKELY(exp)) \
133 { \ 132 { \
134 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 133 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
135 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ 134 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
136 return val; \ 135 return val; \
137 } \ 136 } \
138 } \ 137 } \
139 while (0) 138 while (0)
140 139
141#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ 140#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
142 do \ 141 do \
143 { \ 142 { \
144 if (EINA_UNLIKELY(exp)) \ 143 if (EINA_UNLIKELY(exp)) \
145 { \ 144 { \
146 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 145 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
147 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \ 146 EINA_LOG_ERR("%s", "safety check failed: " # exp " is true"); \
148 goto label; \ 147 goto label; \
149 } \ 148 } \
150 } \ 149 } \
151 while (0) 150 while (0)
152 151
153#define EINA_SAFETY_ON_FALSE_RETURN(exp) \ 152#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
154 do \ 153 do \
155 { \ 154 { \
156 if (EINA_UNLIKELY(!(exp))) \ 155 if (EINA_UNLIKELY(!(exp))) \
157 { \ 156 { \
158 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 157 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
159 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ 158 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
160 return; \ 159 return; \
161 } \ 160 } \
162 } \ 161 } \
163 while (0) 162 while (0)
164 163
165#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ 164#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
166 do \ 165 do \
167 { \ 166 { \
168 if (EINA_UNLIKELY(!(exp))) \ 167 if (EINA_UNLIKELY(!(exp))) \
169 { \ 168 { \
170 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 169 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
171 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ 170 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
172 return val; \ 171 return val; \
173 } \ 172 } \
174 } \ 173 } \
175 while (0) 174 while (0)
176 175
177#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ 176#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
178 do \ 177 do \
179 { \ 178 { \
180 if (EINA_UNLIKELY(!(exp))) \ 179 if (EINA_UNLIKELY(!(exp))) \
181 { \ 180 { \
182 eina_error_set(EINA_ERROR_SAFETY_FAILED); \ 181 eina_error_set(EINA_ERROR_SAFETY_FAILED); \
183 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \ 182 EINA_LOG_ERR("%s", "safety check failed: " # exp " is false"); \
184 goto label; \ 183 goto label; \
185 } \ 184 } \
186 } \ 185 } \
187 while (0) 186 while (0)
188 187
189#ifdef EINA_ARG_NONNULL 188#ifdef EINA_ARG_NONNULL
@@ -192,34 +191,33 @@ EAPI extern Eina_Error EINA_ERROR_SAFETY_FAILED;
192#define EINA_ARG_NONNULL(idx, ...) 191#define EINA_ARG_NONNULL(idx, ...)
193#endif 192#endif
194 193
195
196#else /* no safety checks */ 194#else /* no safety checks */
197 195
198#define EINA_SAFETY_ON_NULL_RETURN(exp) \ 196#define EINA_SAFETY_ON_NULL_RETURN(exp) \
199 do { (void)(!(exp)); } while (0) 197 do { (void)(!(exp)); } while (0)
200 198
201#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \ 199#define EINA_SAFETY_ON_NULL_RETURN_VAL(exp, val) \
202 do { if (0 && !(exp)) { (void)val; } } while (0) 200 do { if (0 && !(exp)) { (void)val; } } while (0)
203 201
204#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \ 202#define EINA_SAFETY_ON_NULL_GOTO(exp, label) \
205 do { if (0 && (exp) == NULL) { goto label; } } while (0) 203 do { if (0 && (exp) == NULL) { goto label; } } while (0)
206 204
207#define EINA_SAFETY_ON_TRUE_RETURN(exp) \ 205#define EINA_SAFETY_ON_TRUE_RETURN(exp) \
208 do { (void)(exp); } while (0) 206 do { (void)(exp); } while (0)
209 207
210#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \ 208#define EINA_SAFETY_ON_TRUE_RETURN_VAL(exp, val) \
211 do { if (0 && (exp)) { (void)val; } } while (0) 209 do { if (0 && (exp)) { (void)val; } } while (0)
212 210
213#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \ 211#define EINA_SAFETY_ON_TRUE_GOTO(exp, label) \
214 do { if (0 && (exp)) { goto label; } } while (0) 212 do { if (0 && (exp)) { goto label; } } while (0)
215 213
216#define EINA_SAFETY_ON_FALSE_RETURN(exp) \ 214#define EINA_SAFETY_ON_FALSE_RETURN(exp) \
217 do { (void)(!(exp)); } while (0) 215 do { (void)(!(exp)); } while (0)
218 216
219#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \ 217#define EINA_SAFETY_ON_FALSE_RETURN_VAL(exp, val) \
220 do { if (0 && !(exp)) { (void)val; } } while (0) 218 do { if (0 && !(exp)) { (void)val; } } while (0)
221 219
222#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \ 220#define EINA_SAFETY_ON_FALSE_GOTO(exp, label) \
223 do { if (0 && !(exp)) { goto label; } } while (0) 221 do { if (0 && !(exp)) { goto label; } } while (0)
224 222
225#endif /* safety checks macros */ 223#endif /* safety checks macros */