[PATCH v5 2/8] md: changed the switch of RAID_VERSION to if

linan666@huaweicloud.com posted 8 patches 1 year, 10 months ago
There is a newer version of this series
[PATCH v5 2/8] md: changed the switch of RAID_VERSION to if
Posted by linan666@huaweicloud.com 1 year, 10 months ago
From: Li Nan <linan122@huawei.com>

There is only one case of this 'switch'. Change it to 'if'.

Signed-off-by: Li Nan <linan122@huawei.com>
---
 drivers/md/md.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 1b509fb82040..3b4e0ef49675 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7636,11 +7636,9 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
 	 * Commands dealing with the RAID driver but not any
 	 * particular array:
 	 */
-	switch (cmd) {
-	case RAID_VERSION:
+	if (cmd == RAID_VERSION) {
 		err = get_version(argp);
 		goto out;
-	default:;
 	}
 
 	/*
-- 
2.39.2
Re: [PATCH v5 2/8] md: changed the switch of RAID_VERSION to if
Posted by Yu Kuai 1 year, 10 months ago
Hi,

在 2024/02/01 14:33, linan666@huaweicloud.com 写道:
> From: Li Nan <linan122@huawei.com>
> 
> There is only one case of this 'switch'. Change it to 'if'.
> 
> Signed-off-by: Li Nan <linan122@huawei.com>
> ---
>   drivers/md/md.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 1b509fb82040..3b4e0ef49675 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -7636,11 +7636,9 @@ static int md_ioctl(struct block_device *bdev, blk_mode_t mode,
>   	 * Commands dealing with the RAID driver but not any
>   	 * particular array:
>   	 */
> -	switch (cmd) {
> -	case RAID_VERSION:
> +	if (cmd == RAID_VERSION) {
>   		err = get_version(argp);
>   		goto out;

you can just return here;

if (cmd == RAID_VERSION)
	return get_version(argp);

Thanks,
Kuai

> -	default:;
>   	}
>   
>   	/*
>