[edk2-devel] [PATCH v1 27/41] PrmPkg: Enforce stricter types

Michael Kubacki mikuback at linux.microsoft.com
Tue Mar 22 16:19:33 UTC 2022


From: Michael Kubacki <michael.kubacki at microsoft.com>

Makes the following changes to enforce stricter types:

1. PrmPkg/PrmConfigDxe

   The function PrmConfigEndOfDxeNotification () is used as a notify
   function (of type EFI_EVENT_NOTIFY), however it has a return type
   of EFI_STATUS whereas the return type should actually be VOID.

2. PrmPkg/PrmLoaderDxe

   Updates the following types to be more accurate than were allowed
   in the VS compiler:
   * 3rd actual argument given to GetModuleContextBuffers () is
     explicitly marked as CONST PRM_MODULE_CONTEXT_BUFFERS **

   * 3rd actual argument given to GetContextBuffer () is
     explicitly marked as CONST PRM_CONTEXT_BUFFER **

   * PrmLoaderEndOfDxeNotification () return type is changed to VOID
     to align with the EFI_EVENT_NOTIFY type

3. PrmPkg/Application/PrmInfo

   Updates the following types to be more accurate than were allowed
   in the VS compiler:
   * SHELL_STATUS in ParseParameterList () is now EFI_STATUS

   * 3rd actual argument given to GetModuleContextBuffers () is
     explicitly marked as CONST PRM_MODULE_CONTEXT_BUFFERS **

   * 3rd actual argument given to GetContextBuffer () is
     explicitly marked as CONST PRM_CONTEXT_BUFFER **

Cc: Andrew Fish <afish at apple.com>
Cc: Kang Gao <kang.gao at intel.com>
Cc: Michael D Kinney <michael.d.kinney at intel.com>
Cc: Michael Kubacki <michael.kubacki at microsoft.com>
Cc: Leif Lindholm <leif at nuviainc.com>
Cc: Benjamin You <benjamin.you at intel.com>
Cc: Liu Yun <yun.y.liu at intel.com>
Cc: Ankit Sinha <ankit.sinha at intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki at microsoft.com>
---
 PrmPkg/Application/PrmInfo/PrmInfo.c |  6 +++---
 PrmPkg/PrmConfigDxe/PrmConfigDxe.c   |  8 ++------
 PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c   | 10 +++-------
 3 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/PrmPkg/Application/PrmInfo/PrmInfo.c b/PrmPkg/Application/PrmInfo/PrmInfo.c
index 431a6f206163..e479667ec7eb 100644
--- a/PrmPkg/Application/PrmInfo/PrmInfo.c
+++ b/PrmPkg/Application/PrmInfo/PrmInfo.c
@@ -221,7 +221,7 @@ GatherPrmHandlerInfo (
     Status = GetModuleContextBuffers (
               ByModuleGuid,
               CurrentModuleGuid,
-              &CurrentModuleContextBuffers
+              (CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers
               );
     ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
     if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) {
@@ -272,7 +272,7 @@ GatherPrmHandlerInfo (
       Status =  GetContextBuffer (
                   CurrentHandlerContext.Guid,
                   CurrentModuleContextBuffers,
-                  &CurrentContextBuffer
+                  (CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer
                   );
       if (!EFI_ERROR (Status)) {
         CurrentHandlerContext.StaticDataBuffer = CurrentContextBuffer->StaticDataBuffer;
@@ -520,7 +520,7 @@ ParseParameterList (
   )
 {
   EFI_STATUS                            Status;
-  SHELL_STATUS                          ReturnStatus;
+  EFI_STATUS                            ReturnStatus;
   UINTN                                 ArgumentCount;
   EFI_GUID                              HandlerGuid;
   BOOLEAN                               PrintHandlerInfo;
diff --git a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c
index c547db3eca5e..f3223d63de0c 100644
--- a/PrmPkg/PrmConfigDxe/PrmConfigDxe.c
+++ b/PrmPkg/PrmConfigDxe/PrmConfigDxe.c
@@ -361,10 +361,8 @@ PrmConfigVirtualAddressChangeEvent (
   @param[in]  Context         The pointer to the notification function's context,
                               which is implementation-dependent.
 
-  @retval EFI_SUCCESS         The function executed successfully
-
 **/
-EFI_STATUS
+VOID
 EFIAPI
 PrmConfigEndOfDxeNotification (
   IN  EFI_EVENT               Event,
@@ -446,8 +444,6 @@ PrmConfigEndOfDxeNotification (
     gBS->FreePool (HandleBuffer);
   }
   gBS->CloseEvent(Event);
-
-  return EFI_SUCCESS;
 }
 
 /**
@@ -476,7 +472,7 @@ PrmConfigEntryPoint (
   // Register a notification function to change memory attributes at end of DXE
   //
   Event = NULL;
-  Status = gBS->CreateEventEx(
+  Status = gBS->CreateEventEx (
                   EVT_NOTIFY_SIGNAL,
                   TPL_CALLBACK,
                   PrmConfigEndOfDxeNotification,
diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
index 407c48257432..aa7aab391e8c 100644
--- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
+++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
@@ -151,7 +151,7 @@ ProcessPrmModules (
     Status = GetModuleContextBuffers (
               ByModuleGuid,
               &CurrentModuleInfoStruct->Identifier,
-              &CurrentModuleContextBuffers
+              (CONST PRM_MODULE_CONTEXT_BUFFERS **) &CurrentModuleContextBuffers
               );
     ASSERT (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND);
     if (!EFI_ERROR (Status) && CurrentModuleContextBuffers != NULL) {
@@ -177,7 +177,7 @@ ProcessPrmModules (
       Status =  GetContextBuffer (
                   &CurrentHandlerInfoStruct->Identifier,
                   CurrentModuleContextBuffers,
-                  &CurrentContextBuffer
+                  (CONST PRM_CONTEXT_BUFFER **) &CurrentContextBuffer
                   );
       if (!EFI_ERROR (Status)) {
         CurrentHandlerInfoStruct->StaticDataBuffer = (UINT64) (UINTN) CurrentContextBuffer->StaticDataBuffer;
@@ -286,10 +286,8 @@ PublishPrmAcpiTable (
   @param[in]  Context                     The pointer to the notification function's context,
                                           which is implementation-dependent.
 
-  @retval EFI_SUCCESS                     The function executed successfully
-
 **/
-EFI_STATUS
+VOID
 EFIAPI
 PrmLoaderEndOfDxeNotification (
   IN  EFI_EVENT                           Event,
@@ -314,8 +312,6 @@ PrmLoaderEndOfDxeNotification (
     FreePool (PrmAcpiDescriptionTable);
   }
   gBS->CloseEvent (Event);
-
-  return EFI_SUCCESS;
 }
 
 /**
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#87869): https://edk2.groups.io/g/devel/message/87869
Mute This Topic: https://groups.io/mt/89956018/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list