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] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.0904251808320.4803@localhost.localdomain>
Date:	Sat, 25 Apr 2009 18:09:11 -0400 (EDT)
From:	"Robert P. J. Day" <rpjday@...shcourse.ca>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Introduce a boolean "single_bit_set" function.

On Fri, 24 Apr 2009, Andrew Morton wrote:

> On Fri, 24 Apr 2009 06:40:39 -0400 (EDT) "Robert P. J. Day" <rpjday@...shcourse.ca> wrote:
>
> >   so it would be a simple matter to define the bit set boolean in
> > terms of hweight_long(), yes?  so what about, in bitops.h:
> >
> >   static inline bool
> >   exactly_one_bit_set(unsigned long w)
> >   {
> > 	return hweight_long(w) == 1;
> >   }
> >
> >   static inline bool
> >   more_than_one_bit_set(unsigned long w)
> >   {
> > 	return hweight_long(w) > 1;
> >   }
> >
> > or something to that effect, *if* people think it's worth it.
> > obviously, none of the above is strictly necessary, but it would make
> > a lot of code semantically cleaner.
> >
>
> Doing plain old
>
> 	if (hweight32(foo) == 1)
>
> (say) at the call sites quite clearly expresses what the code is trying
> to do.

  yes, that seems reasonable.  but would you really prefer "hweight32"
over "hweight_long"?

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

        Linux Consulting, Training and Annoying Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Linked In:                             http://www.linkedin.com/in/rpjday
Twitter:                                       http://twitter.com/rpjday
========================================================================
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ