[PATCH] net/ceph: Remove unnecessary variables

Subsystems: ceph common code (libceph), the rest

STALE1887d

2 messages, 2 authors, 2021-06-14 · open the first message on its own page

[PATCH] net/ceph: Remove unnecessary variables

From: <hidden>
Date: 2021-06-10 10:02:04

From: zuoqilin <redacted>

There is no necessary to define variable assignment,
just return directly to simplify the steps.

Signed-off-by: zuoqilin <redacted>
---
 net/ceph/auth.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/net/ceph/auth.c b/net/ceph/auth.c
index de407e8..b824a48 100644
--- a/net/ceph/auth.c
+++ b/net/ceph/auth.c
@@ -58,12 +58,10 @@ struct ceph_auth_client *ceph_auth_init(const char *name,
 					const int *con_modes)
 {
 	struct ceph_auth_client *ac;
-	int ret;
 
-	ret = -ENOMEM;
 	ac = kzalloc(sizeof(*ac), GFP_NOFS);
 	if (!ac)
-		goto out;
+		return ERR_PTR(-ENOMEM);
 
 	mutex_init(&ac->mutex);
 	ac->negotiating = true;
@@ -78,9 +76,6 @@ struct ceph_auth_client *ceph_auth_init(const char *name,
 	dout("%s name '%s' preferred_mode %d fallback_mode %d\n", __func__,
 	     ac->name, ac->preferred_mode, ac->fallback_mode);
 	return ac;
-
-out:
-	return ERR_PTR(ret);
 }
 
 void ceph_auth_destroy(struct ceph_auth_client *ac)
-- 
1.9.1

Re: [PATCH] net/ceph: Remove unnecessary variables

From: Ilya Dryomov <idryomov@gmail.com>
Date: 2021-06-14 17:18:15

On Thu, Jun 10, 2021 at 12:02 PM [off-list ref] wrote:
quoted hunk
From: zuoqilin <redacted>

There is no necessary to define variable assignment,
just return directly to simplify the steps.

Signed-off-by: zuoqilin <redacted>
---
 net/ceph/auth.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/net/ceph/auth.c b/net/ceph/auth.c
index de407e8..b824a48 100644
--- a/net/ceph/auth.c
+++ b/net/ceph/auth.c
@@ -58,12 +58,10 @@ struct ceph_auth_client *ceph_auth_init(const char *name,
                                        const int *con_modes)
 {
        struct ceph_auth_client *ac;
-       int ret;

-       ret = -ENOMEM;
        ac = kzalloc(sizeof(*ac), GFP_NOFS);
        if (!ac)
-               goto out;
+               return ERR_PTR(-ENOMEM);

        mutex_init(&ac->mutex);
        ac->negotiating = true;
@@ -78,9 +76,6 @@ struct ceph_auth_client *ceph_auth_init(const char *name,
        dout("%s name '%s' preferred_mode %d fallback_mode %d\n", __func__,
             ac->name, ac->preferred_mode, ac->fallback_mode);
        return ac;
-
-out:
-       return ERR_PTR(ret);
 }

 void ceph_auth_destroy(struct ceph_auth_client *ac)
Applied.

Thanks,

                Ilya
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help