On Mon, Jun 13, 2016 at 12:47:02PM -0700, Andy Zhou wrote:
> On Sun, Jun 12, 2016 at 5:43 PM, Ben Pfaff <[email protected]> wrote:
>
> > Reported-by: james hopper <[email protected]>
> > Reported-at:
> > http://openvswitch.org/pipermail/discuss/2016-June/021662.html
> > Signed-off-by: Ben Pfaff <[email protected]>
> > ---
> > 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 [email protected]
> > Zoltán Balogh [email protected]
> > ankur dwivedi [email protected]
> > chen zhang [email protected]
> > +james hopper [email protected]
> > kk yap [email protected]
> > likunyun [email protected]
> > meishengxin [email protected]
> > 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
[email protected]
http://openvswitch.org/mailman/listinfo/dev