From: Harvey Harrison <harvey.harrison@gmail.com>
To: Michael Buesch <mb@bu3sch.de>
Cc: Johannes Berg <johannes@sipsolutions.net>,
linux-wireless <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH 4/7] mac80211: make ieee80211_get_hdrlen_from_skb return unsigned
Date: Fri, 06 Jun 2008 11:47:41 -0700 [thread overview]
Message-ID: <1212778061.6340.85.camel@brick> (raw)
In-Reply-To: <200806062024.24681.mb@bu3sch.de>
On Fri, 2008-06-06 at 20:24 +0200, Michael Buesch wrote:
> On Friday 06 June 2008 19:51:12 Harvey Harrison wrote:
> > -int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
> > +unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
> > {
> > const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data;
> > - int hdrlen;
> > + unsigned int hdrlen;
> >
> > - if (unlikely(skb->len < 10))
> > + if (skb->len < 10)
>
> Why are you removing the unlikely()? This should actually be pretty unlikely.
> Sane firmware will drop short packets, so the kernel won't ever see them.
>
When all that is in the if-block is a return, there's not much point.
It's a trivial test/return and gcc does a fine job with this.
> > return 0;
> > - hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control));
> > - if (unlikely(hdrlen > skb->len))
> > + hdrlen = ieee80211_hdrlen(hdr->frame_control);
> > + if (hdrlen > skb->len)
>
> I think this also is unlikely, as it can only come from corrupted packets.
>
unlikely() isn't some magic make-me-faster function, it just moves code
to the end of the function to get it out of the icache and jumps to it
in the unlikely case it is taken. When all there is is a return, I
don't think it even makes any difference. In both these cases a comment
is probably more appropriate.
Harvey
next prev parent reply other threads:[~2008-06-06 18:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-06 17:51 [PATCH 4/7] mac80211: make ieee80211_get_hdrlen_from_skb return unsigned Harvey Harrison
2008-06-06 18:24 ` Michael Buesch
2008-06-06 18:47 ` Harvey Harrison [this message]
2008-06-06 20:15 ` Pavel Roskin
2008-06-07 2:24 ` Harvey Harrison
2008-06-09 9:15 ` Johannes Berg
2008-06-09 16:25 ` Harvey Harrison
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=1212778061.6340.85.camel@brick \
--to=harvey.harrison@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=mb@bu3sch.de \
/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).