[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1452170339-26748-5-git-send-email-wanghaibin.wang@huawei.com>
Date: Thu, 7 Jan 2016 20:38:59 +0800
From: wanghaibin <wanghaibin.wang@...wei.com>
To: <linux-kernel@...r.kernel.org>
CC: <tj@...nel.org>, <jiangshanlai@...il.com>,
<peter.huangpeng@...wei.com>,
wanghaibin <wanghaibin.wang@...wei.com>
Subject: [RFC PATCH 4/4] workqueue: simplify the apply_workqueue_attrs_locked function.
if the apply_wqattrs_prepare function return NULL, in its implement, it has already
clear up the related resource, so, it can return failed directly, to avoid to call
the clean up function again.
this doesn't introduce any functional changes, just a suggestion.
Signed-off-by: wanghaibin <wanghaibin.wang@...wei.com>
---
kernel/workqueue.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d6527dc..9c9a27e 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3601,7 +3601,6 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
const struct workqueue_attrs *attrs)
{
struct apply_wqattrs_ctx *ctx;
- int ret = -ENOMEM;
/* only unbound workqueues can change attributes */
if (WARN_ON(!(wq->flags & WQ_UNBOUND)))
@@ -3612,16 +3611,14 @@ static int apply_workqueue_attrs_locked(struct workqueue_struct *wq,
return -EINVAL;
ctx = apply_wqattrs_prepare(wq, attrs);
+ if (!ctx)
+ return -ENOMEM;
/* the ctx has been prepared successfully, let's commit it */
- if (ctx) {
- apply_wqattrs_commit(ctx);
- ret = 0;
- }
-
+ apply_wqattrs_commit(ctx);
apply_wqattrs_cleanup(ctx);
- return ret;
+ return 0;
}
/**
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists