From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: Patrick McHardy <kaber@trash.net>, netdev@vger.kernel.org
Subject: [PATCH 2/4] dsmark: get rid of trivial function
Date: Sun, 20 Jan 2008 13:25:50 -0800 [thread overview]
Message-ID: <20080120132550.056370c0@deepthought> (raw)
In-Reply-To: <20080120130542.16720b45@deepthought>
Replace loop in dsmark_valid_indices with equivalent bit math.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/sched/sch_dsmark.c 2008-01-20 13:07:58.000000000 -0800
+++ b/net/sched/sch_dsmark.c 2008-01-20 13:22:54.000000000 -0800
@@ -45,13 +45,8 @@ struct dsmark_qdisc_data {
static inline int dsmark_valid_indices(u16 indices)
{
- while (indices != 1) {
- if (indices & 1)
- return 0;
- indices >>= 1;
- }
-
- return 1;
+ /* Must have only one bit set */
+ return (indices & (indices - 1)) == 0;
}
static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index)
next parent reply other threads:[~2008-01-20 21:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080120130542.16720b45@deepthought>
2008-01-20 21:25 ` Stephen Hemminger [this message]
2008-01-21 0:16 ` [PATCH 2/4] dsmark: get rid of trivial function Patrick McHardy
2008-01-21 8:39 ` Ilpo Järvinen
2008-01-21 10:22 ` David Miller
2008-01-22 3:47 ` Stephen Hemminger
2008-01-22 3:59 ` David Miller
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=20080120132550.056370c0@deepthought \
--to=shemminger@vyatta.com \
--cc=davem@davemloft.net \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.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).