]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: Fix incorrect return of OSEVENT_HOOK macro
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 10 May 2012 11:19:15 +0000 (12:19 +0100)
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 10 May 2012 11:19:15 +0000 (12:19 +0100)
The OSEVENT_HOOK_INTERN macro incorrectly returned the value of the
expression CTX->osevent_in_hook-- (usually 1) instead of the value of
the function call it made. Fix the macro to return the proper value.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 tools/libxl/libxl_event.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

tools/libxl/libxl_event.c

index 638b9abb699408a1d6b394602026e7b8ddc8a0d5..e11a4e7603b9a719a9305149a58ec45a0f20cf5e 100644 (file)
  * these macros, with the ctx locked.  Likewise all the "occurred"
  * entrypoints from the application should assert(!in_hook);
  */
-#define OSEVENT_HOOK_INTERN(defval, hookname, ...)                      \
-    (CTX->osevent_hooks                                                 \
-     ? (CTX->osevent_in_hook++,                                         \
-        CTX->osevent_hooks->hookname(CTX->osevent_user, __VA_ARGS__),   \
-        CTX->osevent_in_hook--)                                         \
-     : defval)
-
-#define OSEVENT_HOOK(hookname,...)                      \
-    OSEVENT_HOOK_INTERN(0, hookname, __VA_ARGS__)
-
-#define OSEVENT_HOOK_VOID(hookname,...)                 \
-    OSEVENT_HOOK_INTERN((void)0, hookname, __VA_ARGS__)
+#define OSEVENT_HOOK_INTERN(retval, hookname, ...) do {                      \
+    if (CTX->osevent_hooks) {                                                \
+        CTX->osevent_in_hook++;                                              \
+        retval CTX->osevent_hooks->hookname(CTX->osevent_user, __VA_ARGS__); \
+        CTX->osevent_in_hook--;                                              \
+    }                                                                        \
+} while (0)
+
+#define OSEVENT_HOOK(hookname, ...) ({                                       \
+    int osevent_hook_rc = 0;                                                 \
+    OSEVENT_HOOK_INTERN(osevent_hook_rc = , hookname, __VA_ARGS__);          \
+    osevent_hook_rc;                                                         \
+})
+
+#define OSEVENT_HOOK_VOID(hookname, ...) \
+    OSEVENT_HOOK_INTERN(/* void */, hookname, __VA_ARGS__)
 
 /*
  * fd events