[edk2-platforms][PATCH v1 5/5] MinPlatformPkg/TestPointCheckLib: Make OutTable parameter optional


Michael Kubacki
 

From: Michael Kubacki <michael.kubacki@...>

Makes the OutTable parameter in DumpAcpiRsdt() and DumpAcpiXsdt()
optional since the pointer passed can be NULL if the Signature
pointer is also NULL.

Can fix a potential failure in TestPointCheckAcpi().

Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Michael Kubacki <michael.kubacki@...>
---
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcp=
i.c | 32 ++++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib=
/DxeCheckAcpi.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointChe=
ckLib/DxeCheckAcpi.c
index cd8f538f7f3f..3d75e5012a4c 100644
--- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChe=
ckAcpi.c
+++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeChe=
ckAcpi.c
@@ -477,7 +477,7 @@ DumpAcpiTable (
)
{
EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
- =20
+
if (Table =3D=3D NULL) {
return ;
}
@@ -535,7 +535,7 @@ CheckAcpiTableResource (
)
{
EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
- =20
+
if (Table =3D=3D NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -592,7 +592,7 @@ EFI_STATUS
DumpAcpiRsdt (
IN EFI_ACPI_DESCRIPTION_HEADER *Rsdt,
IN UINT32 *Signature, OPTIONAL
- OUT VOID **OutTable,
+ OUT VOID **OutTable, OPTIONAL
IN BOOLEAN DumpPrint,
IN BOOLEAN CheckResource
)
@@ -610,7 +610,7 @@ DumpAcpiRsdt (
=20
if (OutTable !=3D NULL) {
*OutTable =3D NULL;
- } else {
+ } else if ((OutTable =3D=3D NULL) && (Signature !=3D NULL)) {
return EFI_INVALID_PARAMETER;
}
=20
@@ -632,7 +632,7 @@ DumpAcpiRsdt (
*OutTable =3D Table;
}
}
- =20
+
if (OutTable !=3D NULL) {
if (*OutTable =3D=3D NULL) {
return EFI_NOT_FOUND;
@@ -646,7 +646,7 @@ EFI_STATUS
DumpAcpiXsdt (
IN EFI_ACPI_DESCRIPTION_HEADER *Xsdt,
IN UINT32 *Signature, OPTIONAL
- OUT VOID **OutTable,
+ OUT VOID **OutTable, OPTIONAL
IN BOOLEAN DumpPrint,
IN BOOLEAN CheckResource
)
@@ -662,16 +662,16 @@ DumpAcpiXsdt (
if (Xsdt =3D=3D NULL) {
return EFI_INVALID_PARAMETER;
}
- =20
+
if (OutTable !=3D NULL) {
*OutTable =3D NULL;
- } else {
+ } else if ((OutTable =3D=3D NULL) && (Signature !=3D NULL)) {
return EFI_INVALID_PARAMETER;
}
=20
ReturnStatus =3D EFI_SUCCESS;
EntryCount =3D (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /=
sizeof(UINT64);
- =20
+
BasePtr =3D (UINTN)(Xsdt + 1);
for (Index =3D 0; Index < EntryCount; Index ++) {
CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), size=
of(UINT64));
@@ -783,7 +783,7 @@ TestPointCheckAcpi (
if (Status =3D=3D EFI_NOT_FOUND) {
Status =3D DumpAcpiWithGuid (&gEfiAcpi10TableGuid, NULL, NULL, TRUE,=
FALSE);
}
- =20
+
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_ERROR, "No ACPI table\n"));
TestPointLibAppendErrorString (
@@ -796,7 +796,7 @@ TestPointCheckAcpi (
}
=20
DEBUG ((DEBUG_INFO, "=3D=3D=3D=3D TestPointCheckAcpi - Exit\n"));
- =20
+
return Status;
}
=20
@@ -806,9 +806,9 @@ TestPointCheckAcpiGcdResource (
)
{
EFI_STATUS Status;
- =20
+
DEBUG ((DEBUG_INFO, "=3D=3D=3D=3D TestPointCheckAcpiGcdResource - Ente=
r\n"));
- =20
+
//
// Check the ACPI existence
//
@@ -816,7 +816,7 @@ TestPointCheckAcpiGcdResource (
if (Status =3D=3D EFI_NOT_FOUND) {
Status =3D DumpAcpiWithGuid (&gEfiAcpi10TableGuid, NULL, NULL, FALSE=
, FALSE);
}
- =20
+
if (!EFI_ERROR(Status)) {
//
// Then check resource in ACPI and GCD
@@ -828,7 +828,7 @@ TestPointCheckAcpiGcdResource (
Status =3D DumpAcpiWithGuid (&gEfiAcpi10TableGuid, NULL, NULL, FAL=
SE, TRUE);
}
}
- =20
+
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_ERROR, "ACPI table resource not in GCD\n"));
TestPointLibAppendErrorString (
@@ -840,7 +840,7 @@ TestPointCheckAcpiGcdResource (
);
}
DEBUG ((DEBUG_INFO, "=3D=3D=3D=3D TestPointCheckAcpiGcdResource - Exit=
\n"));
- =20
+
return Status;
}
=20
--=20
2.28.0.windows.1


Nate DeSimone
 

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@...>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
Kubacki
Sent: Thursday, August 5, 2021 7:57 AM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@...>; Desimone, Nathaniel L
<nathaniel.l.desimone@...>; Liming Gao
<gaoliming@...>; Dong, Eric <eric.dong@...>
Subject: [edk2-devel] [edk2-platforms][PATCH v1 5/5]
MinPlatformPkg/TestPointCheckLib: Make OutTable parameter optional

From: Michael Kubacki <michael.kubacki@...>

Makes the OutTable parameter in DumpAcpiRsdt() and DumpAcpiXsdt()
optional since the pointer passed can be NULL if the Signature pointer is also
NULL.

Can fix a potential failure in TestPointCheckAcpi().

Cc: Chasel Chiu <chasel.chiu@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Michael Kubacki <michael.kubacki@...>
---

Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckA
cpi.c | 32 ++++++++++----------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck
Acpi.c
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck
Acpi.c
index cd8f538f7f3f..3d75e5012a4c 100644
---
a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck
Acpi.c
+++
b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh
+++ eckAcpi.c
@@ -477,7 +477,7 @@ DumpAcpiTable (
)
{
EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
-
+
if (Table == NULL) {
return ;
}
@@ -535,7 +535,7 @@ CheckAcpiTableResource (
)
{
EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
-
+
if (Table == NULL) {
return EFI_INVALID_PARAMETER;
}
@@ -592,7 +592,7 @@ EFI_STATUS
DumpAcpiRsdt (
IN EFI_ACPI_DESCRIPTION_HEADER *Rsdt,
IN UINT32 *Signature, OPTIONAL
- OUT VOID **OutTable,
+ OUT VOID **OutTable, OPTIONAL
IN BOOLEAN DumpPrint,
IN BOOLEAN CheckResource
)
@@ -610,7 +610,7 @@ DumpAcpiRsdt (

if (OutTable != NULL) {
*OutTable = NULL;
- } else {
+ } else if ((OutTable == NULL) && (Signature != NULL)) {
return EFI_INVALID_PARAMETER;
}

@@ -632,7 +632,7 @@ DumpAcpiRsdt (
*OutTable = Table;
}
}
-
+
if (OutTable != NULL) {
if (*OutTable == NULL) {
return EFI_NOT_FOUND;
@@ -646,7 +646,7 @@ EFI_STATUS
DumpAcpiXsdt (
IN EFI_ACPI_DESCRIPTION_HEADER *Xsdt,
IN UINT32 *Signature, OPTIONAL
- OUT VOID **OutTable,
+ OUT VOID **OutTable, OPTIONAL
IN BOOLEAN DumpPrint,
IN BOOLEAN CheckResource
)
@@ -662,16 +662,16 @@ DumpAcpiXsdt (
if (Xsdt == NULL) {
return EFI_INVALID_PARAMETER;
}
-
+
if (OutTable != NULL) {
*OutTable = NULL;
- } else {
+ } else if ((OutTable == NULL) && (Signature != NULL)) {
return EFI_INVALID_PARAMETER;
}

ReturnStatus = EFI_SUCCESS;
EntryCount = (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) /
sizeof(UINT64);
-
+
BasePtr = (UINTN)(Xsdt + 1);
for (Index = 0; Index < EntryCount; Index ++) {
CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)),
sizeof(UINT64)); @@ -783,7 +783,7 @@ TestPointCheckAcpi (
if (Status == EFI_NOT_FOUND) {
Status = DumpAcpiWithGuid (&gEfiAcpi10TableGuid, NULL, NULL, TRUE,
FALSE);
}
-
+
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_ERROR, "No ACPI table\n"));
TestPointLibAppendErrorString (
@@ -796,7 +796,7 @@ TestPointCheckAcpi (
}

DEBUG ((DEBUG_INFO, "==== TestPointCheckAcpi - Exit\n"));
-
+
return Status;
}

@@ -806,9 +806,9 @@ TestPointCheckAcpiGcdResource (
)
{
EFI_STATUS Status;
-
+
DEBUG ((DEBUG_INFO, "==== TestPointCheckAcpiGcdResource -
Enter\n"));
-
+
//
// Check the ACPI existence
//
@@ -816,7 +816,7 @@ TestPointCheckAcpiGcdResource (
if (Status == EFI_NOT_FOUND) {
Status = DumpAcpiWithGuid (&gEfiAcpi10TableGuid, NULL, NULL, FALSE,
FALSE);
}
-
+
if (!EFI_ERROR(Status)) {
//
// Then check resource in ACPI and GCD @@ -828,7 +828,7 @@
TestPointCheckAcpiGcdResource (
Status = DumpAcpiWithGuid (&gEfiAcpi10TableGuid, NULL, NULL, FALSE,
TRUE);
}
}
-
+
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_ERROR, "ACPI table resource not in GCD\n"));
TestPointLibAppendErrorString (
@@ -840,7 +840,7 @@ TestPointCheckAcpiGcdResource (
);
}
DEBUG ((DEBUG_INFO, "==== TestPointCheckAcpiGcdResource - Exit\n"));
-
+
return Status;
}

--
2.28.0.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#78715): https://edk2.groups.io/g/devel/message/78715
Mute This Topic: https://groups.io/mt/84686310/1767664
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub
[nathaniel.l.desimone@...]
-=-=-=-=-=-=