All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bcache: Use #ifdef instead of boolean variable
@ 2020-10-09 18:34 Alex Dewar
  2020-10-09 19:14   ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Alex Dewar @ 2020-10-09 18:34 UTC (permalink / raw)
  Cc: Alex Dewar, Coly Li, Kent Overstreet, linux-bcache, linux-kernel

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)
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
 
 	ret = -EBUSY;
 	err = "failed to reference bcache module";
@@ -2563,26 +2558,25 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
 
 	err = "failed to register device";
 
-	if (async_registration) {
-		/* register in asynchronous way */
-		struct async_reg_args *args =
-			kzalloc(sizeof(struct async_reg_args), GFP_KERNEL);
-
-		if (!args) {
-			ret = -ENOMEM;
-			err = "cannot allocate memory";
-			goto out_put_sb_page;
-		}
+#ifdef CONFIG_BCACHE_ASYNC_REGISTRATION
+	/* register in asynchronous way */
+	struct async_reg_args *args =
+		kzalloc(sizeof(struct async_reg_args), GFP_KERNEL);
 
-		args->path	= path;
-		args->sb	= sb;
-		args->sb_disk	= sb_disk;
-		args->bdev	= bdev;
-		register_device_aync(args);
-		/* No wait and returns to user space */
-		goto async_done;
+	if (!args) {
+		ret = -ENOMEM;
+		err = "cannot allocate memory";
+		goto out_put_sb_page;
 	}
 
+	args->path	= path;
+	args->sb	= sb;
+	args->sb_disk	= sb_disk;
+	args->bdev	= bdev;
+	register_device_aync(args);
+	/* No wait and returns to user space */
+	return size;
+#else
 	if (SB_IS_BDEV(sb)) {
 		struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
 
@@ -2605,12 +2599,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
 		if (register_cache(sb, sb_disk, bdev, ca) != 0)
 			goto out_free_sb;
 	}
+#endif
 
 done:
 	kfree(sb);
 	kfree(path);
 	module_put(THIS_MODULE);
-async_done:
 	return size;
 
 out_put_sb_page:
-- 
2.28.0


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

end of thread, other threads:[~2020-10-10 11:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2020-10-10  8:23     ` Alex Dewar

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.