Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1572232

Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT()
Date 2017-02-02 11:00 +0100
Message-ID <t6mlk-2a2-7@gated-at.bofh.it> (permalink)
References <t66qg-8ov-67@gated-at.bofh.it> <t6ktc-VZ-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] staging: lustre: shut up clang warnings on CLASSERT() Arnd Bergmann <arnd@arndb.de> - 2017-02-01 18:00 +0100
  Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT() "Dilger, Andreas" <andreas.dilger@intel.com> - 2017-02-02 09:00 +0100
    Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-02 11:00 +0100
      Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Arnd Bergmann <arnd@arndb.de> - 2017-02-02 11:50 +0100
        Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-02-02 11:50 +0100
          Re: [PATCH] staging: lustre: shut up clang warnings on CLASSERT() Arnd Bergmann <arnd@arndb.de> - 2017-02-02 12:30 +0100

csiph-web