From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 3A7A07803CD for ; Wed, 29 Nov 2023 18:29:23 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=EH2+D8wDPVkhSIJiN4hnb72MS1Ysj4a3oBU0s93LytQ=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1701282561; v=1; b=cs8eNN6RF2FgQbEJYkQTynagAfRdx7Hg5qOKMnBJm+ef/vZ+Xm9r/0ig10Bg/25sV9u0W6V3 RtuA7iarl3Q15jm5yVTQfSKvYij3QPRTsBqI8QQqdWY6ec8/3SQqrPy4wmLJ88jzHmHCLB1iiXe H5GifRVe5hJnbGn364jnvm/0= X-Received: by 127.0.0.2 with SMTP id DznuYY7687511xOD13IOofo0; Wed, 29 Nov 2023 10:29:21 -0800 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.46009.1701282561033008677 for ; Wed, 29 Nov 2023 10:29:21 -0800 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C720EC15; Wed, 29 Nov 2023 10:30:07 -0800 (PST) X-Received: from u102865.austin.arm.com (u102865.arm.com [10.118.16.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A9D3F3F5A1; Wed, 29 Nov 2023 10:29:20 -0800 (PST) From: "Daniel Nguyen" To: devel@edk2.groups.io Cc: nd@arm.com, Daniel Nguyen , Zhichao Gao , Ray Ni Subject: [edk2-devel] [PATCH v2 1/1] ShellPkg: Tidy for code readability Date: Wed, 29 Nov 2023 12:28:40 -0600 Message-Id: <20231129182840.2333098-2-daniel.nguyen@arm.com> In-Reply-To: <20231129182840.2333098-1-daniel.nguyen@arm.com> References: <20231129182840.2333098-1-daniel.nguyen@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,daniel.nguyen@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Ri07flzCVTxEek3JDdbUh0Y7x7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=cs8eNN6R; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Use error handling instead of success handling. Less indented logic is easier to read. Cc: Zhichao Gao Cc: Ray Ni Signed-off-by: Daniel Nguyen --- ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c | 41 +++++++++++----= ----- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c b/ShellP= kg/Library/UefiShellLevel2CommandsLib/Reset.c index 57ba3c90f373..361c47e43059 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/Reset.c @@ -79,30 +79,35 @@ ShellCommandRunReset ( &DataSize, &OsIndications ); - if (!EFI_ERROR (Status)) { - if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) !=3D 0)= { - DataSize =3D sizeof (OsIndications); - Status =3D gRT->GetVariable ( - EFI_OS_INDICATIONS_VARIABLE_NAME, - &gEfiGlobalVariableGuid, - &Attr, - &DataSize, - &OsIndications - ); - if (!EFI_ERROR (Status)) { - OsIndications |=3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI; - } else { - OsIndications =3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI; - } =20 - Status =3D gRT->SetVariable ( + if (EFI_ERROR (Status)) { + ShellStatus =3D SHELL_UNSUPPORTED; + goto Error; + } + + if ((OsIndications & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) !=3D 0) { + DataSize =3D sizeof (OsIndications); + Status =3D gRT->GetVariable ( EFI_OS_INDICATIONS_VARIABLE_NAME, &gEfiGlobalVariableGuid, - EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOO= TSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, - sizeof (OsIndications), + &Attr, + &DataSize, &OsIndications ); + + if (EFI_ERROR (Status)) { + OsIndications =3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI; + } else { + OsIndications |=3D EFI_OS_INDICATIONS_BOOT_TO_FW_UI; } + + Status =3D gRT->SetVariable ( + EFI_OS_INDICATIONS_VARIABLE_NAME, + &gEfiGlobalVariableGuid, + EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTS= ERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, + sizeof (OsIndications), + &OsIndications + ); } =20 if (EFI_ERROR (Status)) { --=20 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111856): https://edk2.groups.io/g/devel/message/111856 Mute This Topic: https://groups.io/mt/102877864/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-