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 3/3] kdbus: optimize if statements in kdbus_conn_disconnect()
Date: Wed, 17 Jun 2015 20:14:58 +0300 [thread overview]
Message-ID: <1434561298-4576-4-git-send-email-sergei@s15v.net> (raw)
In-Reply-To: <1434561298-4576-1-git-send-email-sergei@s15v.net>
if (r->sync) branch and code after it both call kdbus_reply_unlink().
Rewrite them as if-else to eliminate code duplication and make algorithm
more obvious.
Convert outer if statement to use continue in order to reduce
indentation and make things easier to read.
Signed-off-by: Sergei Zviagintsev <sergei@s15v.net>
---
ipc/kdbus/connection.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c
index 707be050b408..9993753d11de 100644
--- a/ipc/kdbus/connection.c
+++ b/ipc/kdbus/connection.c
@@ -559,17 +559,16 @@ int kdbus_conn_disconnect(struct kdbus_conn *conn, bool ensure_queue_empty)
hash_for_each(bus->conn_hash, i, c, hentry) {
mutex_lock(&c->lock);
list_for_each_entry_safe(r, r_tmp, &c->reply_list, entry) {
- if (r->reply_src == conn) {
- if (r->sync) {
- kdbus_sync_reply_wakeup(r, -EPIPE);
- kdbus_reply_unlink(r);
- continue;
- }
+ if (r->reply_src != conn)
+ continue;
+ if (r->sync)
+ kdbus_sync_reply_wakeup(r, -EPIPE);
+ else
/* send a 'connection dead' notification */
kdbus_notify_reply_dead(bus, c->id, r->cookie);
- kdbus_reply_unlink(r);
- }
+
+ kdbus_reply_unlink(r);
}
mutex_unlock(&c->lock);
}
--
1.8.3.1
next prev 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 ` [PATCH 2/3] kdbus: optimize error path in kdbus_reply_new() Sergei Zviagintsev
2015-06-17 17:25 ` David Herrmann
2015-06-17 17:14 ` Sergei Zviagintsev [this message]
2015-06-17 17:27 ` [PATCH 3/3] kdbus: optimize if statements in kdbus_conn_disconnect() 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-4-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®