Use conventional if-else logic instead of goto, which makes the function easier to read.
Signed-off-by: Sergei Zviagintsev <ser...@s15v.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 majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/