Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757984AbbFQRZa (ORCPT ); Wed, 17 Jun 2015 13:25:30 -0400 Received: from mail-lb0-f176.google.com ([209.85.217.176]:32807 "EHLO mail-lb0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756851AbbFQRZX (ORCPT ); Wed, 17 Jun 2015 13:25:23 -0400 MIME-Version: 1.0 In-Reply-To: <1434561298-4576-3-git-send-email-sergei@s15v.net> References: <1434561298-4576-1-git-send-email-sergei@s15v.net> <1434561298-4576-3-git-send-email-sergei@s15v.net> Date: Wed, 17 Jun 2015 19:25:21 +0200 Message-ID: Subject: Re: [PATCH 2/3] kdbus: optimize error path in kdbus_reply_new() 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: 1673 Lines: 55 Hi On Wed, Jun 17, 2015 at 7:14 PM, Sergei Zviagintsev wrote: > Move cleanup code to separate location as it never executes on normal > flow. This removes extra if-block and the need to initialize `ret'. > > Signed-off-by: Sergei Zviagintsev > --- > ipc/kdbus/reply.c | 12 +++++------- > 1 file changed, 5 insertions(+), 7 deletions(-) Reviewed-by: David Herrmann Thanks David > diff --git a/ipc/kdbus/reply.c b/ipc/kdbus/reply.c > index 9d823ebee71f..e6791d86ec92 100644 > --- a/ipc/kdbus/reply.c > +++ b/ipc/kdbus/reply.c > @@ -37,7 +37,7 @@ struct kdbus_reply *kdbus_reply_new(struct kdbus_conn *reply_src, > bool sync) > { > struct kdbus_reply *r; > - int ret = 0; > + int ret; > > if (atomic_inc_return(&reply_dst->request_count) > > KDBUS_CONN_MAX_REQUESTS_PENDING) { > @@ -64,13 +64,11 @@ struct kdbus_reply *kdbus_reply_new(struct kdbus_conn *reply_src, > r->waiting = true; > } > > -exit_dec_request_count: > - if (ret < 0) { > - atomic_dec(&reply_dst->request_count); > - return ERR_PTR(ret); > - } > - > return r; > + > +exit_dec_request_count: > + atomic_dec(&reply_dst->request_count); > + return ERR_PTR(ret); > } > > static void __kdbus_reply_free(struct kref *kref) > -- > 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/