Re: [PATCH] IB/qib: Fix null pointer subtraction compiler warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Sep 03, 2021 at 10:07:28AM -0300, Jason Gunthorpe wrote:
> >> drivers/infiniband/hw/qib/qib_sysfs.c:411:1: warning: performing pointer subtraction with a null pointer has undefined behavior
> +[-Wnull-pointer-subtraction]
>    QIB_DIAGC_ATTR(rc_resends);
>    ^~~~~~~~~~~~~~~~~~~~~~~~~~
>    drivers/infiniband/hw/qib/qib_sysfs.c:408:51: note: expanded from macro 'QIB_DIAGC_ATTR'
>                    .counter = &((struct qib_ibport *)0)->rvp.n_##N - (u64 *)0,    \
> 
> Use offsetof and accomplish the type check using static_assert.
> 
> Fixes: 4a7aaf88c89f ("RDMA/qib: Use attributes for the port sysfs")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Acked-by: Dennis Dalessandro <dennis.dalessandro@xxxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/infiniband/hw/qib/qib_sysfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied to for-rc

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux