From 97b564c708fbb44cf1ac512d7eaca701767120d5 Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Mon, 5 Oct 2009 05:37:31 +0000 Subject: libglusterfs: Add STACK_UNWIND_STRICT macro. STACK_UNWIND_STRICT (op, frame, this, op_ret, op_errno, ...) The "op" argument is the name of the fop (lookup, open, etc.). This macro makes sure that the number and type of arguments passed match those of the callback function for the fop. Signed-off-by: Anand V. Avati BUG: 269 (Add a specialized STACK_UNWIND macro for each FOP) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=269 --- libglusterfs/src/stack.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 94297255607..e03f95ca128 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -215,6 +215,24 @@ STACK_DESTROY (call_stack_t *stack) } while (0) +/* return from function in type-safe way */ +#define STACK_UNWIND_STRICT(op, frame, params ...) \ + do { \ + fop_##op##_cbk_t fn = NULL; \ + call_frame_t *_parent = NULL; \ + xlator_t *old_THIS = NULL; \ + \ + fn = (fop_##op##_cbk_t )frame->ret; \ + _parent = frame->parent; \ + _parent->ref_count--; \ + old_THIS = THIS; \ + THIS = _parent->this; \ + frame->complete = _gf_true; \ + fn (_parent, frame->cookie, _parent->this, params); \ + THIS = old_THIS; \ + } while (0) + + static inline call_frame_t * copy_frame (call_frame_t *frame) { -- cgit