[ovs-dev] [PATCH v2 05/21] expr: Refine handling of error parameter to expr_annotate().

Ben Pfaff blp at ovn.org
Mon Aug 8 16:14:16 UTC 2016


In most cases expr_annotate() set '*errorp' to NULL if it was successful,
but there was one case where it did not.  This corrects that and refines
the comment to better explain the intended behavior.

This didn't affect any existing users because all of them passed in a
pointer that was already NULL.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 ovn/lib/expr.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ovn/lib/expr.c b/ovn/lib/expr.c
index 050e694..a28684b 100644
--- a/ovn/lib/expr.c
+++ b/ovn/lib/expr.c
@@ -1473,6 +1473,7 @@ expr_annotate_cmp(struct expr *expr, const struct shash *symtab,
         }
     }
 
+    *errorp = NULL;
     ovs_list_remove(&an.node);
     return prereqs ? expr_combine(EXPR_T_AND, expr, prereqs) : expr;
 
@@ -1532,8 +1533,10 @@ expr_annotate__(struct expr *expr, const struct shash *symtab,
  *
  * In each case, annotation occurs recursively as necessary.
  *
- * On failure, returns NULL and sets '*errorp' to an explanatory error
- * message, which the caller must free. */
+ * If successful, returns the annotated expression and sets '*errorp' to NULL.
+ * On failure, returns NULL and sets '*errorp' to an explanatory error message,
+ * which the caller must free.  In either case, the caller transfers ownership
+ * of 'expr' and receives ownership of the returned expression, if any. */
 struct expr *
 expr_annotate(struct expr *expr, const struct shash *symtab, char **errorp)
 {
-- 
2.1.3




More information about the dev mailing list