expr: Generalize wording of error message in expand_symbol().
[cascardo/ovs.git] / ovn / lib / expr.c
index 316d557..e196922 100644 (file)
@@ -1789,7 +1789,7 @@ crush_and_numeric(struct expr *expr, const struct expr_symbol *symbol)
                 expr_destroy(expr);
                 return new;
             }
-            free(new);
+            expr_destroy(new);
             break;
         }
     }
@@ -1827,7 +1827,7 @@ crush_and_numeric(struct expr *expr, const struct expr_symbol *symbol)
                                       &sub->cmp.value, &sub->cmp.mask)) {
                 list_push_back(&or->andor, &sub->node);
             } else {
-                free(sub);
+                expr_destroy(sub);
             }
         }
         free(disjuncts);
@@ -1974,7 +1974,7 @@ crush_or(struct expr *expr, const struct expr_symbol *symbol)
         if (compare_cmps_3way(a, b)) {
             list_push_back(&expr->andor, &b->node);
         } else {
-            free(b);
+            expr_destroy(b);
         }
     }
     free(subs);
@@ -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;
         }