aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl/libxl_event.c
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2012-05-10 12:19:15 +0100
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>2012-05-10 12:19:15 +0100
commitba57e19f6c527a784ba24ddadecc59da2effc608 (patch)
tree0e6f139a55805be7d230bc13200e99d78053d761 /tools/libxl/libxl_event.c
parentf5eca5dedd39ddb489fa505cb668eb93ba08937c (diff)
downloadxen-ba57e19f6c527a784ba24ddadecc59da2effc608.tar.gz
xen-ba57e19f6c527a784ba24ddadecc59da2effc608.tar.bz2
xen-ba57e19f6c527a784ba24ddadecc59da2effc608.zip
libxl: Fix incorrect return of OSEVENT_HOOK macro
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(-)
Diffstat (limited to 'tools/libxl/libxl_event.c')
-rw-r--r--tools/libxl/libxl_event.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
index 638b9abb69..e11a4e7603 100644
--- a/tools/libxl/libxl_event.c
+++ b/tools/libxl/libxl_event.c
@@ -27,18 +27,22 @@
* 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