X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FUefiDevicePathLib%2FUefiDevicePathLibOptionalDevicePathProtocol.c;fp=MdePkg%2FLibrary%2FUefiDevicePathLib%2FUefiDevicePathLibOptionalDevicePathProtocol.c;h=dfe211205b7f18d7ca9178e728d6121c69a36ef7;hp=e1e629442a0fafe8a14898c61585873a5138e5c4;hb=2f88bd3a1296c522317f1c21377876de63de5be7;hpb=1436aea4d5707e672672a11bda72be2c63c936c3 diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c index e1e629442a..dfe211205b 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.c @@ -13,12 +13,11 @@ **/ - #include "UefiDevicePathLib.h" -GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathLibDevicePathUtilities = NULL; -GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathLibDevicePathToText = NULL; -GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLibDevicePathFromText = NULL; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathLibDevicePathUtilities = NULL; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathLibDevicePathToText = NULL; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLibDevicePathFromText = NULL; /** The constructor function caches the pointer to DevicePathUtilites protocol, @@ -37,16 +36,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *mDevicePathLib EFI_STATUS EFIAPI UefiDevicePathLibOptionalDevicePathProtocolConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; + EFI_STATUS Status; Status = gBS->LocateProtocol ( &gEfiDevicePathUtilitiesProtocolGuid, NULL, - (VOID**) &mDevicePathLibDevicePathUtilities + (VOID **)&mDevicePathLibDevicePathUtilities ); ASSERT_EFI_ERROR (Status); ASSERT (mDevicePathLibDevicePathUtilities != NULL); @@ -256,8 +255,8 @@ AppendDevicePathInstance ( EFI_DEVICE_PATH_PROTOCOL * EFIAPI GetNextDevicePathInstance ( - IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, - OUT UINTN *Size + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath, + OUT UINTN *Size ) { if (mDevicePathLibDevicePathUtilities != NULL) { @@ -289,9 +288,9 @@ GetNextDevicePathInstance ( EFI_DEVICE_PATH_PROTOCOL * EFIAPI CreateDeviceNode ( - IN UINT8 NodeType, - IN UINT8 NodeSubType, - IN UINT16 NodeLength + IN UINT8 NodeType, + IN UINT8 NodeSubType, + IN UINT16 NodeLength ) { if (mDevicePathLibDevicePathUtilities != NULL) { @@ -338,15 +337,16 @@ IsDevicePathMultiInstance ( **/ VOID * UefiDevicePathLibLocateProtocol ( - EFI_GUID *ProtocolGuid + EFI_GUID *ProtocolGuid ) { - EFI_STATUS Status; - VOID *Protocol; + EFI_STATUS Status; + VOID *Protocol; + Status = gBS->LocateProtocol ( ProtocolGuid, NULL, - (VOID**) &Protocol + (VOID **)&Protocol ); if (EFI_ERROR (Status)) { return NULL; @@ -381,6 +381,7 @@ ConvertDeviceNodeToText ( if (mDevicePathLibDevicePathToText == NULL) { mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid); } + if (mDevicePathLibDevicePathToText != NULL) { return mDevicePathLibDevicePathToText->ConvertDeviceNodeToText (DeviceNode, DisplayOnly, AllowShortcuts); } @@ -406,14 +407,15 @@ ConvertDeviceNodeToText ( CHAR16 * EFIAPI ConvertDevicePathToText ( - IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, - IN BOOLEAN DisplayOnly, - IN BOOLEAN AllowShortcuts + IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, + IN BOOLEAN DisplayOnly, + IN BOOLEAN AllowShortcuts ) { if (mDevicePathLibDevicePathToText == NULL) { mDevicePathLibDevicePathToText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathToTextProtocolGuid); } + if (mDevicePathLibDevicePathToText != NULL) { return mDevicePathLibDevicePathToText->ConvertDevicePathToText (DevicePath, DisplayOnly, AllowShortcuts); } @@ -435,12 +437,13 @@ ConvertDevicePathToText ( EFI_DEVICE_PATH_PROTOCOL * EFIAPI ConvertTextToDeviceNode ( - IN CONST CHAR16 *TextDeviceNode + IN CONST CHAR16 *TextDeviceNode ) { if (mDevicePathLibDevicePathFromText == NULL) { mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid); } + if (mDevicePathLibDevicePathFromText != NULL) { return mDevicePathLibDevicePathFromText->ConvertTextToDeviceNode (TextDeviceNode); } @@ -463,12 +466,13 @@ ConvertTextToDeviceNode ( EFI_DEVICE_PATH_PROTOCOL * EFIAPI ConvertTextToDevicePath ( - IN CONST CHAR16 *TextDevicePath + IN CONST CHAR16 *TextDevicePath ) { if (mDevicePathLibDevicePathFromText == NULL) { mDevicePathLibDevicePathFromText = UefiDevicePathLibLocateProtocol (&gEfiDevicePathFromTextProtocolGuid); } + if (mDevicePathLibDevicePathFromText != NULL) { return mDevicePathLibDevicePathFromText->ConvertTextToDevicePath (TextDevicePath); }