From: Piotr Kosko Date: Mon, 11 Jun 2018 10:22:41 +0000 (+0200) Subject: [Common] Prepared a macro WEBAPI_NOP X-Git-Tag: submit/tizen/20180612.064221~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=903522aec7fbe5c2f17d6e48acd540a1799b7fc7;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Common] Prepared a macro WEBAPI_NOP [Feature] Dlog team is changing internal code of their module. As webapi code is using this code, it was needed to prepare own macro for no-operation with checking the types in compilation time. [Verification] Code compiles without errors Change-Id: I68a0e2bde3894cc991420abd9e0efe778e637be7 Signed-off-by: Piotr Kosko --- diff --git a/src/common/logger.h b/src/common/logger.h index 3410dd85..b59a3183 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -7,6 +7,13 @@ #include +// Using static inline function with no operation inside to cause compiler types check. +// Using empty do {} while in WEBAPI_NOP macro will cause that when TIZEN_DEBUG_ENABLE flag +// is turned off, then no types checking will be performed. This could cause problems when +// developing code with this flag off and then enabling it. +static inline int _noop_print(const char *fmt __attribute__((unused)), ...) { return 0; } +#define WEBAPI_NOP(...) ({ do { _noop_print(__VA_ARGS__); } while (0); }) + // Tizen 3.0 uses different debug flag (DLOG_DEBUG_ENABLE) which is always // enabled, following code allows to disable logs with DLOG_DEBUG priority if // TIZEN_DEBUG_ENABLE is not set. @@ -41,7 +48,7 @@ } while (0); \ }) #else // TIZEN_DEBUG_ENABLE -#define SECURE_LOG_(id, prio, tag, fmt, arg...) NOP(fmt, ##arg) +#define SECURE_LOG_(id, prio, tag, fmt, arg...) WEBAPI_NOP(fmt, ##arg) #endif // TIZEN_DEBUG_ENABLE #include