On Mon, Jun 13, 2016 at 12:47:02PM -0700, Andy Zhou wrote: > On Sun, Jun 12, 2016 at 5:43 PM, Ben Pfaff <b...@ovn.org> wrote: > > > Reported-by: james hopper <jameshop...@email.com> > > Reported-at: > > http://openvswitch.org/pipermail/discuss/2016-June/021662.html > > Signed-off-by: Ben Pfaff <b...@ovn.org> > > --- > > AUTHORS | 1 + > > lib/ofp-util.c | 109 > > ++++++++++++++++++++++++++++++-------------------- > > tests/ofp-util.at | 43 ++++++++++++++++++++ > > tests/ofproto.at | 4 ++ > > utilities/ovs-ofctl.c | 21 ++++++++++ > > 5 files changed, 134 insertions(+), 44 deletions(-) > > > > diff --git a/AUTHORS b/AUTHORS > > index 9fda4c1..e2ac267 100644 > > --- a/AUTHORS > > +++ b/AUTHORS > > @@ -452,6 +452,7 @@ Ziyou Wang ziy...@vmware.com > > Zoltán Balogh zoltan.bal...@ericsson.com > > ankur dwivedi ankurengg2...@gmail.com > > chen zhang 3zhangchen9...@gmail.com > > +james hopper jameshop...@email.com > > kk yap yap...@stanford.edu > > likunyun kunyu...@hotmail.com > > meishengxin meisheng...@huawei.com > > diff --git a/lib/ofp-util.c b/lib/ofp-util.c > > index 2c6fb1f..2c93dd4 100644 > > --- a/lib/ofp-util.c > > +++ b/lib/ofp-util.c > > @@ -7355,6 +7355,36 @@ ofputil_normalize_match_quiet(struct match *match) > > ofputil_normalize_match__(match, false); > > } > > > > +static size_t > > +parse_value(const char *s, const char *delimiters) > > +{ > > + size_t n = 0; > > + for (;;) { > > > Would it be easier to read with a while loop? Of course, there is nothing > wrong > using the for loop logically. > > e.g. > size_t n = 0; > While (!strchr(delimiters, s[n]) { > if (s[n] == '(') > ... > > } > return n;
That's a nice way to do it. Thanks, I changed it. > > > + if (strchr(delimiters, s[n])) { > > + /* strchr(s, '\0') returns s+strlen(s), so this case handles > > the > > + * null terminator at the end of 's'. */ > > + return n; > > + } else if (s[n] == '(') { > > + int level = 0; > > + do { > > + switch (s[n]) { > > + case '\0': > > + return n; > > + case '(': > > + level++; > > + break; > > + case ')': > > + level--; > > + break; > > > Is it possible for n to advance beyond end of string, in case of imbalanced > ")" ? It should not be possible because of the "case '\0':". > I have not played with the test cases, so this is not a full review. Thanks, I'll send v2. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev