[Common] Prepared a macro WEBAPI_NOP 65/181265/1
authorPiotr Kosko <p.kosko@samsung.com>
Mon, 11 Jun 2018 10:22:41 +0000 (12:22 +0200)
committerPiotr Kosko <p.kosko@samsung.com>
Mon, 11 Jun 2018 10:22:43 +0000 (12:22 +0200)
[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 <p.kosko@samsung.com>
src/common/logger.h

index 3410dd85e664adee818730eba1db41f30884c573..b59a31830ebcd4259ae67b4cf673d44e7ba18b5a 100644 (file)
@@ -7,6 +7,13 @@
 
 #include <dlog.h>
 
+// 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 <cstring>