]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
*BaseSmbusLib: (new version)
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / UefiDevicePathLib.c
index 8dc84f48b7e3bfe95815eb40255015035a416e96..1b1376e2cf29b287310b0d61516118b3e67d1644 100644 (file)
@@ -155,9 +155,9 @@ AppendDevicePath (
   This function appends the device path node SecondDevicePath\r
   to every device path instance in FirstDevicePath.\r
 \r
-  @param  FirstDevicePath A pointer to a device path data structure.\r
+  @param  DevicePath A pointer to a device path data structure.\r
   \r
-  @param  SecondDevicePath A pointer to a single device path node.\r
+  @param  DevicePathNode A pointer to a single device path node.\r
 \r
   @return A pointer to the new device path.\r
   If there is not enough temporary pool memory available to complete this function,\r
@@ -167,40 +167,37 @@ AppendDevicePath (
 EFI_DEVICE_PATH_PROTOCOL *\r
 EFIAPI\r
 AppendDevicePathNode (\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *FirstDevicePath,\r
-  IN CONST EFI_DEVICE_PATH_PROTOCOL  *SecondDevicePath\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePath,\r
+  IN CONST EFI_DEVICE_PATH_PROTOCOL  *DevicePathNode\r
   )\r
 {\r
+  EFI_DEVICE_PATH_PROTOCOL  *TempDevicePath;\r
   EFI_DEVICE_PATH_PROTOCOL  *NextNode;\r
   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
   UINTN                     NodeLength;\r
-  UINTN                     Size1;\r
 \r
   //\r
   // Build a Node that has a terminator on it\r
   //\r
-  NodeLength  = DevicePathNodeLength (SecondDevicePath);\r
-  Size1       = GetDevicePathSize (FirstDevicePath);\r
-  \r
-  NewDevicePath = AllocatePool (NodeLength + Size1);\r
-  if (NewDevicePath != NULL) {\r
-    //\r
-    // Copy the first device path to the new device path\r
-    //\r
-    NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1);\r
-\r
-    //\r
-    // Copy the device path node to the new device path\r
-    //\r
-    NextNode      = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));\r
-    NextNode      = CopyMem (NextNode, SecondDevicePath, NodeLength);\r
+  NodeLength = DevicePathNodeLength (DevicePathNode);\r
 \r
-    //\r
-    // Terminate the whole device path\r
-    //\r
-    NextNode      = NextDevicePathNode (NextNode);\r
-    SetDevicePathEndNode (NextNode);\r
+  TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL));\r
+  if (TempDevicePath == NULL) {\r
+    return NULL;\r
   }\r
+  TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength);\r
+  //\r
+  // Add and end device path node to convert Node to device path\r
+  //\r
+  NextNode = NextDevicePathNode (TempDevicePath);\r
+  SetDevicePathEndNode (NextNode);\r
+  //\r
+  // Append device paths\r
+  //\r
+  NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath);\r
+\r
+  FreePool (TempDevicePath);\r
+\r
   return NewDevicePath;\r
 }\r
 \r