* [PATCH 1/3] bcache: do not assign in if condition register_bcache()
2018-06-18 10:08 [PATCH 0/3] bcache: Fix variable assignment in if condition in super.c Florian Schmaus
@ 2018-06-18 10:09 ` Florian Schmaus
2018-06-18 13:44 ` Coly Li
2018-06-18 10:09 ` [PATCH 2/3] bcache: do not assign in if condition in bcache_init() Florian Schmaus
2018-06-18 10:09 ` [PATCH 3/3] bcache: do not assign in if condition in bcache_device_init() Florian Schmaus
2 siblings, 1 reply; 7+ messages in thread
From: Florian Schmaus @ 2018-06-18 10:09 UTC (permalink / raw)
To: Coly Li, Kent Overstreet, linux-bcache; +Cc: Florian Schmaus, linux-kernel
Fixes an error condition reported by checkpatch.pl which is caused by
assigning a variable in an if condition.
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
---
drivers/md/bcache/super.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index fa4058e43202..db7177d422e5 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2163,8 +2163,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
if (!try_module_get(THIS_MODULE))
return -EBUSY;
- if (!(path = kstrndup(buffer, size, GFP_KERNEL)) ||
- !(sb = kmalloc(sizeof(struct cache_sb), GFP_KERNEL)))
+ path = kstrndup(buffer, size, GFP_KERNEL);
+ if (!path)
+ goto err;
+
+ sb = kmalloc(sizeof(struct cache_sb), GFP_KERNEL);
+ if (!sb)
goto err;
err = "failed to open device";
--
2.16.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] bcache: do not assign in if condition register_bcache()
2018-06-18 10:09 ` [PATCH 1/3] bcache: do not assign in if condition register_bcache() Florian Schmaus
@ 2018-06-18 13:44 ` Coly Li
0 siblings, 0 replies; 7+ messages in thread
From: Coly Li @ 2018-06-18 13:44 UTC (permalink / raw)
To: Florian Schmaus, Kent Overstreet, linux-bcache; +Cc: linux-kernel
On 2018/6/18 6:09 PM, Florian Schmaus wrote:
> Fixes an error condition reported by checkpatch.pl which is caused by
> assigning a variable in an if condition.
>
> Signed-off-by: Florian Schmaus <flo@geekplace.eu>
Signed-off-by: Coly Li <colyli@suse.de>
Added into for-next patch set.
Thanks.
Coly Li
> ---
> drivers/md/bcache/super.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index fa4058e43202..db7177d422e5 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -2163,8 +2163,12 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> if (!try_module_get(THIS_MODULE))
> return -EBUSY;
>
> - if (!(path = kstrndup(buffer, size, GFP_KERNEL)) ||
> - !(sb = kmalloc(sizeof(struct cache_sb), GFP_KERNEL)))
> + path = kstrndup(buffer, size, GFP_KERNEL);
> + if (!path)
> + goto err;
> +
> + sb = kmalloc(sizeof(struct cache_sb), GFP_KERNEL);
> + if (!sb)
> goto err;
>
> err = "failed to open device";
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] bcache: do not assign in if condition in bcache_init()
2018-06-18 10:08 [PATCH 0/3] bcache: Fix variable assignment in if condition in super.c Florian Schmaus
2018-06-18 10:09 ` [PATCH 1/3] bcache: do not assign in if condition register_bcache() Florian Schmaus
@ 2018-06-18 10:09 ` Florian Schmaus
2018-06-18 13:44 ` Coly Li
2018-06-18 10:09 ` [PATCH 3/3] bcache: do not assign in if condition in bcache_device_init() Florian Schmaus
2 siblings, 1 reply; 7+ messages in thread
From: Florian Schmaus @ 2018-06-18 10:09 UTC (permalink / raw)
To: Coly Li, Kent Overstreet, linux-bcache; +Cc: Florian Schmaus, linux-kernel
Fixes an error condition reported by checkpatch.pl which is caused by
assigning a variable in an if condition.
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
---
drivers/md/bcache/super.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index db7177d422e5..f09f4f046315 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2328,9 +2328,15 @@ static int __init bcache_init(void)
return bcache_major;
}
- if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
- !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
- bch_request_init() ||
+ bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0);
+ if (!bcache_wq)
+ goto err;
+
+ bcache_kobj = kobject_create_and_add("bcache", fs_kobj);
+ if (!bcache_kobj)
+ goto err;
+
+ if (bch_request_init() ||
bch_debug_init(bcache_kobj) || closure_debug_init() ||
sysfs_create_files(bcache_kobj, files))
goto err;
--
2.16.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 2/3] bcache: do not assign in if condition in bcache_init()
2018-06-18 10:09 ` [PATCH 2/3] bcache: do not assign in if condition in bcache_init() Florian Schmaus
@ 2018-06-18 13:44 ` Coly Li
0 siblings, 0 replies; 7+ messages in thread
From: Coly Li @ 2018-06-18 13:44 UTC (permalink / raw)
To: Florian Schmaus, Kent Overstreet, linux-bcache; +Cc: linux-kernel
On 2018/6/18 6:09 PM, Florian Schmaus wrote:
> Fixes an error condition reported by checkpatch.pl which is caused by
> assigning a variable in an if condition.
>
> Signed-off-by: Florian Schmaus <flo@geekplace.eu>
Signed-off-by: Coly Li <colyli@suse.de>
Added into for-next patch set.
Thanks.
Coly Li
> ---
> drivers/md/bcache/super.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index db7177d422e5..f09f4f046315 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -2328,9 +2328,15 @@ static int __init bcache_init(void)
> return bcache_major;
> }
>
> - if (!(bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0)) ||
> - !(bcache_kobj = kobject_create_and_add("bcache", fs_kobj)) ||
> - bch_request_init() ||
> + bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0);
> + if (!bcache_wq)
> + goto err;
> +
> + bcache_kobj = kobject_create_and_add("bcache", fs_kobj);
> + if (!bcache_kobj)
> + goto err;
> +
> + if (bch_request_init() ||
> bch_debug_init(bcache_kobj) || closure_debug_init() ||
> sysfs_create_files(bcache_kobj, files))
> goto err;
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] bcache: do not assign in if condition in bcache_device_init()
2018-06-18 10:08 [PATCH 0/3] bcache: Fix variable assignment in if condition in super.c Florian Schmaus
2018-06-18 10:09 ` [PATCH 1/3] bcache: do not assign in if condition register_bcache() Florian Schmaus
2018-06-18 10:09 ` [PATCH 2/3] bcache: do not assign in if condition in bcache_init() Florian Schmaus
@ 2018-06-18 10:09 ` Florian Schmaus
2018-06-18 13:45 ` Coly Li
2 siblings, 1 reply; 7+ messages in thread
From: Florian Schmaus @ 2018-06-18 10:09 UTC (permalink / raw)
To: Coly Li, Kent Overstreet, linux-bcache; +Cc: Florian Schmaus, linux-kernel
Fixes an error condition reported by checkpatch.pl which is caused by
assigning a variable in an if condition.
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
---
drivers/md/bcache/super.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f09f4f046315..4a2a028c8754 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -796,11 +796,12 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
return idx;
if (bioset_init(&d->bio_split, 4, offsetof(struct bbio, bio),
- BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER) ||
- !(d->disk = alloc_disk(BCACHE_MINORS))) {
- ida_simple_remove(&bcache_device_idx, idx);
- return -ENOMEM;
- }
+ BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER))
+ goto err;
+
+ d->disk = alloc_disk(BCACHE_MINORS);
+ if (!d->disk)
+ goto err;
set_capacity(d->disk, sectors);
snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", idx);
@@ -834,6 +835,11 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
blk_queue_write_cache(q, true, true);
return 0;
+
+err:
+ ida_simple_remove(&bcache_device_idx, idx);
+ return -ENOMEM;
+
}
/* Cached device */
--
2.16.4
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 3/3] bcache: do not assign in if condition in bcache_device_init()
2018-06-18 10:09 ` [PATCH 3/3] bcache: do not assign in if condition in bcache_device_init() Florian Schmaus
@ 2018-06-18 13:45 ` Coly Li
0 siblings, 0 replies; 7+ messages in thread
From: Coly Li @ 2018-06-18 13:45 UTC (permalink / raw)
To: Florian Schmaus, Kent Overstreet, linux-bcache; +Cc: linux-kernel
On 2018/6/18 6:09 PM, Florian Schmaus wrote:
> Fixes an error condition reported by checkpatch.pl which is caused by
> assigning a variable in an if condition.
>
> Signed-off-by: Florian Schmaus <flo@geekplace.eu>
> ---
> drivers/md/bcache/super.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index f09f4f046315..4a2a028c8754 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -796,11 +796,12 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
> return idx;
>
> if (bioset_init(&d->bio_split, 4, offsetof(struct bbio, bio),
> - BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER) ||
> - !(d->disk = alloc_disk(BCACHE_MINORS))) {
> - ida_simple_remove(&bcache_device_idx, idx);
> - return -ENOMEM;
> - }
> + BIOSET_NEED_BVECS|BIOSET_NEED_RESCUER))
Signed-off-by: Coly Li <colyli@suse.de>
I fix the above indent and added the patch into for-next patch set. Thanks.
Coly Li
> + goto err;
> +
> + d->disk = alloc_disk(BCACHE_MINORS);
> + if (!d->disk)
> + goto err;
>
> set_capacity(d->disk, sectors);
> snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", idx);
> @@ -834,6 +835,11 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
> blk_queue_write_cache(q, true, true);
>
> return 0;
> +
> +err:
> + ida_simple_remove(&bcache_device_idx, idx);
> + return -ENOMEM;
> +
> }
>
> /* Cached device */
>
^ permalink raw reply [flat|nested] 7+ messages in thread