]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiSortLib/UefiSortLib.c
MdeModulePkg/PartitionDxe: Fixed El Torito support when the medium is not a CDROM
[mirror_edk2.git] / ShellPkg / Library / UefiSortLib / UefiSortLib.c
index 73ee7830fc46c79597c6175721a566c7f1393aa1..2aab9d26919eb472076d416de3c6b2ced3fb2151 100644 (file)
 **/\r
 \r
 #include <Uefi.h>\r
+#include <ShellBase.h>\r
 \r
 #include <Protocol/UnicodeCollation.h>\r
 #include <Protocol/DevicePath.h>\r
-#include <Protocol/DevicePathToText.h>\r
 \r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
@@ -24,8 +24,8 @@
 #include <Library/DebugLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/SortLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
-STATIC EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;\r
 STATIC EFI_UNICODE_COLLATION_PROTOCOL   *mUnicodeCollation = NULL;\r
 \r
 \r
@@ -223,15 +223,6 @@ DevicePathCompare (
     return 1;\r
   }\r
 \r
-  if (mDevicePathToText == NULL) {\r
-    Status = gBS->LocateProtocol(\r
-      &gEfiDevicePathToTextProtocolGuid,\r
-      NULL,\r
-      (VOID**)&mDevicePathToText);\r
-\r
-    ASSERT_EFI_ERROR(Status);\r
-  }\r
-\r
   if (mUnicodeCollation == NULL) {\r
     Status = gBS->LocateProtocol(\r
       &gEfiUnicodeCollation2ProtocolGuid,\r
@@ -241,23 +232,29 @@ DevicePathCompare (
     ASSERT_EFI_ERROR(Status);\r
   }\r
 \r
-  TextPath1 = mDevicePathToText->ConvertDevicePathToText(\r
+  TextPath1 = ConvertDevicePathToText(\r
     DevicePath1,\r
     FALSE,\r
     FALSE);\r
 \r
-  TextPath2 = mDevicePathToText->ConvertDevicePathToText(\r
+  TextPath2 = ConvertDevicePathToText(\r
     DevicePath2,\r
     FALSE,\r
     FALSE);\r
 \r
-  RetVal = mUnicodeCollation->StriColl(\r
-    mUnicodeCollation,\r
-    TextPath1,\r
-    TextPath2);\r
+  if (TextPath1 == NULL) {\r
+    RetVal = -1;\r
+  } else if (TextPath2 == NULL) {\r
+    RetVal = 1;\r
+  } else {\r
+    RetVal = mUnicodeCollation->StriColl(\r
+      mUnicodeCollation,\r
+      TextPath1,\r
+      TextPath2);\r
+  }\r
 \r
-  FreePool(TextPath1);\r
-  FreePool(TextPath2);\r
+  SHELL_FREE_NON_NULL(TextPath1);\r
+  SHELL_FREE_NON_NULL(TextPath2);\r
 \r
   return (RetVal);\r
 }\r