public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
@ 2017-02-01 16:52 Arnd Bergmann
  2017-02-02  7:50 ` Dilger, Andreas
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2017-02-01 16:52 UTC (permalink / raw)
  To: Oleg Drokin, Andreas Dilger, James Simmons, Greg Kroah-Hartman
  Cc: Arnd Bergmann, John L. Hammond, Dmitry Eremin, Kirill A. Shutemov,
	lustre-devel, devel, linux-kernel

lustre uses a fake switch() statement as a compile-time assert, but unfortunately
each use of that causes a warning when building with clang:

drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42'
drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT'
 #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)

Adding a 'default:' label in there shuts up the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index aab15d8112a4..2d5435029185 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -291,7 +291,7 @@ do {							    \
  *       value  after  conversion...
  *
  */
-#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
+#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0)
 
 /* max value for numeric network address */
 #define MAX_NUMERIC_VALUE 0xffffffff
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
  2017-02-01 16:52 [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Arnd Bergmann
@ 2017-02-02  7:50 ` Dilger, Andreas
  2017-02-02  9:54   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Dilger, Andreas @ 2017-02-02  7:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, Eremin, Dmitry,
	Lustre Development List, devel@driverdev.osuosl.org, LKML

On Feb 1, 2017, at 09:52, Arnd Bergmann <arnd@arndb.de> wrote:
> 
> lustre uses a fake switch() statement as a compile-time assert, but unfortunately
> each use of that causes a warning when building with clang:
> 
> drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42'
> drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT'
> #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
> 
> Adding a 'default:' label in there shuts up the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>

> ---
> drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> index aab15d8112a4..2d5435029185 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> @@ -291,7 +291,7 @@ do {							    \
>  *       value  after  conversion...
>  *
>  */
> -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
> +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0)
> 
> /* max value for numeric network address */
> #define MAX_NUMERIC_VALUE 0xffffffff
> -- 
> 2.9.0
> 

Cheers, Andreas
--
Andreas Dilger
Lustre Principal Architect
Intel Corporation

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
  2017-02-02  7:50 ` Dilger, Andreas
@ 2017-02-02  9:54   ` Greg Kroah-Hartman
  2017-02-02 10:40     ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2017-02-02  9:54 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: Arnd Bergmann, Drokin, Oleg, James Simmons, Eremin, Dmitry,
	Lustre Development List, devel@driverdev.osuosl.org, LKML

On Thu, Feb 02, 2017 at 07:50:24AM +0000, Dilger, Andreas wrote:
> On Feb 1, 2017, at 09:52, Arnd Bergmann <arnd@arndb.de> wrote:
> > 
> > lustre uses a fake switch() statement as a compile-time assert, but unfortunately
> > each use of that causes a warning when building with clang:
> > 
> > drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c:2907:2: warning: no case matching constant switch condition '42'
> > drivers/staging/lustre/lnet/klnds/socklnd/../../../include/linux/libcfs/libcfs_private.h:294:36: note: expanded from macro 'CLASSERT'
> > #define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
> > 
> > Adding a 'default:' label in there shuts up the warning.
> > 
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
> 
> > ---
> > drivers/staging/lustre/include/linux/libcfs/libcfs_private.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> > index aab15d8112a4..2d5435029185 100644
> > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> > @@ -291,7 +291,7 @@ do {							    \
> >  *       value  after  conversion...
> >  *
> >  */
> > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
> > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0)

Ugh, why not just use the in-kernel ASSERT macro instead?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
  2017-02-02  9:54   ` Greg Kroah-Hartman
@ 2017-02-02 10:40     ` Arnd Bergmann
  2017-02-02 10:43       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2017-02-02 10:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Dilger, Andreas, Drokin, Oleg, James Simmons, Eremin, Dmitry,
	Lustre Development List, devel@driverdev.osuosl.org, LKML

On Thu, Feb 2, 2017 at 10:54 AM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
>> > index aab15d8112a4..2d5435029185 100644
>> > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
>> > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
>> > @@ -291,7 +291,7 @@ do {                                                        \
>> >  *       value  after  conversion...
>> >  *
>> >  */
>> > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
>> > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0)
>
> Ugh, why not just use the in-kernel ASSERT macro instead?

We don't have one ;-)

I've done a semi-automated patch to replace CLASSERT() with the respective
BUILD_BUG_ON() now, but that patch is quite large.

    Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
  2017-02-02 10:40     ` Arnd Bergmann
@ 2017-02-02 10:43       ` Greg Kroah-Hartman
  2017-02-02 11:22         ` Arnd Bergmann
  0 siblings, 1 reply; 6+ messages in thread
From: Greg Kroah-Hartman @ 2017-02-02 10:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Dilger, Andreas, Drokin, Oleg, James Simmons, Eremin, Dmitry,
	Lustre Development List, devel@driverdev.osuosl.org, LKML

On Thu, Feb 02, 2017 at 11:40:32AM +0100, Arnd Bergmann wrote:
> On Thu, Feb 2, 2017 at 10:54 AM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> >> > index aab15d8112a4..2d5435029185 100644
> >> > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> >> > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
> >> > @@ -291,7 +291,7 @@ do {                                                        \
> >> >  *       value  after  conversion...
> >> >  *
> >> >  */
> >> > -#define CLASSERT(cond) do {switch (42) {case (cond): case 0: break; } } while (0)
> >> > +#define CLASSERT(cond) do {switch (42) {case (cond): case 0: default: break; } } while (0)
> >
> > Ugh, why not just use the in-kernel ASSERT macro instead?
> 
> We don't have one ;-)

Oh nice!

> I've done a semi-automated patch to replace CLASSERT() with the respective
> BUILD_BUG_ON() now, but that patch is quite large.

Should be easy to script, I missed that this was a build-time check.
Heck, I'll take a script to do this, or I can just do it in my end.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
  2017-02-02 10:43       ` Greg Kroah-Hartman
@ 2017-02-02 11:22         ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2017-02-02 11:22 UTC (permalink / raw)
  To: gregkh
  Cc: Drokin, Oleg, Dilger, Andreas, devel@driverdev.osuosl.org,
	Eremin, Dmitry, LKML, James Simmons, Lustre Development List

On Feb 2, 2017 11:43 AM, "Greg Kroah-Hartman"
<gregkh@linuxfoundation.org> wrote:
> On Thu, Feb 02, 2017 at 11:40:32AM +0100, Arnd Bergmann wrote:
> > I've done a semi-automated patch to replace CLASSERT() with the respective
> > BUILD_BUG_ON() now, but that patch is quite large.
>
> Should be easy to script, I missed that this was a build-time check.
> Heck, I'll take a script to do this, or I can just do it in my end

My patch has been through a couple of randconfig and allmodconfig builds now,
should be good. If it's wrong, it will at least blow up at compile time.

    Arnd

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-02 11:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-01 16:52 [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Arnd Bergmann
2017-02-02  7:50 ` Dilger, Andreas
2017-02-02  9:54   ` Greg Kroah-Hartman
2017-02-02 10:40     ` Arnd Bergmann
2017-02-02 10:43       ` Greg Kroah-Hartman
2017-02-02 11:22         ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox