From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933940AbbJISHv (ORCPT ); Fri, 9 Oct 2015 14:07:51 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:37551 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751464AbbJISHu (ORCPT ); Fri, 9 Oct 2015 14:07:50 -0400 X-Sasl-enc: t0jqvK1KbOsNw/KMqFavmrP+WdCQ1b4hNCgskIxlJNvg 1444414069 Date: Fri, 9 Oct 2015 21:07:48 +0300 From: Sergei Zviagintsev To: David Herrmann Cc: Greg Kroah-Hartman , Daniel Mack , Djalal Harouni , linux-kernel Subject: Re: [PATCH 21/44] kdbus: Cleanup tests in kdbus_cmd_send() Message-ID: <20151009180748.GF2189@localhost.localdomain> References: <9db47f36656aca616ea01b24bdd615976843093b.1444302968.git.sergei@s15v.net> 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 On Thu, Oct 08, 2015 at 04:30:59PM +0200, David Herrmann wrote: > Hi > > On Thu, Oct 8, 2015 at 1:31 PM, Sergei Zviagintsev wrote: > > Rearrange tests a little to make them look cleaner. > > What's wrong with 'else if'? Less verbose constructions are easier for our brain to accept :) Moreover, we usually don't write code in the 'else' branch of if-statement which handles an error-path. But I don't mind dropping this patch, it really doesn't save the universe. > > Thanks > David > > > Signed-off-by: Sergei Zviagintsev > > --- > > ipc/kdbus/connection.c | 9 +++++---- > > 1 file changed, 5 insertions(+), 4 deletions(-) > > > > diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c > > index 93da7f539f74..a4d7414ecaea 100644 > > --- a/ipc/kdbus/connection.c > > +++ b/ipc/kdbus/connection.c > > @@ -1977,7 +1977,7 @@ int kdbus_cmd_send(struct kdbus_conn *conn, struct file *f, void __user *argp) > > ret = kdbus_args_parse(&args, argp, &cmd); > > if (ret < 0) > > goto exit; > > - else if (ret > 0 && !cmd->msg_address) /* negotiation without msg */ > > + if (ret > 0 && !cmd->msg_address) /* negotiation without msg */ > > goto exit; > > > > ret2 = kdbus_args_parse_msg(&msg_args, KDBUS_PTR(cmd->msg_address), > > @@ -1985,10 +1985,11 @@ int kdbus_cmd_send(struct kdbus_conn *conn, struct file *f, void __user *argp) > > if (ret2 < 0) { /* cannot parse message */ > > ret = ret2; > > goto exit; > > - } else if (ret2 > 0 && !ret) { /* msg-negot implies cmd-negot */ > > - ret = -EINVAL; > > + } > > + if (ret > 0) /* negotiation */ > > goto exit; > > - } else if (ret > 0) { /* negotiation */ > > + if (ret2 > 0) { /* msg-negot implies cmd-negot */ > > + ret = -EINVAL; > > goto exit; > > } > > > > -- > > 1.8.3.1 > >