From b3c1bc1cfa2f45849429f582808c3384f4273229 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Fri, 24 Apr 2020 09:53:49 +0200 Subject: [PATCH] OvmfPkg/PlatformPei: use QemuFwCfgParseBool in UPDATE_BOOLEAN_PCD_FROM_... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UPDATE_BOOLEAN_PCD_FROM_FW_CFG() macro currently calls the module-private helper function GetNamedFwCfgBoolean(). Replace the latter with QemuFwCfgParseBool() from QemuFwCfgSimpleParserLib. This change is compatible with valid strings accepted previously. Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Per Sundstrom Cc: Philippe Mathieu-Daudé Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2681 Signed-off-by: Laszlo Ersek Message-Id: <20200424075353.8489-4-lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Ard Biesheuvel --- OvmfPkg/PlatformPei/Platform.c | 47 ++-------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 088e616a98..3b850c2c26 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -254,56 +255,12 @@ MemMapInitialization ( ASSERT_RETURN_ERROR (PcdStatus); } -EFI_STATUS -GetNamedFwCfgBoolean ( - IN CHAR8 *FwCfgFileName, - OUT BOOLEAN *Setting - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM FwCfgItem; - UINTN FwCfgSize; - UINT8 Value[3]; - - Status = QemuFwCfgFindFile (FwCfgFileName, &FwCfgItem, &FwCfgSize); - if (EFI_ERROR (Status)) { - return Status; - } - if (FwCfgSize > sizeof Value) { - return EFI_BAD_BUFFER_SIZE; - } - QemuFwCfgSelectItem (FwCfgItem); - QemuFwCfgReadBytes (FwCfgSize, Value); - - if ((FwCfgSize == 1) || - (FwCfgSize == 2 && Value[1] == '\n') || - (FwCfgSize == 3 && Value[1] == '\r' && Value[2] == '\n')) { - switch (Value[0]) { - case '0': - case 'n': - case 'N': - *Setting = FALSE; - return EFI_SUCCESS; - - case '1': - case 'y': - case 'Y': - *Setting = TRUE; - return EFI_SUCCESS; - - default: - break; - } - } - return EFI_PROTOCOL_ERROR; -} - #define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName) \ do { \ BOOLEAN Setting; \ RETURN_STATUS PcdStatus; \ \ - if (!EFI_ERROR (GetNamedFwCfgBoolean ( \ + if (!RETURN_ERROR (QemuFwCfgParseBool ( \ "opt/ovmf/" #TokenName, &Setting))) { \ PcdStatus = PcdSetBoolS (TokenName, Setting); \ ASSERT_RETURN_ERROR (PcdStatus); \