diff mbox

[edk2,06/19] OvmfPkg/SmbiosVersionLib: eliminate unchecked PcdSetXX() calls

Message ID 20161021212737.15974-7-lersek@redhat.com
State Accepted
Commit ae23afb4e7481c9f079ebabb2a0341fdf9c4964b
Headers show

Commit Message

Laszlo Ersek Oct. 21, 2016, 9:27 p.m. UTC
These are deprecated / disabled under the
DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

Introduce a variable called PcdStatus, and use it to assert the success of
these operations (there is no reason for them to fail here).

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=166
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

---

Notes:
    tested with OVMF (smbios v2) and ArmVirtQemu (smbios v3)

 OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Ard Biesheuvel Oct. 24, 2016, 8 a.m. UTC | #1
On 21 October 2016 at 22:27, Laszlo Ersek <lersek@redhat.com> wrote:
> These are deprecated / disabled under the

> DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.

>

> Introduce a variable called PcdStatus, and use it to assert the success of

> these operations (there is no reason for them to fail here).

>

> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> Cc: Jordan Justen <jordan.l.justen@intel.com>

> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=166

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Laszlo Ersek <lersek@redhat.com>


Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


> ---

>

> Notes:

>     tested with OVMF (smbios v2) and ArmVirtQemu (smbios v3)

>

>  OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c | 10 +++++++---

>  1 file changed, 7 insertions(+), 3 deletions(-)

>

> diff --git a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c

> index 950c3f7e0a31..58180412bd1a 100644

> --- a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c

> +++ b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c

> @@ -40,6 +40,7 @@ DetectSmbiosVersion (

>    UINTN                AnchorSize, TablesSize;

>    QEMU_SMBIOS_ANCHOR   QemuAnchor;

>    UINT16               SmbiosVersion;

> +  RETURN_STATUS        PcdStatus;

>

>    if (PcdGetBool (PcdQemuSmbiosValidated)) {

>      //

> @@ -87,7 +88,8 @@ DetectSmbiosVersion (

>

>      DEBUG ((EFI_D_INFO, "%a: SMBIOS 3.x DocRev from QEMU: 0x%02x\n",

>        __FUNCTION__, QemuAnchor.V3.DocRev));

> -    PcdSet8 (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);

> +    PcdStatus = PcdSet8S (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);

> +    ASSERT_RETURN_ERROR (PcdStatus);

>      break;

>

>    default:

> @@ -96,12 +98,14 @@ DetectSmbiosVersion (

>

>    DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,

>      SmbiosVersion));

> -  PcdSet16 (PcdSmbiosVersion, SmbiosVersion);

> +  PcdStatus = PcdSet16S (PcdSmbiosVersion, SmbiosVersion);

> +  ASSERT_RETURN_ERROR (PcdStatus);

>

>    //

>    // SMBIOS platform drivers can now fetch and install

>    // "etc/smbios/smbios-tables" from QEMU.

>    //

> -  PcdSetBool (PcdQemuSmbiosValidated, TRUE);

> +  PcdStatus = PcdSetBoolS (PcdQemuSmbiosValidated, TRUE);

> +  ASSERT_RETURN_ERROR (PcdStatus);

>    return RETURN_SUCCESS;

>  }

> --

> 2.9.2

>

>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
index 950c3f7e0a31..58180412bd1a 100644
--- a/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
+++ b/OvmfPkg/Library/SmbiosVersionLib/DetectSmbiosVersionLib.c
@@ -40,6 +40,7 @@  DetectSmbiosVersion (
   UINTN                AnchorSize, TablesSize;
   QEMU_SMBIOS_ANCHOR   QemuAnchor;
   UINT16               SmbiosVersion;
+  RETURN_STATUS        PcdStatus;
 
   if (PcdGetBool (PcdQemuSmbiosValidated)) {
     //
@@ -87,7 +88,8 @@  DetectSmbiosVersion (
 
     DEBUG ((EFI_D_INFO, "%a: SMBIOS 3.x DocRev from QEMU: 0x%02x\n",
       __FUNCTION__, QemuAnchor.V3.DocRev));
-    PcdSet8 (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);
+    PcdStatus = PcdSet8S (PcdSmbiosDocRev, QemuAnchor.V3.DocRev);
+    ASSERT_RETURN_ERROR (PcdStatus);
     break;
 
   default:
@@ -96,12 +98,14 @@  DetectSmbiosVersion (
 
   DEBUG ((EFI_D_INFO, "%a: SMBIOS version from QEMU: 0x%04x\n", __FUNCTION__,
     SmbiosVersion));
-  PcdSet16 (PcdSmbiosVersion, SmbiosVersion);
+  PcdStatus = PcdSet16S (PcdSmbiosVersion, SmbiosVersion);
+  ASSERT_RETURN_ERROR (PcdStatus);
 
   //
   // SMBIOS platform drivers can now fetch and install
   // "etc/smbios/smbios-tables" from QEMU.
   //
-  PcdSetBool (PcdQemuSmbiosValidated, TRUE);
+  PcdStatus = PcdSetBoolS (PcdQemuSmbiosValidated, TRUE);
+  ASSERT_RETURN_ERROR (PcdStatus);
   return RETURN_SUCCESS;
 }