update Mon May 31 06:37:01 PDT 2010
[pkgsrc.git] / security / lasso / patches / patch-cc
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
4 @@ -336,4 +336,73 @@
5         g_return_val_if_fail(name != NULL, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ);
6  
7 +/**
8 + * The following macros are made to create some formalism for function's cleanup code.
9 + *
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.
12 + */
13 +
14 +/**
15 + * goto_cleanup_with_rc:
16 + * @rc_value: integer return value
17 + *
18 + * This macro jump to the 'cleanup' label and set the return value to @rc_value.
19 + *
20 + */
21 +#define goto_cleanup_with_rc(rc_value) \
22 +       {\
23 +               rc = (rc_value); \
24 +               goto cleanup; \
25 +       }
26 +
27 +/**
28 + * goto_cleanup_if_fail:
29 + * @condition: a boolean condition
30 + *
31 + * Jump to the 'cleanup' label if the @condition is FALSE.
32 + *
33 + */
34 +#define goto_cleanup_if_fail(condition) \
35 +       {\
36 +               if (! (condition) ) {\
37 +                       goto cleanup; \
38 +               } \
39 +       }
40 +
41 +/**
42 + * goto_cleanup_if_fail_with_rc:
43 + * @condition: a boolean condition
44 + * @rc_value: integer return value
45 + *
46 + * Jump to the 'cleanup' label if the @condition is FALSE and set the return value to
47 + * @rc_value.
48 + *
49 + */
50 +#define goto_cleanup_if_fail_with_rc(condition, rc_value) \
51 +       {\
52 +               if (! (condition) ) {\
53 +                       rc = (rc_value); \
54 +                       goto cleanup; \
55 +               } \
56 +       }
57 +
58 +/**
59 + * goto_cleanup_if_fail_with_rc_with_warning:
60 + * @condition: a boolean condition
61 + * @rc_value: integer return value
62 + *
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.
65 + *
66 + */
67 +#define goto_cleanup_if_fail_with_rc_with_warning(condition, rc_value) \
68 +       {\
69 +               if (! (condition) ) {\
70 +                       g_warning("%s failed, returning %s", __STRING(condition), __STRING(rc_value));\
71 +                       rc = (rc_value); \
72 +                       goto cleanup; \
73 +               } \
74 +       }
75 +
76  #define goto_exit_with_rc(rc_value) \
77         {\