[edk2] [PATCH 6/7] MdeModulePkg/Udf: Avoid declaring and initializing local GUID variable

Hao Wu posted 7 patches 7 years, 3 months ago
[edk2] [PATCH 6/7] MdeModulePkg/Udf: Avoid declaring and initializing local GUID variable
Posted by Hao Wu 7 years, 3 months ago
The local GUID variable 'UdfDevPathGuid', it has been initialized during
its declaration.

For better coding style, this commit uses a global variable instead.

Cc: Paulo Alcantara <pcacjr@zytor.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c            | 8 ++++++--
 MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c | 8 ++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
index c566bfc594..609f56cef6 100644
--- a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
+++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c
@@ -28,6 +28,11 @@ typedef struct {
 } UDF_DEVICE_PATH;
 
 //
+// Vendor-Defined Device Path GUID for UDF file system
+//
+EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
+
+//
 // Vendor-Defined Media Device Path for UDF file system
 //
 UDF_DEVICE_PATH gUdfDevicePath = {
@@ -260,7 +265,6 @@ PartitionInstallUdfChildHandles (
   EFI_BLOCK_IO_MEDIA           *Media;
   EFI_DEVICE_PATH_PROTOCOL     *DevicePathNode;
   EFI_GUID                     *VendorDefinedGuid;
-  EFI_GUID                     UdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
   EFI_PARTITION_INFO_PROTOCOL  PartitionInfo;
 
   Media = BlockIo->Media;
@@ -291,7 +295,7 @@ PartitionInstallUdfChildHandles (
       if (DevicePathSubType (DevicePathNode) == MEDIA_VENDOR_DP) {
         VendorDefinedGuid = (EFI_GUID *)((UINTN)DevicePathNode +
                                          OFFSET_OF (VENDOR_DEVICE_PATH, Guid));
-        if (CompareGuid (VendorDefinedGuid, &UdfDevPathGuid)) {
+        if (CompareGuid (VendorDefinedGuid, &gUdfDevPathGuid)) {
           return EFI_NOT_FOUND;
         }
       }
diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
index 90862932fd..dfbf6b3f95 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/FileSystemOperations.c
@@ -14,6 +14,11 @@
 
 #include "Udf.h"
 
+//
+// Vendor-Defined Device Path GUID for UDF file system
+//
+EFI_GUID gUdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
+
 /**
   Find the anchor volume descriptor pointer.
 
@@ -2650,7 +2655,6 @@ SupportUdfFileSystem (
   EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode;
   EFI_DEVICE_PATH_PROTOCOL  *LastDevicePathNode;
   EFI_GUID                  *VendorDefinedGuid;
-  EFI_GUID                  UdfDevPathGuid = EFI_UDF_DEVICE_PATH_GUID;
 
   //
   // Open Device Path protocol on ControllerHandle
@@ -2687,7 +2691,7 @@ SupportUdfFileSystem (
       DevicePathSubType (LastDevicePathNode) == MEDIA_VENDOR_DP) {
     VendorDefinedGuid = (EFI_GUID *)((UINTN)LastDevicePathNode +
                                      OFFSET_OF (VENDOR_DEVICE_PATH, Guid));
-    if (CompareGuid (VendorDefinedGuid, &UdfDevPathGuid)) {
+    if (CompareGuid (VendorDefinedGuid, &gUdfDevPathGuid)) {
       Status = EFI_SUCCESS;
     }
   }
-- 
2.12.0.windows.1

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