From patchwork Tue Jun 11 09:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10986323 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC3811515 for ; Tue, 11 Jun 2019 09:22:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBC7328630 for ; Tue, 11 Jun 2019 09:22:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AF62D286A1; Tue, 11 Jun 2019 09:22:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF947286A2 for ; Tue, 11 Jun 2019 09:22:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hacxW-0006Vr-F4; Tue, 11 Jun 2019 09:20:50 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hacxV-0006Vm-D1 for xen-devel@lists.xenproject.org; Tue, 11 Jun 2019 09:20:49 +0000 X-Inumbo-ID: 30abe35e-8c2a-11e9-8980-bc764e045a96 Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 30abe35e-8c2a-11e9-8980-bc764e045a96; Tue, 11 Jun 2019 09:20:46 +0000 (UTC) Received: from localhost.localdomain (61.161.186.150) by mxnavi-mail.mxnavi.com (116.90.87.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Tue, 11 Jun 2019 17:17:34 +0800 From: Baodong Chen To: Date: Tue, 11 Jun 2019 17:20:37 +0800 Message-ID: <1560244837-31477-1-git-send-email-chenbaodong@mxnavi.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [61.161.186.150] X-ClientProxiedBy: mxnavi-mail.mxnavi.com (116.90.87.199) To mxnavi-mail.mxnavi.com (116.90.87.199) Subject: [Xen-devel] [PATCH] xen: superficial clean-ups 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: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Baodong Chen , Dario Faggioli Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP * Remove redundant set 'DOMDYING_dead' domain_create() will set this when fail, thus no need set in arch_domain_create(). * Set error when really happened Signed-off-by: Baodong Chen --- xen/arch/arm/domain.c | 1 - xen/common/domain.c | 15 +++++++-------- xen/common/schedule.c | 4 +++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index ff330b3..c72be08 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -731,7 +731,6 @@ int arch_domain_create(struct domain *d, return 0; fail: - d->is_dying = DOMDYING_dead; arch_domain_destroy(d); return rc; diff --git a/xen/common/domain.c b/xen/common/domain.c index 90c6607..a6af5a6 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -358,10 +358,9 @@ struct domain *domain_create(domid_t domid, */ if ( !is_system_domain(d) ) { - err = -ENOMEM; d->vcpu = xzalloc_array(struct vcpu *, config->max_vcpus); if ( !d->vcpu ) - goto fail; + goto no_mem; d->max_vcpus = config->max_vcpus; } @@ -389,9 +388,8 @@ struct domain *domain_create(domid_t domid, rwlock_init(&d->vnuma_rwlock); - err = -ENOMEM; if ( !zalloc_cpumask_var(&d->dirty_cpumask) ) - goto fail; + goto no_mem; rangeset_domain_initialise(d); @@ -429,7 +427,7 @@ struct domain *domain_create(domid_t domid, d->iomem_caps = rangeset_new(d, "I/O Memory", RANGESETF_prettyprint_hex); d->irq_caps = rangeset_new(d, "Interrupts", 0); if ( !d->iomem_caps || !d->irq_caps ) - goto fail; + goto no_mem; if ( (err = xsm_domain_create(XSM_HOOK, d, config->ssidref)) != 0 ) goto fail; @@ -449,11 +447,9 @@ struct domain *domain_create(domid_t domid, if ( (err = argo_init(d)) != 0 ) goto fail; - err = -ENOMEM; - d->pbuf = xzalloc_array(char, DOMAIN_PBUF_SIZE); if ( !d->pbuf ) - goto fail; + goto no_mem; if ( (err = sched_init_domain(d, 0)) != 0 ) goto fail; @@ -482,6 +478,9 @@ struct domain *domain_create(domid_t domid, return d; + no_mem: + err = -ENOMEM; + fail: ASSERT(err < 0); /* Sanity check paths leading here. */ err = err ?: -EILSEQ; /* Release build safety. */ diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 86341bc..d6cdcf8 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -1894,9 +1894,11 @@ struct scheduler *scheduler_alloc(unsigned int sched_id, int *perr) return NULL; found: - *perr = -ENOMEM; if ( (sched = xmalloc(struct scheduler)) == NULL ) + { + *perr = -ENOMEM; return NULL; + } memcpy(sched, schedulers[i], sizeof(*sched)); if ( (*perr = SCHED_OP(sched, init)) != 0 ) {