MINOR: acl/pattern: use types different from int to clarify who does what.
We now have the following enums and all related functions return them and
consume them :
enum pat_match_res {
PAT_NOMATCH = 0, /* sample didn't match any pattern */
PAT_MATCH = 3, /* sample matched at least one pattern */
};
enum acl_test_res {
ACL_TEST_FAIL = 0, /* test failed */
ACL_TEST_MISS = 1, /* test may pass with more info */
ACL_TEST_PASS = 3, /* test passed */
};
enum acl_cond_pol {
ACL_COND_NONE, /* no polarity set yet */
ACL_COND_IF, /* positive condition (after 'if') */
ACL_COND_UNLESS, /* negative condition (after 'unless') */
};
It's just in order to avoid doubts when reading some code.
diff --git a/include/proto/acl.h b/include/proto/acl.h
index 2d2a34a..82782d4 100644
--- a/include/proto/acl.h
+++ b/include/proto/acl.h
@@ -33,13 +33,13 @@
/* Negate an acl result. This turns (ACL_MATCH_FAIL, ACL_MATCH_MISS,
* ACL_MATCH_PASS) into (ACL_MATCH_PASS, ACL_MATCH_MISS, ACL_MATCH_FAIL).
*/
-static inline int acl_neg(int res)
+static inline enum acl_test_res acl_neg(enum acl_test_res res)
{
return (3 >> res);
}
/* Convert an acl result to a boolean. Only ACL_MATCH_PASS returns 1. */
-static inline int acl_pass(int res)
+static inline int acl_pass(enum acl_test_res res)
{
return (res >> 1);
}
@@ -79,7 +79,8 @@
* known ACLs passed in <known_acl>. The new condition is returned (or NULL in
* case of low memory). Supports multiple conditions separated by "or".
*/
-struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl, int pol, char **err, struct arg_list *al);
+struct acl_cond *parse_acl_cond(const char **args, struct list *known_acl,
+ enum acl_cond_pol pol, char **err, struct arg_list *al);
/* Builds an ACL condition starting at the if/unless keyword. The complete
* condition is returned. NULL is returned in case of error or if the first
@@ -97,7 +98,7 @@
* function only computes the condition, it does not apply the polarity required
* by IF/UNLESS, it's up to the caller to do this.
*/
-int acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, void *l7, unsigned int opt);
+enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, void *l7, unsigned int opt);
/* Returns a pointer to the first ACL conflicting with usage at place <where>
* which is one of the SMP_VAL_* bits indicating a check place, or NULL if