1 $NetBSD: patch-cc,v 1.1 2009/12/01 08:49:46 manu Exp $
2 --- lasso/utils.h.orig 2009-11-30 18:54:46.000000000 +0100
3 +++ lasso/utils.h 2009-11-30 19:31:22.000000000 +0100
5 g_return_val_if_fail(name != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
8 + * The following macros are made to create some formalism for function's cleanup code.
10 + * The exit label should be called 'cleanup'. And for functions returning an integer error code, the
11 + * error code should be named 'rc' and 'return rc;' should be the last statement of the function.
15 + * goto_cleanup_with_rc:
16 + * @rc_value: integer return value
18 + * This macro jump to the 'cleanup' label and set the return value to @rc_value.
21 +#define goto_cleanup_with_rc(rc_value) \
28 + * goto_cleanup_if_fail:
29 + * @condition: a boolean condition
31 + * Jump to the 'cleanup' label if the @condition is FALSE.
34 +#define goto_cleanup_if_fail(condition) \
36 + if (! (condition) ) {\
42 + * goto_cleanup_if_fail_with_rc:
43 + * @condition: a boolean condition
44 + * @rc_value: integer return value
46 + * Jump to the 'cleanup' label if the @condition is FALSE and set the return value to
50 +#define goto_cleanup_if_fail_with_rc(condition, rc_value) \
52 + if (! (condition) ) {\
59 + * goto_cleanup_if_fail_with_rc_with_warning:
60 + * @condition: a boolean condition
61 + * @rc_value: integer return value
63 + * Jump to the 'cleanup' label if the @condition is FALSE and set the return value to
64 + * @rc_value. Also emit a warning, showing the condition and the return value.
67 +#define goto_cleanup_if_fail_with_rc_with_warning(condition, rc_value) \
69 + if (! (condition) ) {\
70 + g_warning("%s failed, returning %s", __STRING(condition), __STRING(rc_value));\
76 #define goto_exit_with_rc(rc_value) \