* [PATCH rc] IB/qib: Fix clang confusion of NULL pointer comparison
@ 2021-09-14 19:01 Jason Gunthorpe
2021-09-14 19:18 ` Nick Desaulniers
0 siblings, 1 reply; 2+ messages in thread
From: Jason Gunthorpe @ 2021-09-14 19:01 UTC (permalink / raw)
To: linux-rdma; +Cc: Nick Desaulniers
clang becomes confused due to the comparision to NULL in a contexpr context:
>> drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression
QIB_DIAGC_ATTR(rc_resends);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/infiniband/hw/qib/qib_sysfs.c:406:16: note: expanded from macro 'QIB_DIAGC_ATTR'
static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \
Nick found __same_type that solves this problem nicely, so use it instead.
Reported-by: kernel test robot <lkp@intel.com>
Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
drivers/infiniband/hw/qib/qib_sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Hopefully third time is the charm here..
diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
index 452e2355d24eeb..0a3b28142c05b6 100644
--- a/drivers/infiniband/hw/qib/qib_sysfs.c
+++ b/drivers/infiniband/hw/qib/qib_sysfs.c
@@ -403,7 +403,7 @@ static ssize_t diagc_attr_store(struct ib_device *ibdev, u32 port_num,
}
#define QIB_DIAGC_ATTR(N) \
- static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \
+ static_assert(__same_type(((struct qib_ibport *)0)->rvp.n_##N, u64)); \
static struct qib_diagc_attr qib_diagc_attr_##N = { \
.attr = __ATTR(N, 0664, diagc_attr_show, diagc_attr_store), \
.counter = \
base-commit: 6880fa6c56601bb8ed59df6c30fd390cc5f6dd8f
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH rc] IB/qib: Fix clang confusion of NULL pointer comparison
2021-09-14 19:01 [PATCH rc] IB/qib: Fix clang confusion of NULL pointer comparison Jason Gunthorpe
@ 2021-09-14 19:18 ` Nick Desaulniers
0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2021-09-14 19:18 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: linux-rdma, Nathan Chancellor, llvm
On Tue, Sep 14, 2021 at 12:01 PM Jason Gunthorpe <jgg@nvidia.com> wrote:
>
> clang becomes confused due to the comparision to NULL in a contexpr context:
s/comparision/comparison/
s/contexpr/Integer Constant Expression/
I don't think constexpr is the equivalent to an ICE. We know what you
mean though. :^)
>
> >> drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression
> QIB_DIAGC_ATTR(rc_resends);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/infiniband/hw/qib/qib_sysfs.c:406:16: note: expanded from macro 'QIB_DIAGC_ATTR'
> static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \
>
> Nick found __same_type that solves this problem nicely, so use it instead.
Sorry, Nathan found that. Should be:
Suggested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Thanks for the patch.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Suggested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/infiniband/hw/qib/qib_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Hopefully third time is the charm here..
:^)
>
> diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
> index 452e2355d24eeb..0a3b28142c05b6 100644
> --- a/drivers/infiniband/hw/qib/qib_sysfs.c
> +++ b/drivers/infiniband/hw/qib/qib_sysfs.c
Consider explicitly including <linux/compiler_types.h> in this
translation unit. I know it may compile today, and it might just be
our internal style guide talking here...
> @@ -403,7 +403,7 @@ static ssize_t diagc_attr_store(struct ib_device *ibdev, u32 port_num,
> }
>
> #define QIB_DIAGC_ATTR(N) \
> - static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \
> + static_assert(__same_type(((struct qib_ibport *)0)->rvp.n_##N, u64)); \
> static struct qib_diagc_attr qib_diagc_attr_##N = { \
> .attr = __ATTR(N, 0664, diagc_attr_show, diagc_attr_store), \
> .counter = \
>
> base-commit: 6880fa6c56601bb8ed59df6c30fd390cc5f6dd8f
> --
> 2.33.0
>
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-14 19:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14 19:01 [PATCH rc] IB/qib: Fix clang confusion of NULL pointer comparison Jason Gunthorpe
2021-09-14 19:18 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).