evaluate: better error notice when interval flag is not set on
Pablo Neira Ayuso
maintainerPATCH 1/1 evaluate: better error notice when interval flag is not set on
Users get confused with the existing error notice, let's try a different one:
# nft add element x y { 1.1.1.0/24 }
Error: You must add 'flags interval' to your set declaration if you want to add prefix elements
add element x y { 1.1.1.0/24 }
^^^^^^^^^^Signed-off-by Pablo Neira Ayuso <[email protected]>
--- src/evaluate.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
src/evaluate.c +2 -5
@@ -1299,13 +1299,10 @@ static int expr_evaluate_set_elem(struct eval_ctx *ctx, struct expr **expr) !(ctx->set->flags & (NFT_SET_ANONYMOUS | NFT_SET_INTERVAL))) {switch (elem->key->etype) {case EXPR_PREFIX : -return expr_error (ctx->msgs, elem, -"Set member cannot be prefix, " -"missing interval flag on declaration" );case EXPR_RANGE :return expr_error (ctx->msgs, elem, -"Set member cannot be range, " -"missing interval flag on declaration" ); +"You must add 'flags interval' to your %s declaration if you want to add %s elements" , +set_is_map (ctx->set->flags) ?"map" :"set" ,expr_name (elem->key));default :break ; }
Signature · 1 line
2.11.0
Quoted 6 lines · Pablo Neira Ayuso
Users get confused with the existing error notice, let's try a different one:
# nft add element x y { 1.1.1.0/24 } Error: You must add 'flags interval' to your set declaration if you want to add prefix elements add element x y { 1.1.1.0/24 } ^^^^^^^^^^
Not sure why "missing inverval flag on declaration" is more confusing than "you must add 'flags interval' to ...", but maybe I'm just too much into the topic to notice the difference. :)
Quoted 1 line
Unrelated? Did you pick the wrong ticket ID?
Quoted 1 line
Signed-off-by Pablo Neira Ayuso <[email protected]>
Except for nfbz link:
Acked-by Phil Sutter <[email protected]>