From: Ben Pfaff Date: Fri, 4 Dec 2015 22:12:05 +0000 (-0800) Subject: expr: Generalize wording of error message in expand_symbol(). X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=ce57ea75e674b24209ed66058a88236c31277871 expr: Generalize wording of error message in expand_symbol(). The existing wording was very specific to the actual operation being performed. While this is nice for users, it becomes difficult to maintain as more and more operations are added. This commit makes the wording less specific, because a third operation will start using this function in an upcoming commit. Signed-off-by: Ben Pfaff Acked-by: Justin Pettit --- diff --git a/ovn/lib/expr.c b/ovn/lib/expr.c index 0b65492ac..e19692284 100644 --- a/ovn/lib/expr.c +++ b/ovn/lib/expr.c @@ -2625,20 +2625,17 @@ expr_is_normalized(const struct expr *expr) * * If 'rw', verifies that 'f' is a read/write field. * - * 'exchange' should be true if an exchange action is being parsed. This is - * only used to improve error message phrasing. - * * Returns true if successful, false if an error was encountered (in which case * 'ctx->error' reports the particular error). */ static bool -expand_symbol(struct expr_context *ctx, bool rw, bool exchange, +expand_symbol(struct expr_context *ctx, bool rw, struct expr_field *f, struct expr **prereqsp) { const struct expr_symbol *orig_symbol = f->symbol; if (f->symbol->expansion && f->symbol->level != EXPR_L_ORDINAL) { - expr_error(ctx, "Predicate symbol %s cannot be used in %s.", - f->symbol->name, exchange ? "exchange" : "assignment"); + expr_error(ctx, "Predicate symbol %s used where lvalue required.", + f->symbol->name); return false; } @@ -2715,7 +2712,7 @@ parse_assignment(struct expr_context *ctx, const struct simap *ports, goto exit; } const struct expr_symbol *orig_dst = dst.symbol; - if (!expand_symbol(ctx, true, exchange, &dst, &prereqs)) { + if (!expand_symbol(ctx, true, &dst, &prereqs)) { goto exit; } @@ -2725,7 +2722,7 @@ parse_assignment(struct expr_context *ctx, const struct simap *ports, goto exit; } const struct expr_symbol *orig_src = src.symbol; - if (!expand_symbol(ctx, exchange, exchange, &src, &prereqs)) { + if (!expand_symbol(ctx, exchange, &src, &prereqs)) { goto exit; } diff --git a/tests/ovn.at b/tests/ovn.at index f4117b633..d6982b0d6 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -487,19 +487,19 @@ next(16); => "next" argument must be in range 0 to 15. inport[1] = 1; => Cannot select subfield of string field inport. ip.proto[1] = 1; => Cannot select subfield of nominal field ip.proto. eth.dst[40] == 1; => Syntax error at `==' expecting `='. -ip = 1; => Predicate symbol ip cannot be used in assignment. +ip = 1; => Predicate symbol ip used where lvalue required. ip.proto = 6; => Field ip.proto is not modifiable. inport = {"a", "b"}; => Assignments require a single value. inport = {}; => Syntax error at `}' expecting constant. bad_prereq = 123; => Error parsing expression `xyzzy' encountered as prerequisite or predicate of initial expression: Syntax error at `xyzzy' expecting field name. self_recurse = 123; => Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Error parsing expression `self_recurse != 0' encountered as prerequisite or predicate of initial expression: Recursive expansion of symbol `self_recurse'. -vlan.present = 0; => Predicate symbol vlan.present cannot be used in assignment. -reg0[0] = vlan.present; => Predicate symbol vlan.present cannot be used in assignment. +vlan.present = 0; => Predicate symbol vlan.present used where lvalue required. +reg0[0] = vlan.present; => Predicate symbol vlan.present used where lvalue required. reg0 = reg1[0..10]; => Can't assign 11-bit value to 32-bit destination. inport = reg0; => Can't assign integer field (reg0) to string field (inport). inport = big_string; => String fields inport and big_string are incompatible for assignment. ip.proto = reg0[0..7]; => Field ip.proto is not modifiable. -reg0[0] <-> vlan.present; => Predicate symbol vlan.present cannot be used in exchange. +reg0[0] <-> vlan.present; => Predicate symbol vlan.present used where lvalue required. reg0 <-> reg1[0..10]; => Can't exchange 32-bit field with 11-bit field. inport <-> reg0; => Can't exchange string field (inport) with integer field (reg0). inport <-> big_string; => String fields inport and big_string are incompatible for exchange.