expr: Generalize wording of error message in expand_symbol().
authorBen Pfaff <blp@ovn.org>
Fri, 4 Dec 2015 22:12:05 +0000 (14:12 -0800)
committerBen Pfaff <blp@ovn.org>
Fri, 19 Feb 2016 08:13:39 +0000 (00:13 -0800)
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 <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
ovn/lib/expr.c
tests/ovn.at

index 0b65492..e196922 100644 (file)
@@ -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;
         }
 
index f4117b6..d6982b0 100644 (file)
@@ -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.