lkml.org 
[lkml]   [2021]   [Sep]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] IB/qib: Fix null pointer subtraction compiler warning
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@intel.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> Acked-by: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>
> ---
> drivers/infiniband/hw/qib/qib_sysfs.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to for-rc

Jason

\
 
 \ /
  Last update: 2021-09-08 13:45    [W:0.778 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site