lkml.org 
[lkml]   [2015]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/3] kdbus: optimize error path in kdbus_reply_new()
From
Hi

On Wed, Jun 17, 2015 at 7:14 PM, Sergei Zviagintsev <sergei@s15v.net> 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 <sergei@s15v.net>
> ---
> ipc/kdbus/reply.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

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
>


\
 
 \ /
  Last update: 2015-06-17 19:41    [W:0.347 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site