From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759145AbbJISrl (ORCPT ); Fri, 9 Oct 2015 14:47:41 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:36319 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753817AbbJISrk (ORCPT ); Fri, 9 Oct 2015 14:47:40 -0400 X-Sasl-enc: dAlQRZUqUhWjTBMZUdw33Y+CFtKO44j6ZANbo3b8w4+7 1444416459 Date: Fri, 9 Oct 2015 21:47:38 +0300 From: Sergei Zviagintsev To: David Herrmann Cc: Greg Kroah-Hartman , Daniel Mack , Djalal Harouni , linux-kernel Subject: Re: [PATCH 31/44] kdbus: Cleanup kdbus_conn_move_messages() Message-ID: <20151009184738.GL2189@localhost.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Oct 08, 2015 at 04:50:31PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:32 PM, Sergei Zviagintsev wrote: > > - Move `r' and `ret' to scopes where they are used. Drop redundant > > initialization of `ret'. > > > > - Initialize `bus' on declaration. > > > > - Replace list_for_each_entry_safe() with list_for_each_entry() when > > iterating over list of replies. > > > > - Drop redundant `continue'. > > > > Signed-off-by: Sergei Zviagintsev > > --- > > ipc/kdbus/connection.c | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c > > index b32b4f981618..6ee688d3de53 100644 > > --- a/ipc/kdbus/connection.c > > +++ b/ipc/kdbus/connection.c > > @@ -1293,25 +1293,24 @@ void kdbus_conn_move_messages(struct kdbus_conn *conn_dst, > > u64 name_id) > > { > > struct kdbus_queue_entry *e, *e_tmp; > > - struct kdbus_reply *r, *r_tmp; > > - struct kdbus_bus *bus; > > + struct kdbus_bus *bus = conn_src->ep->bus; > > struct kdbus_conn *c; > > LIST_HEAD(msg_list); > > - int i, ret = 0; > > + int i; > > > > if (WARN_ON(conn_src == conn_dst)) > > return; > > > > - bus = conn_src->ep->bus; > > - > > /* lock order: domain -> bus -> ep -> names -> conn */ > > down_read(&bus->conn_rwlock); > > hash_for_each(bus->conn_hash, i, c, hentry) { > > + struct kdbus_reply *r; > > + > > Why make 'r' local? So what is the rule to keep some vars block-local and some not? This function has a number of local vars, so the rationale is to keep things simple. We don't use `r' function wide, but use it only in this block, so why don't have it block-local? > > > if (c == conn_src || c == conn_dst) > > continue; > > > > mutex_lock(&c->lock); > > - list_for_each_entry_safe(r, r_tmp, &c->reply_list, entry) { > > + list_for_each_entry(r, &c->reply_list, entry) { > > Looks good. > > > if (r->reply_src != conn_src) > > continue; > > > > @@ -1328,6 +1327,8 @@ void kdbus_conn_move_messages(struct kdbus_conn *conn_dst, > > > > kdbus_conn_lock2(conn_src, conn_dst); > > list_for_each_entry_safe(e, e_tmp, &conn_src->queue.msg_list, entry) { > > + int ret; > > + > > Why make it local? Same thing here. We have the only use of this `ret' var, so why don't keep it right here? > > > /* filter messages for a specific name */ > > if (name_id > 0 && e->dst_name_id != name_id) > > continue; > > @@ -1343,7 +1344,6 @@ void kdbus_conn_move_messages(struct kdbus_conn *conn_dst, > > if (ret < 0) { > > kdbus_conn_lost_message(conn_dst); > > kdbus_queue_entry_free(e); > > - continue; > > Looks good. > > Thanks > David > > > } > > } > > kdbus_conn_unlock2(conn_src, conn_dst); > > -- > > 1.8.3.1 > >