[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdW0jEpE3YrA5Znq8O9e4eswARwYYerEhRLSLWxeXMbsEQ@mail.gmail.com>
Date: Tue, 27 Aug 2019 19:59:51 +0200
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: David Laight <David.Laight@...lab.com>,
Joe Perches <joe@...ches.com>,
Bernard Metzler <bmt@...ich.ibm.com>,
Doug Ledford <dledford@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>,
linux-rdma <linux-rdma@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] RDMA/siw: Fix compiler warnings on 32-bit due to
u64/pointer abuse
Hi Al,
On Tue, Aug 27, 2019 at 7:46 PM Al Viro <viro@...iv.linux.org.uk> wrote:
> On Tue, Aug 27, 2019 at 07:29:52PM +0200, Geert Uytterhoeven wrote:
> > On Tue, Aug 27, 2019 at 4:17 PM David Laight <David.Laight@...lab.com> wrote:
> > > From: Geert Uytterhoeven
> > > > Sent: 19 August 2019 18:15
> > > ...
> > > > > I think a cast to unsigned long is rather more common.
> > > > >
> > > > > uintptr_t is used ~1300 times in the kernel.
> > > > > I believe a cast to unsigned long is much more common.
> > > >
> > > > That is true, as uintptr_t was introduced in C99.
> > > > Similarly, unsigned long was used before size_t became common.
> > > >
> > > > However, nowadays size_t and uintptr_t are preferred.
> > >
> > > Isn't uintptr_t defined by the same standard as uint32_t?
> >
> > I believe so.
>
> It sure as hell is not. C99 7.18.1.4:
>
> The following type designates an unsigned integer type with the property that any valid
> pointer to void can be converted to this type, then converted back to pointer to void,
> and the result will compare equal to the original pointer:
> uintptr_t
>
> IOW, it's "large enough to represent pointers".
I did not say the two types are identical, and can be used interchangeable.
Both types are defined (at least) in
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/stdint.h.html
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists