lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20080121.195913.256836460.davem@davemloft.net>
Date:	Mon, 21 Jan 2008 19:59:13 -0800 (PST)
From:	David Miller <davem@...emloft.net>
To:	stephen.hemminger@...tta.com
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH 2/4] dsmark: get rid of trivial function

From: Stephen Hemminger <stephen.hemminger@...tta.com>
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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ