BUG/MINOR: acl: fix sample expression error reporting
ACL parse errors are not easy to understand since recent commit 348971e
(MEDIUM: acl: use the fetch syntax 'fetch(args),conv(),conv()' into the
ACL keyword) :
[ALERT] 339/154717 (26437) : parsing [check-bug.cfg:10] : error detected while parsing a 'stats admin' rule : unknown ACL or sample keyword 'env(a,b,c)': invalid arg 2 in fetch method 'env' : end of arguments expected at position 2, but got ',b,c'..
This error is only relevant to sample fetch keywords, so the new form is
a bit easier to understand :
[ALERT] 339/160011 (26626) : parsing [check-bug.cfg:12] : error detected while parsing a 'stats admin' rule : invalid arg 2 in fetch method 'env' : end of arguments expected at position 2, but got ',b,c' in sample expression 'env(a,b,c),upper'.
No backport is needed.
diff --git a/src/acl.c b/src/acl.c
index 95b559c..62a58f6 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -153,7 +153,7 @@
smp = sample_parse_expr((char **)args, &idx, trash.str, trash.size, al);
if (!smp) {
- memprintf(err, "unknown ACL or sample keyword '%s': %s", *args, trash.str);
+ memprintf(err, "%s in sample expression '%s'", trash.str, *args);
goto out_return;
}
}
diff --git a/src/sample.c b/src/sample.c
index 4253dd1..50ceb85 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -612,7 +612,7 @@
for (endw = begw; *endw && *endw != '(' && *endw != ','; endw++);
if (endw == begw) {
- snprintf(err, err_size, "missing fetch method.");
+ snprintf(err, err_size, "missing fetch method");
goto out_error;
}
@@ -621,7 +621,7 @@
fetch = find_sample_fetch(begw, endw - begw);
if (!fetch) {
- snprintf(err, err_size, "unknown fetch method '%s'.", fkw);
+ snprintf(err, err_size, "unknown fetch method '%s'", fkw);
goto out_error;
}
@@ -631,7 +631,7 @@
while (*endt && *endt != ')')
endt++;
if (*endt != ')') {
- snprintf(err, err_size, "syntax error: missing ')' after fetch keyword '%s'.", fkw);
+ snprintf(err, err_size, "syntax error: missing ')' after fetch keyword '%s'", fkw);
goto out_error;
}
}
@@ -643,7 +643,7 @@
*/
if (fetch->out_type >= SMP_TYPES) {
- snprintf(err, err_size, "returns type of fetch method '%s' is unknown.", fkw);
+ snprintf(err, err_size, "returns type of fetch method '%s' is unknown", fkw);
goto out_error;
}
prev_type = fetch->out_type;
@@ -661,14 +661,14 @@
int err_arg;
if (!fetch->arg_mask) {
- snprintf(err, err_size, "fetch method '%s' does not support any args.", fkw);
+ snprintf(err, err_size, "fetch method '%s' does not support any args", fkw);
goto out_error;
}
al->kw = expr->fetch->kw;
al->conv = NULL;
if (make_arg_list(endw + 1, endt - endw - 1, fetch->arg_mask, &expr->arg_p, &err_msg, NULL, &err_arg, al) < 0) {
- snprintf(err, err_size, "invalid arg %d in fetch method '%s' : %s.", err_arg+1, fkw, err_msg);
+ snprintf(err, err_size, "invalid arg %d in fetch method '%s' : %s", err_arg+1, fkw, err_msg);
free(err_msg);
goto out_error;
}
@@ -677,13 +677,13 @@
expr->arg_p = empty_arg_list;
if (fetch->val_args && !fetch->val_args(expr->arg_p, &err_msg)) {
- snprintf(err, err_size, "invalid args in fetch method '%s' : %s.", fkw, err_msg);
+ snprintf(err, err_size, "invalid args in fetch method '%s' : %s", fkw, err_msg);
free(err_msg);
goto out_error;
}
}
else if (ARGM(fetch->arg_mask)) {
- snprintf(err, err_size, "missing args for fetch method '%s'.", fkw);
+ snprintf(err, err_size, "missing args for fetch method '%s'", fkw);
goto out_error;
}
@@ -707,9 +707,9 @@
if (*endt && *endt != ',') {
if (ckw)
- snprintf(err, err_size, "missing comma after conv keyword '%s'.", ckw);
+ snprintf(err, err_size, "missing comma after conv keyword '%s'", ckw);
else
- snprintf(err, err_size, "missing comma after fetch keyword '%s'.", fkw);
+ snprintf(err, err_size, "missing comma after fetch keyword '%s'", fkw);
goto out_error;
}
@@ -736,7 +736,7 @@
/* we found an isolated keyword that we don't know, it's not ours */
if (begw == str[*idx])
break;
- snprintf(err, err_size, "unknown conv method '%s'.", ckw);
+ snprintf(err, err_size, "unknown conv method '%s'", ckw);
goto out_error;
}
@@ -746,19 +746,19 @@
while (*endt && *endt != ')')
endt++;
if (*endt != ')') {
- snprintf(err, err_size, "syntax error: missing ')' after conv keyword '%s'.", ckw);
+ snprintf(err, err_size, "syntax error: missing ')' after conv keyword '%s'", ckw);
goto out_error;
}
}
if (conv->in_type >= SMP_TYPES || conv->out_type >= SMP_TYPES) {
- snprintf(err, err_size, "returns type of conv method '%s' is unknown.", ckw);
+ snprintf(err, err_size, "returns type of conv method '%s' is unknown", ckw);
goto out_error;
}
/* If impossible type conversion */
if (!sample_casts[prev_type][conv->in_type]) {
- snprintf(err, err_size, "conv method '%s' cannot be applied.", ckw);
+ snprintf(err, err_size, "conv method '%s' cannot be applied", ckw);
goto out_error;
}
@@ -775,14 +775,14 @@
int err_arg;
if (!conv->arg_mask) {
- snprintf(err, err_size, "conv method '%s' does not support any args.", ckw);
+ snprintf(err, err_size, "conv method '%s' does not support any args", ckw);
goto out_error;
}
al->kw = expr->fetch->kw;
al->conv = conv_expr->conv->kw;
if (make_arg_list(endw + 1, endt - endw - 1, conv->arg_mask, &conv_expr->arg_p, &err_msg, NULL, &err_arg, al) < 0) {
- snprintf(err, err_size, "invalid arg %d in conv method '%s' : %s.", err_arg+1, ckw, err_msg);
+ snprintf(err, err_size, "invalid arg %d in conv method '%s' : %s", err_arg+1, ckw, err_msg);
free(err_msg);
goto out_error;
}
@@ -791,13 +791,13 @@
conv_expr->arg_p = empty_arg_list;
if (conv->val_args && !conv->val_args(conv_expr->arg_p, conv, &err_msg)) {
- snprintf(err, err_size, "invalid args in conv method '%s' : %s.", ckw, err_msg);
+ snprintf(err, err_size, "invalid args in conv method '%s' : %s", ckw, err_msg);
free(err_msg);
goto out_error;
}
}
else if (ARGM(conv->arg_mask)) {
- snprintf(err, err_size, "missing args for conv method '%s'.", ckw);
+ snprintf(err, err_size, "missing args for conv method '%s'", ckw);
goto out_error;
}
}