MdeModulePkg/ResetUtilityLib: Add pack(1) for reset data structure
authorRuiyu Ni <ruiyu.ni@intel.com>
Mon, 2 Jul 2018 03:13:17 +0000 (11:13 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 3 Jul 2018 06:39:56 +0000 (14:39 +0800)
RESET_UTILITY_GUID_SPECIFIC_RESET_DATA structure should be declared
as pack(1).
The patch adds the missing pack(1) pragma.

(GUID *)((UINT8 *)&ResetData +
OFFSET_OF (RESET_UTILITY_GUID_SPECIFIC_RESET_DATA, ResetSubtype))
is used to replace &ResetData.ResetSubType to resolve C4366 VS
compiler warning.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Library/ResetUtilityLib/ResetUtility.c

index e3de4f1..46a9ac6 100644 (file)
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/ResetSystemLib.h>\r
 \r
+#pragma pack(1)\r
 typedef struct {\r
   CHAR16 NullTerminator;\r
   GUID   ResetSubtype;\r
 } RESET_UTILITY_GUID_SPECIFIC_RESET_DATA;\r
+#pragma pack()\r
+\r
+VERIFY_SIZE_OF (RESET_UTILITY_GUID_SPECIFIC_RESET_DATA, 18);\r
 \r
 /**\r
   This is a shorthand helper function to reset with a subtype so that\r
@@ -49,7 +53,10 @@ ResetPlatformSpecificGuid (
   RESET_UTILITY_GUID_SPECIFIC_RESET_DATA  ResetData;\r
 \r
   ResetData.NullTerminator = CHAR_NULL;\r
-  CopyGuid (&ResetData.ResetSubtype, ResetSubtype);\r
+  CopyGuid (\r
+    (GUID *)((UINT8 *)&ResetData + OFFSET_OF (RESET_UTILITY_GUID_SPECIFIC_RESET_DATA, ResetSubtype)),\r
+    ResetSubtype\r
+    );\r
   ResetPlatformSpecific (sizeof (ResetData), &ResetData);\r
 }\r
 \r