Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-28 Thread Arnd Bergmann
On Wed, Oct 28, 2020 at 1:42 AM Jakub Kicinski wrote: > > On Mon, 26 Oct 2020 22:29:48 +0100 Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > Building a "W=1" kernel with clang produces a warning about > > suspicous pointer arithmetic: > > > > drivers/atm/horizon.c:1844:52: warning: performin

Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-28 Thread Jakub Kicinski
On Mon, 26 Oct 2020 22:29:48 +0100 Arnd Bergmann wrote: > From: Arnd Bergmann > > Building a "W=1" kernel with clang produces a warning about > suspicous pointer arithmetic: > > drivers/atm/horizon.c:1844:52: warning: performing pointer arithmetic > on a null pointer has undefined behavior [-Wnu

Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-27 Thread Xie He
On Tue, Oct 27, 2020 at 6:24 AM Arnd Bergmann wrote: > > Ah, of course. I had looked up the types but mixed up the memmap > and HDW definitions, but then got confused trying to understand the > logic in wr_mem() that operates on bytes but expands them into > multiples of 4. I think wr_mem() doesn

Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-27 Thread Arnd Bergmann
On Tue, Oct 27, 2020 at 5:02 AM Xie He wrote: > > On Mon, Oct 26, 2020 at 8:56 PM Xie He wrote: > > > > > - for (mem = (HDW *) memmap; mem < (HDW *) (memmap + 1); ++mem) > > > + for (mem = (HDW *) memmap; mem < (HDW *) ((uintptr_t)memmap + 1); > > > ++mem) > > > > Note that these two lines are

Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-26 Thread Xie He
On Mon, Oct 26, 2020 at 8:56 PM Xie He wrote: > > > - for (mem = (HDW *) memmap; mem < (HDW *) (memmap + 1); ++mem) > > + for (mem = (HDW *) memmap; mem < (HDW *) ((uintptr_t)memmap + 1); ++mem) > > Note that these two lines are semantically different. In the first line, > "+ 1" moves the pointe

Re: [PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-26 Thread Xie He
> - for (mem = (HDW *) memmap; mem < (HDW *) (memmap + 1); ++mem) > + for (mem = (HDW *) memmap; mem < (HDW *) ((uintptr_t)memmap + 1); ++mem) Note that these two lines are semantically different. In the first line, "+ 1" moves the pointer by (sizeof memmap) bytes. However in the second line, "+

[PATCH net-next 01/11] atm: horizon: shut up clang null pointer arithmetic warning

2020-10-26 Thread Arnd Bergmann
From: Arnd Bergmann Building a "W=1" kernel with clang produces a warning about suspicous pointer arithmetic: drivers/atm/horizon.c:1844:52: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic] for (mem = (HDW *) memmap; mem < (HDW *) (mem