From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753299AbcAGMkw (ORCPT ); Thu, 7 Jan 2016 07:40:52 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:56251 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752849AbcAGMkr (ORCPT ); Thu, 7 Jan 2016 07:40:47 -0500 From: wanghaibin To: CC: , , , wanghaibin Subject: [RFC PATCH 4/4] workqueue: simplify the apply_workqueue_attrs_locked function. Date: Thu, 7 Jan 2016 20:38:59 +0800 Message-ID: <1452170339-26748-5-git-send-email-wanghaibin.wang@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1452170339-26748-1-git-send-email-wanghaibin.wang@huawei.com> References: <1452170339-26748-1-git-send-email-wanghaibin.wang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.27.144] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.568E5CCC.016C,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 46448b345f7954e2e17418a12107b0fd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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