From: Stephen Hemminger <[EMAIL PROTECTED]>
Date: Mon, 21 Jan 2008 19:47:51 -0800

> >  
> >     indices = RTA_GET_U16(tb[TCA_DSMARK_INDICES-1]);
> > -   if (!indices || !dsmark_valid_indices(indices))
> > +
> > +   if (hweight32(indices) != 1)
> >             goto errout;
> 
> Come on Dave, that is a step backwards.

Absolutely not.

> So you took a two instruction thing that any programmer who ever had
> one of those technical trick interviews would surely understand, and
> made it call a function...  Seems like the thing you would consul
> others against.

It's counting bits, "hamming weight" is a count of bits.

That is more understandable to me than:

        Oh BTW, power of two values also just so happen to
        have only 1 bit set.

Testing for a power of two obfuscates the meaning of the
test.  It doesn't want a power-of-two, it wants a bitmask
with only one bit set.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to