[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <bab5e8424f14b078604780d8dbaba2072b4b1136.1444302968.git.sergei@s15v.net>
Date: Thu, 8 Oct 2015 14:32:04 +0300
From: Sergei Zviagintsev <sergei@...v.net>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Daniel Mack <daniel@...que.org>,
David Herrmann <dh.herrmann@...glemail.com>,
Djalal Harouni <tixxdz@...ndz.org>
Cc: linux-kernel@...r.kernel.org, Sergei Zviagintsev <sergei@...v.net>
Subject: [PATCH 35/44] kdbus: Drop goto from kdbus_queue_entry_link()
Use conventional if-else logic instead of goto, which makes the function
easier to read.
Signed-off-by: Sergei Zviagintsev <sergei@...v.net>
---
ipc/kdbus/queue.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/ipc/kdbus/queue.c b/ipc/kdbus/queue.c
index 3c0fb3bb55da..5158f00e7148 100644
--- a/ipc/kdbus/queue.c
+++ b/ipc/kdbus/queue.c
@@ -87,6 +87,7 @@ struct kdbus_queue_entry *kdbus_queue_peek(struct kdbus_queue *queue,
static void kdbus_queue_entry_link(struct kdbus_queue_entry *entry)
{
struct kdbus_queue *queue = &entry->conn->queue;
+ struct kdbus_queue_entry *e;
struct rb_node **n, *pn = NULL;
bool highest = true;
@@ -97,16 +98,11 @@ static void kdbus_queue_entry_link(struct kdbus_queue_entry *entry)
/* sort into priority entry tree */
n = &queue->msg_prio_queue.rb_node;
while (*n) {
- struct kdbus_queue_entry *e;
-
pn = *n;
e = rb_entry(pn, struct kdbus_queue_entry, prio_node);
- /* existing node for this priority, add to its list */
- if (likely(entry->priority == e->priority)) {
- list_add_tail(&entry->prio_entry, &e->prio_entry);
- goto prio_done;
- }
+ if (likely(entry->priority == e->priority))
+ break;
if (entry->priority < e->priority) {
n = &pn->rb_left;
@@ -116,16 +112,20 @@ static void kdbus_queue_entry_link(struct kdbus_queue_entry *entry)
}
}
- /* cache highest-priority entry */
- if (highest)
- queue->msg_prio_highest = &entry->prio_node;
-
- /* new node for this priority */
- rb_link_node(&entry->prio_node, pn, n);
- rb_insert_color(&entry->prio_node, &queue->msg_prio_queue);
- INIT_LIST_HEAD(&entry->prio_entry);
+ if (*n) {
+ /* existing node for this priority, add to its list */
+ list_add_tail(&entry->prio_entry, &e->prio_entry);
+ } else {
+ /* cache highest-priority entry */
+ if (highest)
+ queue->msg_prio_highest = &entry->prio_node;
+
+ /* new node for this priority */
+ rb_link_node(&entry->prio_node, pn, n);
+ rb_insert_color(&entry->prio_node, &queue->msg_prio_queue);
+ INIT_LIST_HEAD(&entry->prio_entry);
+ }
-prio_done:
/* add to unsorted fifo list */
list_add_tail(&entry->entry, &queue->msg_list);
}
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists