From nobody Sat Apr 20 12:20:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1592360415; cv=none; d=zohomail.com; s=zohoarc; b=KgGf0f5oSzx+6hLYEwXNEe0UlpfP8ys3wYVsoOzGmvNbzGdA5i/UbdW8uBR5LPZXczEFUFc0pPc2QXpNr4IM4EAiX2HUMITsIZXmpQC4DCQeyhSGnY9AvmGldNSYfCS804BRMB9zJaD1jwQeAxqiac3VMa4NXvKQV3wqAIFiS3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592360415; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=L2Hn0V5tRGHerMZvPhFCYDF3+Xa9unqVuRv8OIXH5kY=; b=Oz00+7ri2i4oKqJIh3GfbwwQ5gDwsb1nXllo6S1WzkogAt0si+lFkdL6DPmQmnQJCLGpJhskfMT12+pJplrSdRXSLnFsQ6zhXlKdsbPcR42Mc07v9Ox1+2kLkBO4g95RkRFxCDb7QCidUvx3QxH8po4z3uOd2U/E5/CPqjJzvys= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1592360415010132.890244213453; Tue, 16 Jun 2020 19:20:15 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jlNg0-0002xD-4g; Wed, 17 Jun 2020 02: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.92) (envelope-from ) id 1jlNfy-0002x8-SB for xen-devel@lists.xenproject.org; Wed, 17 Jun 2020 02:19:42 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ff829024-b040-11ea-b977-12813bfff9fa; Wed, 17 Jun 2020 02:19:40 +0000 (UTC) X-Inumbo-ID: ff829024-b040-11ea-b977-12813bfff9fa Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: cJhDtZTtaIATMqqZXba+kRqLsnVGcgf+mPNLAGvGqPsXmLy3m+f1W2mplsNXiTllp1+COJrGK7 rtlxJi5lrlJVZMLWJsqL3LlP/0vJW/LGeBNDkdNe9xu+aWTSX/Y0Ps+Nyl5Scxggn49GVkN/26 lWiqURkZvgwxvspdcL0vSEdziRrREysxEW78JzcMkyIVc5wsXG9AzhfV5yZP05wKYmbutAsObK l1JnghYtCblVCJMS6Ahlqw1McjrfB111jv6njoX03JSCCL6VHLS7nyB8tg0CLJA+v2jGt7ct5H F38= X-SBRS: 2.7 X-MesageID: 20529371 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.73,520,1583211600"; d="scan'208";a="20529371" From: Igor Druzhinin To: Subject: [PATCH for-4.14 v3] tools/xen-ucode: return correct exit code on failed microcode update Date: Wed, 17 Jun 2020 03:19:13 +0100 Message-ID: <1592360353-31231-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Igor Druzhinin , ian.jackson@eu.citrix.com, xadimgnik@gmail.com, wl@xen.org Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Otherwise it's difficult to know if operation failed inside the automation. While at it, also switch to returning 1 and 2 instead of errno to avoid incompatibilies between errno and special exit code numbers. Signed-off-by: Igor Druzhinin Reviewed-by: Ian Jackson Reviewed-by: Paul Durrant --- Changes in v3: - conventionally return 1 and 2 instead of errno as exit code --- tools/misc/xen-ucode.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/misc/xen-ucode.c b/tools/misc/xen-ucode.c index 0c257f4..ad32fac 100644 --- a/tools/misc/xen-ucode.c +++ b/tools/misc/xen-ucode.c @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "xen-ucode: Xen microcode updating tool\n" "Usage: %s \n", argv[0]); - return 0; + exit(2); } =20 filename =3D argv[1]; @@ -34,14 +34,14 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Could not open %s. (err: %s)\n", filename, strerror(errno)); - return errno; + exit(1); } =20 if ( fstat(fd, &st) !=3D 0 ) { fprintf(stderr, "Could not get the size of %s. (err: %s)\n", filename, strerror(errno)); - return errno; + exit(1); } =20 len =3D st.st_size; @@ -49,7 +49,7 @@ int main(int argc, char *argv[]) if ( buf =3D=3D MAP_FAILED ) { fprintf(stderr, "mmap failed. (error: %s)\n", strerror(errno)); - return errno; + exit(1); } =20 xch =3D xc_interface_open(NULL, NULL, 0); @@ -57,20 +57,23 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Error opening xc interface. (err: %s)\n", strerror(errno)); - return errno; + exit(1); } =20 ret =3D xc_microcode_update(xch, buf, len); if ( ret ) + { fprintf(stderr, "Failed to update microcode. (err: %s)\n", strerror(errno)); + exit(1); + } =20 xc_interface_close(xch); =20 if ( munmap(buf, len) ) { printf("Could not unmap: %d(%s)\n", errno, strerror(errno)); - return errno; + exit(1); } close(fd); =20 --=20 2.7.4