From patchwork Tue Dec 24 15:19:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11309509 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 78BAB6C1 for ; Tue, 24 Dec 2019 15:20:46 +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 50BE42071E for ; Tue, 24 Dec 2019 15:20:46 +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="M/gB5q6j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50BE42071E 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 1ijlyK-0000Ch-5r; Tue, 24 Dec 2019 15:19:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijlyJ-0000Ca-2S for xen-devel@lists.xenproject.org; Tue, 24 Dec 2019 15:19:43 +0000 X-Inumbo-ID: cbed5031-2660-11ea-97e5-12813bfff9fa Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id cbed5031-2660-11ea-97e5-12813bfff9fa; Tue, 24 Dec 2019 15:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577200777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=RX6Blgk0Xk4ef64Q6qEVWGRgYRDhAIECGhmmf5qsoUQ=; b=M/gB5q6jPNTOJF77OwiN9xA+lq/hw4cFXR6QqWpdfl1EMJEjV6VUaOcz ziKyq9U9iGZH0ldJna2AV4LP0ubHQy/utbc5Jy8+/X0N+/XhPzNhE5VII md5vaZIlIgmlzNTZiflVybX8OgO5ccv0baBxEgHEHfeQNEo8wQI7Bsh3Y k=; Authentication-Results: esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.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=esa5.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 (esa5.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=esa5.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: gYdQIRzRpFKEcwEDoefh1V9O9dVPRkOm1Fo2KiWurvODCjmfnI7J6rsi+6QuY8DzTQL+lddk8B mHufNCvRT3R8NDUo8j9/G0p/Q1yw8kqh5Ngn2W44lK8eXdw+Wihn3QLg6w0pACS3GAjJGDQ8ka DZAE84FqHiBxpjc8wTowdlGCphM1eQBQBNrcP4I/5apIVUu8zO3kJv4nkNx7EvEm11WaSRqY2c /p75Q4DUiuebHvQWqmYIeIDQmj16/k32i0p9zdtYi/rLhHRpq63ktxqOKRHQIk/17Vj4vK8BUq oXo= X-SBRS: 2.7 X-MesageID: 10482745 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,351,1571716800"; d="scan'208";a="10482745" From: Andrew Cooper To: Xen-devel Date: Tue, 24 Dec 2019 15:19:21 +0000 Message-ID: <20191224151932.6304-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191224151932.6304-1-andrew.cooper3@citrix.com> References: <20191224151932.6304-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 01/12] libxc/save: Shrink code volume where possible 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: Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A property of how the error handling (0 on success, nonzero otherwise) allows these calls to be chained together with the ternary operatior. No functional change, but far less boilerplate code. Signed-off-by: Andrew Cooper --- CC: Ian Jackson CC: Wei Liu --- tools/libxc/xc_sr_save.c | 7 ++--- tools/libxc/xc_sr_save_x86_hvm.c | 21 +++------------ tools/libxc/xc_sr_save_x86_pv.c | 58 ++++++++-------------------------------- 3 files changed, 16 insertions(+), 70 deletions(-) diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c index f89e12c99f..9764aa743f 100644 --- a/tools/libxc/xc_sr_save.c +++ b/tools/libxc/xc_sr_save.c @@ -845,11 +845,8 @@ static int save(struct xc_sr_context *ctx, uint16_t guest_type) xc_report_progress_single(xch, "Start of stream"); - rc = write_headers(ctx, guest_type); - if ( rc ) - goto err; - - rc = ctx->save.ops.start_of_stream(ctx); + rc = (write_headers(ctx, guest_type) ?: + ctx->save.ops.start_of_stream(ctx)); if ( rc ) goto err; diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c index 3d86cb0600..d925a81999 100644 --- a/tools/libxc/xc_sr_save_x86_hvm.c +++ b/tools/libxc/xc_sr_save_x86_hvm.c @@ -187,24 +187,9 @@ static int x86_hvm_check_vm_state(struct xc_sr_context *ctx) static int x86_hvm_end_of_checkpoint(struct xc_sr_context *ctx) { - int rc; - - /* Write the TSC record. */ - rc = write_x86_tsc_info(ctx); - if ( rc ) - return rc; - - /* Write the HVM_CONTEXT record. */ - rc = write_hvm_context(ctx); - if ( rc ) - return rc; - - /* Write HVM_PARAMS record contains applicable HVM params. */ - rc = write_hvm_params(ctx); - if ( rc ) - return rc; - - return 0; + return (write_x86_tsc_info(ctx) ?: + write_hvm_context(ctx) ?: + write_hvm_params(ctx)); } static int x86_hvm_cleanup(struct xc_sr_context *ctx) diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c index 3ebc5a2bf8..94d0f68911 100644 --- a/tools/libxc/xc_sr_save_x86_pv.c +++ b/tools/libxc/xc_sr_save_x86_pv.c @@ -768,19 +768,10 @@ static int write_all_vcpu_information(struct xc_sr_context *ctx) if ( !vinfo.online ) continue; - rc = write_one_vcpu_basic(ctx, i); - if ( rc ) - return rc; - - rc = write_one_vcpu_extended(ctx, i); - if ( rc ) - return rc; - - rc = write_one_vcpu_xsave(ctx, i); - if ( rc ) - return rc; - - rc = write_one_vcpu_msrs(ctx, i); + rc = (write_one_vcpu_basic(ctx, i) ?: + write_one_vcpu_extended(ctx, i) ?: + write_one_vcpu_xsave(ctx, i) ?: + write_one_vcpu_msrs(ctx, i)); if ( rc ) return rc; } @@ -1031,25 +1022,10 @@ static int x86_pv_normalise_page(struct xc_sr_context *ctx, xen_pfn_t type, */ static int x86_pv_setup(struct xc_sr_context *ctx) { - int rc; - - rc = x86_pv_domain_info(ctx); - if ( rc ) - return rc; - - rc = x86_pv_map_m2p(ctx); - if ( rc ) - return rc; - - rc = map_shinfo(ctx); - if ( rc ) - return rc; - - rc = map_p2m(ctx); - if ( rc ) - return rc; - - return 0; + return (x86_pv_domain_info(ctx) ?: + x86_pv_map_m2p(ctx) ?: + map_shinfo(ctx) ?: + map_p2m(ctx)); } static int x86_pv_start_of_stream(struct xc_sr_context *ctx) @@ -1080,21 +1056,9 @@ static int x86_pv_start_of_checkpoint(struct xc_sr_context *ctx) static int x86_pv_end_of_checkpoint(struct xc_sr_context *ctx) { - int rc; - - rc = write_x86_tsc_info(ctx); - if ( rc ) - return rc; - - rc = write_shared_info(ctx); - if ( rc ) - return rc; - - rc = write_all_vcpu_information(ctx); - if ( rc ) - return rc; - - return 0; + return (write_x86_tsc_info(ctx) ?: + write_shared_info(ctx) ?: + write_all_vcpu_information(ctx)); } static int x86_pv_check_vm_state(struct xc_sr_context *ctx)