From: "Linus Lüssing" <linus.luessing@c0d3.blue>
To: The list for a Better Approach To Mobile Ad-hoc Networking
<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCHv3] batman-adv: Introduce forward packet creation helper
Date: Mon, 20 Jun 2016 19:58:03 +0200 [thread overview]
Message-ID: <20160620175803.GB16638@otheros> (raw)
In-Reply-To: <5707464.HeWq3LKJdl@sven-edge>
On Sun, Jun 19, 2016 at 01:00:18PM +0200, Sven Eckelmann wrote:
> And I would have written it slightly different. I don't want to say that your
> way is worse or my version is better but just add a slightly different way
> into the discussion
Looks good to me, I like all your suggestions for
forw_packet_alloc() :).
> > @@ -478,20 +546,16 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
> > struct batadv_bcast_packet *bcast_packet;
> > struct sk_buff *newskb;
> >
> > - if (!batadv_atomic_dec_not_zero(&bat_priv->bcast_queue_left)) {
> > - batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
> > - "bcast packet queue full\n");
> > - goto out;
> > - }
> > -
> > primary_if = batadv_primary_if_get_selected(bat_priv);
> > if (!primary_if)
> > - goto out_and_inc;
> > -
> > - forw_packet = kmalloc(sizeof(*forw_packet), GFP_ATOMIC);
> > + goto out;
>
> I think you can return here directly
>
> >
> > + forw_packet = batadv_forw_packet_alloc(primary_if, NULL,
> > + &bat_priv->bcast_queue_left,
> > + bat_priv);
> > + batadv_hardif_put(primary_if);
> > if (!forw_packet)
> > - goto out_and_inc;
> > + goto out;
>
> Same here
Regarding these two goto's, usually using a "return" directly instead of a
"goto out" is better, I agree. For these two cases I think I would
prefer keeping it that way, because it's not a simple return but a
return of a macro value. Having NETDEV_TX_OK and NETDEV_TX_BUSY
each only once in a function makes it easier to spot the good or
bad cases, I think?
Or maybe I could rename "out" and "packet_free" to "err" and
"err_packet_free" to make the error cases even more visible?
Regards, Linus
next prev parent reply other threads:[~2016-06-20 17:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-14 21:19 [B.A.T.M.A.N.] [PATCHv3] batman-adv: Introduce forward packet creation helper Linus Lüssing
2016-06-19 11:00 ` Sven Eckelmann
2016-06-20 17:58 ` Linus Lüssing [this message]
2016-06-20 18:05 ` Sven Eckelmann
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=20160620175803.GB16638@otheros \
--to=linus.luessing@c0d3.blue \
--cc=b.a.t.m.a.n@lists.open-mesh.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