[ovs-dev] [PATCH 2/4] ofp-util: Avoid ovs_fatal() in ofputil_parse_key_value().

Ben Pfaff blp at nicira.com
Fri Apr 27 16:49:50 UTC 2012


ofputil_parse_key_value() is safe to use from a process that must not abort
except in one case: where the argument contains unbalanced parentheses.
This commit eliminates that call to ovs_fatal(), instead just treating the
end of the string as closing all nested parentheses.

It would be better to propagate the error condition upward, but I'm not
sure that it's worth it just for this one corner case.

The purpose of this commit is to make it possible to use this function
indirectly within the "ofproto/trace" implementation, which must never
abort ovs-vswitchd.  (All the current callers are within ovs-ofctl and
other utilities.)

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/ofp-util.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 90475f7..264c53d 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -3926,7 +3926,8 @@ ofputil_parse_key_value(char **stringp, char **keyp, char **valuep)
         for (value_len = 0; level > 0; value_len++) {
             switch (value[value_len]) {
             case '\0':
-                ovs_fatal(0, "unbalanced parentheses in argument to %s", key);
+                level = 0;
+                break;
 
             case '(':
                 level++;
-- 
1.7.2.5




More information about the dev mailing list