* [PATCH] nvme/auth: optimize code redundancy and provide code quality
@ 2024-01-15 6:52 mengfanhui
2024-01-15 12:51 ` Sagi Grimberg
0 siblings, 1 reply; 3+ messages in thread
From: mengfanhui @ 2024-01-15 6:52 UTC (permalink / raw)
To: kbusch, axboe; +Cc: mengfanhui, linux-kernel, linux-nvme, sagi
Improve code quality. Reduce code redundancy.
Signed-off-by: mengfanhui <mengfanhui@kylinos.cn>
---
drivers/nvme/common/auth.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c
index a23ab5c968b9..4f9d06afdc38 100644
--- a/drivers/nvme/common/auth.c
+++ b/drivers/nvme/common/auth.c
@@ -250,9 +250,7 @@ struct nvme_dhchap_key *nvme_auth_transform_key(
if (key->hash == 0) {
key_len = nvme_auth_key_struct_size(key->len);
transformed_key = kmemdup(key, key_len, GFP_KERNEL);
- if (!transformed_key)
- return ERR_PTR(-ENOMEM);
- return transformed_key;
+ return transformed_key ? transformed_key : ERR_PTR(-ENOMEM);
}
hmac_name = nvme_auth_hmac_name(key->hash);
if (!hmac_name) {
base-commit: c29901006179c4c87f9335771e50814ec5707239
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme/auth: optimize code redundancy and provide code quality
2024-01-15 6:52 [PATCH] nvme/auth: optimize code redundancy and provide code quality mengfanhui
@ 2024-01-15 12:51 ` Sagi Grimberg
2024-01-15 22:21 ` Chaitanya Kulkarni
0 siblings, 1 reply; 3+ messages in thread
From: Sagi Grimberg @ 2024-01-15 12:51 UTC (permalink / raw)
To: mengfanhui, kbusch, axboe; +Cc: linux-kernel, linux-nvme
> Improve code quality. Reduce code redundancy.
Why does this improve code quality? Why does this
reduce code redundancy?
It's just a different style, seems like a useless change to me.
>
> Signed-off-by: mengfanhui <mengfanhui@kylinos.cn>
> ---
> drivers/nvme/common/auth.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/nvme/common/auth.c b/drivers/nvme/common/auth.c
> index a23ab5c968b9..4f9d06afdc38 100644
> --- a/drivers/nvme/common/auth.c
> +++ b/drivers/nvme/common/auth.c
> @@ -250,9 +250,7 @@ struct nvme_dhchap_key *nvme_auth_transform_key(
> if (key->hash == 0) {
> key_len = nvme_auth_key_struct_size(key->len);
> transformed_key = kmemdup(key, key_len, GFP_KERNEL);
> - if (!transformed_key)
> - return ERR_PTR(-ENOMEM);
> - return transformed_key;
> + return transformed_key ? transformed_key : ERR_PTR(-ENOMEM);
> }
> hmac_name = nvme_auth_hmac_name(key->hash);
> if (!hmac_name) {
>
> base-commit: c29901006179c4c87f9335771e50814ec5707239
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme/auth: optimize code redundancy and provide code quality
2024-01-15 12:51 ` Sagi Grimberg
@ 2024-01-15 22:21 ` Chaitanya Kulkarni
0 siblings, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2024-01-15 22:21 UTC (permalink / raw)
To: mengfanhui
Cc: Sagi Grimberg, linux-kernel@vger.kernel.org, axboe@kernel.dk,
linux-nvme@lists.infradead.org, kbusch@kernel.org
>> + return transformed_key ? transformed_key : ERR_PTR(-ENOMEM);
I've received many comments about not using ?: in kernel code as
if .. else is preferred way, not sure if this is a good idea
-ck
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-01-15 22:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-15 6:52 [PATCH] nvme/auth: optimize code redundancy and provide code quality mengfanhui
2024-01-15 12:51 ` Sagi Grimberg
2024-01-15 22:21 ` Chaitanya Kulkarni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox