mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergei Zviagintsev <sergei@s15v.net>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Daniel Mack <daniel@zonque.org>,
	David Herrmann <dh.herrmann@googlemail.com>,
	Djalal Harouni <tixxdz@opendz.org>
Cc: linux-kernel@vger.kernel.org, Sergei Zviagintsev <sergei@s15v.net>
Subject: [PATCH 2/3] kdbus: optimize error path in kdbus_reply_new()
Date: Wed, 17 Jun 2015 20:14:57 +0300	[thread overview]
Message-ID: <1434561298-4576-3-git-send-email-sergei@s15v.net> (raw)
In-Reply-To: <1434561298-4576-1-git-send-email-sergei@s15v.net>

Move cleanup code to separate location as it never executes on normal
flow. This removes extra if-block and the need to initialize `ret'.

Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
---
 ipc/kdbus/reply.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/ipc/kdbus/reply.c b/ipc/kdbus/reply.c
index 9d823ebee71f..e6791d86ec92 100644
--- a/ipc/kdbus/reply.c
+++ b/ipc/kdbus/reply.c
@@ -37,7 +37,7 @@ struct kdbus_reply *kdbus_reply_new(struct kdbus_conn *reply_src,
 				    bool sync)
 {
 	struct kdbus_reply *r;
-	int ret = 0;
+	int ret;
 
 	if (atomic_inc_return(&reply_dst->request_count) >
 	    KDBUS_CONN_MAX_REQUESTS_PENDING) {
@@ -64,13 +64,11 @@ struct kdbus_reply *kdbus_reply_new(struct kdbus_conn *reply_src,
 		r->waiting = true;
 	}
 
-exit_dec_request_count:
-	if (ret < 0) {
-		atomic_dec(&reply_dst->request_count);
-		return ERR_PTR(ret);
-	}
-
 	return r;
+
+exit_dec_request_count:
+	atomic_dec(&reply_dst->request_count);
+	return ERR_PTR(ret);
 }
 
 static void __kdbus_reply_free(struct kref *kref)
-- 
1.8.3.1


  parent reply	other threads:[~2015-06-17 17:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 17:14 [PATCH 0/3] kdbus: minor readability improvements Sergei Zviagintsev
2015-06-17 17:14 ` [PATCH 1/3] kdbus: kdbus_reply_find(): return on found entry Sergei Zviagintsev
2015-06-17 17:21   ` David Herrmann
2015-06-17 17:14 ` Sergei Zviagintsev [this message]
2015-06-17 17:25   ` [PATCH 2/3] kdbus: optimize error path in kdbus_reply_new() David Herrmann
2015-06-17 17:14 ` [PATCH 3/3] kdbus: optimize if statements in kdbus_conn_disconnect() Sergei Zviagintsev
2015-06-17 17:27   ` David Herrmann
2015-06-17 17:45 ` [PATCH 0/3] kdbus: minor readability improvements Djalal Harouni
2015-06-17 19:03 ` Djalal Harouni
2015-06-19  5:07 ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434561298-4576-3-git-send-email-sergei@s15v.net \
    --to=sergei@s15v.net \
    --cc=daniel@zonque.org \
    --cc=dh.herrmann@googlemail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tixxdz@opendz.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®