Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=5b0ac72bc5fdda9634fb07db4cb0237fa9b6df68
Commit:     5b0ac72bc5fdda9634fb07db4cb0237fa9b6df68
Parent:     81da99ed71254a08d9a0bce46c258c1e15ac3948
Author:     David S. Miller <[EMAIL PROTECTED]>
AuthorDate: Mon Jan 21 02:21:45 2008 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 15:08:39 2008 -0800

    [PKT_SCHED] dsmark: Use hweight32() instead of convoluted loop.
    
    Based upon a patch by Stephen Hemminger and suggestions
    from Patrick McHardy.
    
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/sched/sch_dsmark.c |   15 +++------------
 1 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
index a9732ae..d96eaf0 100644
--- a/net/sched/sch_dsmark.c
+++ b/net/sched/sch_dsmark.c
@@ -10,6 +10,7 @@
 #include <linux/errno.h>
 #include <linux/skbuff.h>
 #include <linux/rtnetlink.h>
+#include <linux/bitops.h>
 #include <net/pkt_sched.h>
 #include <net/dsfield.h>
 #include <net/inet_ecn.h>
@@ -43,17 +44,6 @@ struct dsmark_qdisc_data {
        int                     set_tc_index;
 };
 
-static inline int dsmark_valid_indices(u16 indices)
-{
-       while (indices != 1) {
-               if (indices & 1)
-                       return 0;
-               indices >>= 1;
-       }
-
-       return 1;
-}
-
 static inline int dsmark_valid_index(struct dsmark_qdisc_data *p, u16 index)
 {
        return (index <= p->indices && index > 0);
@@ -348,7 +338,8 @@ static int dsmark_init(struct Qdisc *sch, struct rtattr 
*opt)
                goto errout;
 
        indices = RTA_GET_U16(tb[TCA_DSMARK_INDICES-1]);
-       if (!indices || !dsmark_valid_indices(indices))
+
+       if (hweight32(indices) != 1)
                goto errout;
 
        if (tb[TCA_DSMARK_DEFAULT_INDEX-1])
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to