Logging: Fix broken logging macros.
authorTom Hacohen <tom@stosb.com>
Mon, 22 Jun 2015 14:37:13 +0000 (15:37 +0100)
committerTom Hacohen <tom@stosb.com>
Mon, 22 Jun 2015 14:39:58 +0000 (15:39 +0100)
This is macro 101, you don't EVER put multiple statements in a macro
like that.
See Chris's commits, these broken macros already introduced (subtle)
bugs. Always surround macros in "do {} while()" unless you absolutely
can't (like when you declare a new variable to be used in the scope).

Why is it even there? I think we can safely assume eina log is available
for usage in E...

@fix

src/bin/e_log.h

index 4100780..325539f 100644 (file)
@@ -27,11 +27,11 @@ EINTERN int e_log_shutdown(void);
 #undef WRN
 #undef ERR
 #undef CRI
-#define DBG(...)            printf(__VA_ARGS__); putc('\n', stdout)
-#define INF(...)            printf(__VA_ARGS__); putc('\n', stdout)
-#define WRN(...)            printf(__VA_ARGS__); putc('\n', stdout)
-#define ERR(...)            printf(__VA_ARGS__); putc('\n', stdout)
-#define CRI(...)            printf(__VA_ARGS__); putc('\n', stdout)
+#define DBG(...)            do { printf(__VA_ARGS__); putc('\n', stdout); } while(0)
+#define INF(...)            do { printf(__VA_ARGS__); putc('\n', stdout); } while(0)
+#define WRN(...)            do { printf(__VA_ARGS__); putc('\n', stdout); } while(0)
+#define ERR(...)            do { printf(__VA_ARGS__); putc('\n', stdout); } while(0)
+#define CRI(...)            do { printf(__VA_ARGS__); putc('\n', stdout); } while(0)
 #endif
 
 #endif