From patchwork Mon Jan 6 17:37:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11319725 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E66C9138D for ; Mon, 6 Jan 2020 17:38:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C2AC92072A for ; Mon, 6 Jan 2020 17:38:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="gfbEH7Nf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C2AC92072A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioWJZ-0007UQ-TW; Mon, 06 Jan 2020 17:37:17 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioWJY-0007UL-Tn for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 17:37:16 +0000 X-Inumbo-ID: 28da4392-30ab-11ea-88e7-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 28da4392-30ab-11ea-88e7-bc764e2007e4; Mon, 06 Jan 2020 17:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578332228; h=from:to:cc:subject:date:message-id:mime-version; bh=+I3LKUW/7R/pIq00V+ne+xhkFOqgWlxS6A9JuuSfvNE=; b=gfbEH7NfSooXY9iv8qURaeWh0ISU/lPWinrl1GAwfWA7AlWvudlBA//O Si+RLbiXp/lgMv57o66WdpYs+cnAJ7MOgE0abM4Ispeby7/+Xai1Ezi6D S8JU3AhznymfMn6QsnfyqChzl94dFN3htTB5n4HjV/0rrWaNvRtYwujml M=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: SL4Dy1VqKYK075GrjiZyoSGNGZETGfyyS8cLv1eG9LCknzsyNrbC37XkiNAgzvTiGgMmrmfcRp WTxk4ldOxJegGlsLgQYPN0a42nPiWLlv9H3l1k8IlCcCdYbf0JdW16wQ+JZAU9nd/DKMiPETXG OHMgKLBJ32ZuU9QvklqUGV+nxX2vdP/01VEkyBMXnyns3P4edrmr2FyCbmUZEsR5wVr/b/x4/s wNSBES5dq36RscHYap4LI8n6Hgwekf4tg1yUTdTTZE2uK4iTf/wkyvtmBAdnZxnCpJ0KrxUBp+ 7jg= X-SBRS: 2.7 X-MesageID: 10496308 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,403,1571716800"; d="scan'208";a="10496308" From: Andrew Cooper To: Xen-devel Date: Mon, 6 Jan 2020 17:37:04 +0000 Message-ID: <20200106173704.26433-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/cpupool: Fold error paths in cpupool_create() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Andrew Cooper , Dario Faggioli Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The compiler can't fold because of the write to *perr in the first hunk. No functional change, but slightly better compiled code. Signed-off-by: Andrew Cooper Reviewed-by: Juergen Gross --- CC: Juergen Gross CC: Dario Faggioli --- xen/common/cpupool.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c index 4d3adbdd8d..d66b541a94 100644 --- a/xen/common/cpupool.c +++ b/xen/common/cpupool.c @@ -236,10 +236,8 @@ static struct cpupool *cpupool_create( { if ( (*q)->cpupool_id == poolid ) { - spin_unlock(&cpupool_lock); - free_cpupool_struct(c); *perr = -EEXIST; - return NULL; + goto err; } c->next = *q; } @@ -253,11 +251,7 @@ static struct cpupool *cpupool_create( { c->sched = scheduler_alloc(sched_id, perr); if ( c->sched == NULL ) - { - spin_unlock(&cpupool_lock); - free_cpupool_struct(c); - return NULL; - } + goto err; } c->gran = opt_sched_granularity; @@ -270,6 +264,11 @@ static struct cpupool *cpupool_create( *perr = 0; return c; + + err: + spin_unlock(&cpupool_lock); + free_cpupool_struct(c); + return NULL; } /* * destroys the given cpupool