linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Gao Xiang <gaoxiang25@huawei.com>,
	Aaron Strahlberger <aaron.strahlberger@posteo.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Chao Yu <yuchao0@huawei.com>,
	linux-erofs@lists.ozlabs.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, linux-kernel@i4.cs.fau.de,
	Julius Wiedmann <julius.wiedmann@fau.de>,
	Dominik Huber <domi250@gmx.de>
Subject: Re: [PATCH 4/5] drivers: staging: erofs: Fix parentheses error in macro
Date: Tue, 11 Dec 2018 07:48:58 -0800	[thread overview]
Message-ID: <df69ac6826a2ec20e29d1ded7a8e7ec63c73c2c4.camel@perches.com> (raw)
In-Reply-To: <dc56553c-a5ea-5265-5820-4bb481b0b948@huawei.com>

On Tue, 2018-12-11 at 19:06 +0800, Gao Xiang wrote:
> Hi Aaron,
> 
> On 2018/12/11 18:54, Aaron Strahlberger wrote:
> > Fix of ERROR: Macros with complex values should be enclosed in parentheses
> > from checkpatch.pl
[]
> > diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h
[]
> > @@ -38,9 +38,9 @@ struct erofs_super_block {
> >  /* 80 */__u8 reserved2[48];     /* 128 bytes */
> >  } __packed;
> >  
> > -#define __EROFS_BIT(_prefix, _cur, _pre)	enum {	\
> > +#define __EROFS_BIT(_prefix, _cur, _pre)	(enum { \
> >  	_prefix ## _cur ## _BIT = _prefix ## _pre ## _BIT + \
> > -		_prefix ## _pre ## _BITS }
> > +	_prefix ## _pre ## _BITS })
> 
> It seems not the valid C, here is the compiler error:
> 
> ...
> 
> In file included from drivers/staging/erofs/internal.h:25:0,
>                  from drivers/staging/erofs/xattr.h:16,
>                  from drivers/staging/erofs/xattr.c:14:
> drivers/staging/erofs/erofs_fs.h:41:43: error: expected identifier or ‘(’ before ‘enum’
>  #define __EROFS_BIT(_prefix, _cur, _pre) (enum { \
>                                            ^
> drivers/staging/erofs/erofs_fs.h:65:1: note: in expansion of macro ‘__EROFS_BIT’
>  __EROFS_BIT(EROFS_I_, DATA_MAPPING, VERSION);
>  ^~~~~~~~~~~
> make[3]: *** [scripts/Makefile.build:292: drivers/staging/erofs/xattr.o] Error 1
> 
> ...
> 
> 
> the __EROFS_BIT marco is used to define yyy_BIT according to xxx_BIT + xxx_BITS for cascade, eg.
> 
> __EROFS_BIT(EROFS_I_, DATA_MAPPING, VERSION);
> it will defines EROFS_I_DATA_MAPPING_BIT = EROFS_I_VERSION_BIT + EROFS_I_VERSION_BITS;
> 
> __EROFS_BIT(EROFS_I_, FEATURE2, DATA_MAPPING);
> it will defines EROFS_I_FEATURE2_BIT = EROFS_I_DATA_MAPPING_BIT + EROFS_I_DATA_MAPPING_BITS;

This macro is used only once and is merely obfuscation
for that one use.  Please remove the macro and expand
it in the one place it is used.



  reply	other threads:[~2018-12-11 15:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11  9:06 [PATCH] drivers: staging: erofs: Fix styling issues Aaron Strahlberger
2018-12-11  9:18 ` Gao Xiang
2018-12-11 10:54   ` [PATCH 0/5] " Aaron Strahlberger
2018-12-11 10:54     ` [PATCH 1/5] drivers: staging: erofs: Fix alignment Aaron Strahlberger
2018-12-11 11:19       ` Gao Xiang
2018-12-11 13:00       ` Dan Carpenter
2018-12-11 10:54     ` [PATCH 2/5] drivers: staging: erofs: Fix comparison to NULL issues Aaron Strahlberger
2018-12-11 11:22       ` Gao Xiang
2018-12-11 10:54     ` [PATCH 3/5] drivers: staging: erofs: Fix spelling issue Aaron Strahlberger
2018-12-11 11:27       ` Gao Xiang
2018-12-11 10:54     ` [PATCH 4/5] drivers: staging: erofs: Fix parentheses error in macro Aaron Strahlberger
2018-12-11 11:06       ` Gao Xiang
2018-12-11 15:48         ` Joe Perches [this message]
2018-12-11 17:05           ` Gao Xiang
2018-12-12 12:02             ` [PATCH v2] staging:erofs: Remove __EROFS_BIT macro Aaron Strahlberger
2018-12-12 12:18               ` Gao Xiang
2018-12-11 10:54     ` [PATCH 5/5] drivers: staging: erofs: Add blank line after function Aaron Strahlberger
2018-12-12 12:00   ` [PATCH v2] staging:erofs: Fix alignment issues Aaron Strahlberger
2018-12-12 12:11     ` Gao Xiang
2018-12-12 12:29       ` Gao Xiang
2018-12-11 12:51 ` [PATCH] drivers: staging: erofs: Fix styling issues Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df69ac6826a2ec20e29d1ded7a8e7ec63c73c2c4.camel@perches.com \
    --to=joe@perches.com \
    --cc=aaron.strahlberger@posteo.de \
    --cc=devel@driverdev.osuosl.org \
    --cc=domi250@gmx.de \
    --cc=gaoxiang25@huawei.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=julius.wiedmann@fau.de \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@i4.cs.fau.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).