From e9a0d6bce9e00a8049ed478b88f19196b7694dc9 Mon Sep 17 00:00:00 2001 From: Hyeongsik Min Date: Wed, 26 Apr 2017 20:50:23 +0900 Subject: [PATCH] Define condition checking macros(RET_IF) Change-Id: I5b39db783a6499c1c5429faa8a5777032e743306 Signed-off-by: Hyeongsik Min --- include/peripheral_common.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/include/peripheral_common.h b/include/peripheral_common.h index 1e5d88f..2d2f960 100644 --- a/include/peripheral_common.h +++ b/include/peripheral_common.h @@ -26,4 +26,33 @@ #define _D(fmt, arg...) LOGD(fmt, ##arg) #define _W(fmt, arg...) LOGW(fmt, ##arg) +#define RET_IF(expr) \ + do { \ + if (expr) { \ + _E("(%s)", #expr); \ + return; \ + }\ + } while(0) +#define RETV_IF(expr, val) \ + do {\ + if (expr) { \ + _E("(%s)", #expr); \ + return (val); \ + } \ + } while(0) +#define RETM_IF(expr, fmt, arg...) \ + do {\ + if (expr) { \ + _E(fmt, ##arg); \ + return; \ + }\ + } while(0) +#define RETVM_IF(expr, val, fmt, arg...) \ + do {\ + if (expr) { \ + _E(fmt, ##arg); \ + return (val); \ + } \ + } while(0) + #endif /* __PERIPHERAL_COMMON_H__ */ -- 2.34.1