[igt-dev] [PATCH i-g-t 2/7] Cast void * pointer used in arithmetic to uint32_t*
Chris Wilson
chris at chris-wilson.co.uk
Tue Jul 10 14:43:23 UTC 2018
Quoting Arkadiusz Hiler (2018-07-10 15:38:26)
> On Tue, Jul 10, 2018 at 03:09:25PM +0100, Chris Wilson wrote:
> > Quoting Arkadiusz Hiler (2018-07-10 14:58:49)
> > > On Sat, Jul 07, 2018 at 08:22:38PM -0300, Rodrigo Siqueira wrote:
> > > > This commit fixes the GCC warning:
> > > >
> > > > warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
> > > > memset(ptr + offsets[0], full_range ? 0x00 : 0x10,
> > > > ^
> > > > warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
> > > > memset(ptr + offsets[1], 0x80,
> > > >
> > > > This commit cast the ptr pointer, which is a void *, to uint32_t * in
> > > > the pointer arithmetic operation.
> > >
> > > This will change semantics, as according to GNU C standard[1], void
> > > pointers have a size of 1 for all arithmetical purposes.
> > >
> > > So you should be using uint8_t (or char) pointer instead.
> >
> > Please just fix the compiler flags, we want close compatibility with the
> > kernel coding standards which explicitly allow void arithmetic for the
> > simplicity it lends to writing code.
> > -Chris
>
> Fair point.
>
> We don't rise the error with meson, so it is not a change in the gcc
> defaults. Somehow autotools manage to end up adding -Wpointer-arith to
> BASE_CFLAGS.
iirc, it's pulled in from xorg-macros. Maybe just tack a
-Wnopointer-arith onto the end, or sed away.
-Chris
More information about the igt-dev
mailing list