diff mbox

[ovs-dev,12/14] expr: Generalize wording of error message in expand_symbol().

Message ID 1449623297-31060-13-git-send-email-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff Dec. 9, 2015, 1:08 a.m. UTC
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>
---
 ovn/lib/expr.c | 13 +++++--------
 tests/ovn.at   |  8 ++++----
 2 files changed, 9 insertions(+), 12 deletions(-)

Comments

Justin Pettit Dec. 21, 2015, 11:25 p.m. UTC | #1
> On Dec 8, 2015, at 5:08 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> 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>

--Justin
Ben Pfaff Feb. 19, 2016, 8:16 a.m. UTC | #2
On Mon, Dec 21, 2015 at 03:25:42PM -0800, Justin Pettit wrote:
> 
> > On Dec 8, 2015, at 5:08 PM, Ben Pfaff <blp@ovn.org> wrote:
> > 
> > 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>

Thanks, I applied this patch.
diff mbox

Patch

diff --git a/ovn/lib/expr.c b/ovn/lib/expr.c
index 0d7ba32..54e3085 100644
--- a/ovn/lib/expr.c
+++ b/ovn/lib/expr.c
@@ -2635,20 +2635,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;
     }
 
@@ -2727,7 +2724,7 @@  parse_assignment(struct expr_context *ctx,
         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;
     }
 
@@ -2737,7 +2734,7 @@  parse_assignment(struct expr_context *ctx,
             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 6ce9339..522c4e4 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -490,19 +490,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.