netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Arturo Borrero Gonzalez <arturo@netfilter.org>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Netfilter Development Mailing list
	<netfilter-devel@vger.kernel.org>
Subject: Re: [nft PATCH] set_expr: Allow passing the parent set to set_expr_alloc()
Date: Wed, 12 Jul 2017 14:03:15 +0200	[thread overview]
Message-ID: <20170712120315.GR16375@orbyte.nwl.cc> (raw)
In-Reply-To: <CAOkSjBi0c2RJMtSw1KADjEkH-djevs=ZYVHkfzCfKJyej-SDTQ@mail.gmail.com>

On Wed, Jul 12, 2017 at 08:43:10AM +0200, Arturo Borrero Gonzalez wrote:
> On 11 July 2017 at 23:59, Phil Sutter <phil@nwl.cc> wrote:
> > diff --git a/src/expression.c b/src/expression.c
> > index f90ca6035bd3a..f51fbae281b95 100644
> > --- a/src/expression.c
> > +++ b/src/expression.c
> > @@ -824,9 +824,16 @@ static const struct expr_ops set_expr_ops = {
> >         .destroy        = compound_expr_destroy,
> >  };
> >
> > -struct expr *set_expr_alloc(const struct location *loc)
> > +struct expr *set_expr_alloc(const struct location *loc, const struct set *set)
> >  {
> > -       return compound_expr_alloc(loc, &set_expr_ops);
> > +       struct expr *set_expr = compound_expr_alloc(loc, &set_expr_ops);
> > +
> > +       if (set) {
> > +               set_expr->set_flags = set->flags;
> > +               set_expr->dtype = set->keytype;
> > +       }
> > +
> > +       return set_expr;
> >  }
> 
> What about:
> 
> if (!set)
>      return set_expr;
> 
> set_expr->set_flags = set->flags;
> [..]
> return set_expr;

Yes, why not. I did it the other way around to point out that the extra
parameter is purely optional. But OTOH, kill all the indenting! ;)

> > diff --git a/src/segtree.c b/src/segtree.c
> > index a2316a7b98041..f53536210018d 100644
> > --- a/src/segtree.c
> > +++ b/src/segtree.c
> > @@ -602,10 +602,12 @@ static int expr_value_cmp(const void *p1, const void *p2)
> >         int ret;
> >
> >         ret = mpz_cmp(expr_value(e1)->value, expr_value(e2)->value);
> > -       if (ret == 0 && (e1->flags & EXPR_F_INTERVAL_END))
> > -               return -1;
> > -       else
> > -               return 1;
> > +       if (ret == 0) {
> > +               if (e1->flags & EXPR_F_INTERVAL_END)
> > +                       return -1;
> > +               else if (e2->flags & EXPR_F_INTERVAL_END)
> > +                       return 1;
> > +       }
> >
> >         return ret;
> >  }
> > --
> 
> ^^^
> this last chunk belongs to another patch?

Oh crap, no idea how I managed to combine these commits while rebasing.
Thanks for the review, I'll follow-up with a v2.

Cheers, Phil

  reply	other threads:[~2017-07-12 12:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 21:59 [nft PATCH] set_expr: Allow passing the parent set to set_expr_alloc() Phil Sutter
2017-07-12  6:43 ` Arturo Borrero Gonzalez
2017-07-12 12:03   ` Phil Sutter [this message]
2017-07-12 12:14     ` [nft PATCH v2] " Phil Sutter
2017-07-12 12:22       ` Arturo Borrero Gonzalez
2017-07-17 15:31       ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170712120315.GR16375@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=arturo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).