lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 13 Sep 2021 11:53:25 -0700
From:   Nathan Chancellor <nathan@...nel.org>
To:     Jason Gunthorpe <jgg@...dia.com>
Cc:     Nick Desaulniers <ndesaulniers@...gle.com>,
        kernel test robot <lkp@...el.com>, llvm@...ts.linux.dev,
        kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        clang-built-linux@...glegroups.com
Subject: Re: drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error:
 static_assert expression is not an integral constant expression

On Mon, Sep 13, 2021 at 03:38:13PM -0300, Jason Gunthorpe wrote:
> On Mon, Sep 13, 2021 at 10:00:02AM -0700, Nick Desaulniers wrote:
> 
> > > This macro would like to know that the passed in member name has a u64
> > > type, all the things I've come up with fail on clang - but many work
> > > fine on gcc. Frankly I think this case is a clang bug myself..
> > 
> > Perhaps, though this assertion looks a bit like offsetof() to me. I
> > wonder if that can help here?
> 
> The assertion would logically like to be this:
> 
>          static_assert(typecheck(((struct qib_port *)0)->N, u64))

This works for me with both GCC and clang, if that is acceptable to you?
It fails if you change one of the variables to 'u32'.

Cheers,
Nathan

diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c
index 452e2355d24e..0a3b28142c05 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 =                                                     \

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ