All of lore.kernel.org
 help / color / mirror / Atom feed
From: Coly Li <colyli@suse.de>
To: Rasmus Villemoes <rasmus.villemoes@prevas.dk>,
	Alex Dewar <alex.dewar90@gmail.com>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bcache: Use #ifdef instead of boolean variable
Date: Sat, 10 Oct 2020 10:05:22 +0800	[thread overview]
Message-ID: <64db3f27-5904-8857-349e-e50d612932fb@suse.de> (raw)
In-Reply-To: <b37a5dd2-437d-65e3-f432-a5247d09d94a@prevas.dk>

On 2020/10/10 07:00, Rasmus Villemoes wrote:
> On 09/10/2020 20.34, Alex Dewar wrote:
>> The variable async_registration is used to indicate whether or not
>> CONFIG_BCACHE_ASYNC_REGISTRATION is enabled, triggering a (false)
>> warning in Coverity about unreachable code. However, it seems clearer in
>> this case just to use an #ifdef, so let's do that instead.
>>
>> Addresses-Coverity-ID: 1497746: Control flow issues (DEADCODE)
> 
> I think that coverity check needs to be ignored. The kernel is full of
> things that are supposed to be eliminated by the compiler, but still
> checked for valid syntax etc. Often it's even more hidden than this,
> something like
> 
> // some header
> #ifdef CONFIG_FOO
> int foo(void);
> #else
> static inline int foo(void) { return 0; }
> #endif
> 
> // code
> 
>   if (foo()) { ... // this goes away for CONFIG_FOO=n }
> 
>> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
>> ---
>>  drivers/md/bcache/super.c | 40 +++++++++++++++++----------------------
>>  1 file changed, 17 insertions(+), 23 deletions(-)
>>
>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>> index 46a00134a36a..6d4127881c6a 100644
>> --- a/drivers/md/bcache/super.c
>> +++ b/drivers/md/bcache/super.c
>> @@ -2504,11 +2504,6 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>>  	struct cache_sb_disk *sb_disk;
>>  	struct block_device *bdev;
>>  	ssize_t ret;
>> -	bool async_registration = false;
>> -
>> -#ifdef CONFIG_BCACHE_ASYNC_REGISTRATION
>> -	async_registration = true;
>> -#endif
> 
> If anything, this should simply be changed to
> 
>   bool async_registration = IS_ENABLED(CONFIG_BCACHE_ASYNC_REGISTRATION);
> 
> Rasmus

Hi Rasmus,

Yes, the above change might be better. But I don't suggest to spent
effort on this.

Hi Alex,

Indeed the code in v5.9 is quite similar to what your patch makes, and I
change it in this shape in v5.10 series. This piece of code may stay in
kernel for 2 or 3 versions at most, the purpose is to make it convenient
for people to test the async registration in production environment.
Once the new async registration behavior is verified to not break any
existing thing (which we don't know) it will be the (only) default
behavior and the CONFIG_BCACHE_ASYNC_REGISTRATION check will be removed.

Thank you all for looking at this.

Coly Li

  reply	other threads:[~2020-10-10  2:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 18:34 [PATCH] bcache: Use #ifdef instead of boolean variable Alex Dewar
2020-10-09 19:14 ` kernel test robot
2020-10-09 19:14   ` kernel test robot
2020-10-09 22:39 ` kernel test robot
2020-10-09 22:39   ` kernel test robot
2020-10-09 23:00 ` Rasmus Villemoes
2020-10-10  2:05   ` Coly Li [this message]
2020-10-10  8:23     ` Alex Dewar

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=64db3f27-5904-8857-349e-e50d612932fb@suse.de \
    --to=colyli@suse.de \
    --cc=alex.dewar90@gmail.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rasmus.villemoes@prevas.dk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.