Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757484AbbFQR1a (ORCPT ); Wed, 17 Jun 2015 13:27:30 -0400 Received: from mail-lb0-f180.google.com ([209.85.217.180]:35603 "EHLO mail-lb0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753443AbbFQR1Y (ORCPT ); Wed, 17 Jun 2015 13:27:24 -0400 MIME-Version: 1.0 In-Reply-To: <1434561298-4576-4-git-send-email-sergei@s15v.net> References: <1434561298-4576-1-git-send-email-sergei@s15v.net> <1434561298-4576-4-git-send-email-sergei@s15v.net> Date: Wed, 17 Jun 2015 19:27:22 +0200 Message-ID: Subject: Re: [PATCH 3/3] kdbus: optimize if statements in kdbus_conn_disconnect() From: David Herrmann To: Sergei Zviagintsev Cc: Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni , linux-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2231 Lines: 57 Hi On Wed, Jun 17, 2015 at 7:14 PM, Sergei Zviagintsev wrote: > 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 > --- > ipc/kdbus/connection.c | 15 +++++++-------- > 1 file changed, 7 insertions(+), 8 deletions(-) Reviewed-by: David Herrmann Thanks David > 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 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/