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]
Date:	Fri, 25 Jul 2008 13:47:59 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	joerg.roedel@....com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] introduce lower_32_bits() macro

On Fri, 25 Jul 2008 12:06:27 -0400
"H. Peter Anvin" <hpa@...or.com> wrote:

> Joerg Roedel wrote:
> > The file kernel.h contains the upper_32_bits macro. This patch adds the other
> > part, the lower_32_bits macro. Its first use will be in the driver for AMD
> > IOMMU.
> > 
> > Signed-off-by: Joerg Roedel <joerg.roedel@....com>
> > ---
> >  include/linux/kernel.h |    6 ++++++
> >  1 files changed, 6 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/linux/kernel.h b/include/linux/kernel.h
> > index f9cd7a5..6fd2977 100644
> > --- a/include/linux/kernel.h
> > +++ b/include/linux/kernel.h
> > @@ -73,6 +73,12 @@ extern const char linux_proc_banner[];
> >   */
> >  #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
> >  
> > +/**
> > + * lower_32_bits - return bits 0-31 of a number
> > + * @n: the number we're accessing
> > + */
> > +#define lower_32_bits(n) ((n) & 0xffffffffULL)
> > +
> 
> NAK.  These are assymmetric with regards to type, which is the *last* 
> thing we want.

Yes, it will convert a 32-bit expression into a 64-bit one.

> The symmetric definition would be ((u32)(n)), but that's already 
> idiomatic use, so why not use it as-is?

There's some readability benefit.  Sometimes it is hard to understand
why some random open-coded cast was used.  But I seem to recall that
there was another reason why we decided we needed this.  I forget, and
so apparently did the changelog author ;)


--
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