]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix LocateDevicePath() to return proper error status code. It was returning EFI_INVA...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Mar 2011 16:17:09 +0000 (16:17 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Mar 2011 16:17:09 +0000 (16:17 +0000)
Also update function header comment block for LocateDevicePath() to match UEFI Specification.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11406 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/Hand/Locate.c

index df7fa8fa6dc0ebd174babb07a1542c2cd08ff9d8..d4bc63c2ee7084cf81b603facff2402be263d8be 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Locate handle functions\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -406,18 +406,19 @@ CoreGetNextLocateByProtocol (
 \r
 \r
 /**\r
-  Locates the handle to a device on the device path that best matches the specified protocol.\r
+  Locates the handle to a device on the device path that supports the specified protocol.\r
 \r
-  @param  Protocol               The protocol to search for.\r
-  @param  DevicePath             On input, a pointer to a pointer to the device\r
-                                 path. On output, the device path pointer is\r
-                                 modified to point to the remaining part of the\r
-                                 devicepath.\r
-  @param  Device                 A pointer to the returned device handle.\r
+  @param  Protocol              Specifies the protocol to search for.\r
+  @param  DevicePath            On input, a pointer to a pointer to the device path. On output, the device\r
+                                path pointer is modified to point to the remaining part of the device\r
+                                path.\r
+  @param  Device                A pointer to the returned device handle.\r
 \r
-  @retval EFI_SUCCESS            The resulting handle was returned.\r
-  @retval EFI_NOT_FOUND          No handles matched the search.\r
-  @retval EFI_INVALID_PARAMETER  One of the parameters has an invalid value.\r
+  @retval EFI_SUCCESS           The resulting handle was returned.\r
+  @retval EFI_NOT_FOUND         No handles match the search.\r
+  @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
+  @retval EFI_INVALID_PARAMETER DevicePath is NULL.\r
+  @retval EFI_INVALID_PARAMETER A handle matched the search and Device is NULL.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -436,6 +437,7 @@ CoreLocateDevicePath (
   EFI_STATUS                  Status;\r
   EFI_HANDLE                  *Handles;\r
   EFI_HANDLE                  Handle;\r
+  EFI_HANDLE                  BestDevice;\r
   EFI_DEVICE_PATH_PROTOCOL    *SourcePath;\r
   EFI_DEVICE_PATH_PROTOCOL    *TmpDevicePath;\r
 \r
@@ -447,11 +449,7 @@ CoreLocateDevicePath (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  if (Device == NULL) {\r
-    return  EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  *Device = NULL;\r
+  BestDevice = NULL;\r
   SourcePath = *DevicePath;\r
   TmpDevicePath = SourcePath;\r
   while (!IsDevicePathEnd (TmpDevicePath)) {\r
@@ -504,7 +502,7 @@ CoreLocateDevicePath (
       //\r
       if (Size > BestMatch) {\r
         BestMatch = Size;\r
-        *Device = Handle;\r
+        BestDevice = Handle;\r
       }\r
     }\r
   }\r
@@ -519,6 +517,11 @@ CoreLocateDevicePath (
     return EFI_NOT_FOUND;\r
   }\r
 \r
+  if (Device == NULL) {\r
+    return  EFI_INVALID_PARAMETER;\r
+  }\r
+  *Device = BestDevice;\r
+  \r
   //\r
   // Return the remaining part of the device path\r
   //\r