]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/FileExplorerLib/FileExplorer.c
MdeModulePkg/FileExplorerLib: remove redundant null pointer check
[mirror_edk2.git] / MdeModulePkg / Library / FileExplorerLib / FileExplorer.c
index 9182751ad75bdaaee0f01a10bd132fc0bf4bc43b..13a214b06af9fdc262fababe32abd614a0c4ed6c 100644 (file)
@@ -1,14 +1,8 @@
 /** @file\r
 File explorer related functions.\r
 \r
-Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under\r
-the terms and conditions of the BSD License that accompanies this distribution.\r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2019, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -61,7 +55,7 @@ HII_VENDOR_DEVICE_PATH  FeHiiVendorDevicePath = {
   {\r
     END_DEVICE_PATH_TYPE,\r
     END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
-    { \r
+    {\r
       (UINT8) (END_DEVICE_PATH_LENGTH),\r
       (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
     }\r
@@ -554,7 +548,7 @@ LibFileInfo (
 \r
   Buffer      = NULL;\r
   BufferSize  = 0;\r
-  \r
+\r
   Status = FHand->GetInfo (\r
                     FHand,\r
                     InfoType,\r
@@ -691,19 +685,19 @@ LibAppendFileName (
 \r
   Size1 = StrSize (Str1);\r
   Size2 = StrSize (Str2);\r
-  \r
+\r
   //\r
   // Check overflow\r
   //\r
   if (((MAX_UINTN - Size1) < Size2) || ((MAX_UINTN - Size1 - Size2) < sizeof(CHAR16))) {\r
     return NULL;\r
   }\r
-  \r
+\r
   MaxLen = (Size1 + Size2 + sizeof (CHAR16))/ sizeof (CHAR16);\r
   Str   = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
   ASSERT (Str != NULL);\r
 \r
-  TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16)); \r
+  TmpStr = AllocateZeroPool (Size1 + Size2 + sizeof (CHAR16));\r
   ASSERT (TmpStr != NULL);\r
 \r
   StrCpyS (Str, MaxLen, Str1);\r
@@ -724,7 +718,7 @@ LibAppendFileName (
       //\r
 \r
       //\r
-      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings \r
+      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
       // that overlap.\r
       //\r
       StrCpyS (TmpStr, MaxLen, Ptr + 3);\r
@@ -736,7 +730,7 @@ LibAppendFileName (
       //\r
 \r
       //\r
-      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings \r
+      // Use TmpStr as a backup, as StrCpyS in BaseLib does not handle copy of two strings\r
       // that overlap.\r
       //\r
       StrCpyS (TmpStr, MaxLen, Ptr + 2);\r
@@ -750,7 +744,7 @@ LibAppendFileName (
   }\r
 \r
   FreePool (TmpStr);\r
-  \r
+\r
   return Str;\r
 }\r
 \r
@@ -827,13 +821,9 @@ LibFindFileSystem (
       if (Info == NULL) {\r
         VolumeLabel = L"NO FILE SYSTEM INFO";\r
       } else {\r
-        if (Info->VolumeLabel == NULL) {\r
-          VolumeLabel = L"NULL VOLUME LABEL";\r
-        } else {\r
-          VolumeLabel = Info->VolumeLabel;\r
-          if (*VolumeLabel == 0x0000) {\r
-            VolumeLabel = L"NO VOLUME LABEL";\r
-          }\r
+        VolumeLabel = Info->VolumeLabel;\r
+        if (*VolumeLabel == 0x0000) {\r
+          VolumeLabel = L"NO VOLUME LABEL";\r
         }\r
       }\r
       MenuEntry->DisplayString  = AllocateZeroPool (MAX_CHAR);\r
@@ -845,7 +835,7 @@ LibFindFileSystem (
         VolumeLabel,\r
         MenuEntry->HelpString\r
         );\r
-         MenuEntry->DisplayStringToken = HiiSetString (\r
+      MenuEntry->DisplayStringToken = HiiSetString (\r
                                              gFileExplorerPrivate.FeHiiHandle,\r
                                              0,\r
                                              MenuEntry->DisplayString,\r
@@ -871,16 +861,16 @@ LibFindFileSystem (
 \r
 /**\r
   Find the file handle from the input menu info.\r
-  \r
+\r
   @param  MenuEntry        Input Menu info.\r
   @param  RetFileHandle    Return the file handle for the input device path.\r
-  \r
+\r
   @retval EFI_SUCESS       Find the file handle success.\r
   @retval Other            Find the file handle failure.\r
 **/\r
 EFI_STATUS\r
 LibGetFileHandleFromMenu (\r
-  IN  MENU_ENTRY                *MenuEntry,  \r
+  IN  MENU_ENTRY                *MenuEntry,\r
   OUT EFI_FILE_HANDLE           *RetFileHandle\r
   )\r
 {\r
@@ -917,18 +907,18 @@ LibGetFileHandleFromMenu (
 \r
 /**\r
   Find the file handle from the input device path info.\r
-  \r
+\r
   @param  RootDirectory    Device path info.\r
   @param  RetFileHandle    Return the file handle for the input device path.\r
   @param  ParentFileName   Parent file name.\r
   @param  DeviceHandle     Driver handle for this partition.\r
-  \r
+\r
   @retval EFI_SUCESS       Find the file handle success.\r
   @retval Other            Find the file handle failure.\r
 **/\r
 EFI_STATUS\r
 LibGetFileHandleFromDevicePath (\r
-  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDirectory,  \r
+  IN  EFI_DEVICE_PATH_PROTOCOL  *RootDirectory,\r
   OUT EFI_FILE_HANDLE           *RetFileHandle,\r
   OUT UINT16                    **ParentFileName,\r
   OUT EFI_HANDLE                *DeviceHandle\r
@@ -953,12 +943,12 @@ LibGetFileHandleFromDevicePath (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   Status = gBS->HandleProtocol (Handle, &gEfiSimpleFileSystemProtocolGuid, (VOID**)&Volume);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Open the Volume to get the File System handle\r
   //\r
@@ -974,7 +964,7 @@ LibGetFileHandleFromDevicePath (
     *RetFileHandle = FileHandle;\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   //\r
   // Duplicate the device path to avoid the access to unaligned device path node.\r
   // Because the device path consists of one or more FILE PATH MEDIA DEVICE PATH\r
@@ -990,7 +980,7 @@ LibGetFileHandleFromDevicePath (
     Status = EFI_OUT_OF_RESOURCES;\r
     goto Done;\r
   }\r
-        \r
+\r
   //\r
   // Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the\r
   // directory information and filename can be seperate. The goal is to inch\r
@@ -1123,11 +1113,11 @@ LibCreateNewFile (
 \r
 /**\r
   Find files under current directory.\r
-  \r
+\r
   All files and sub-directories in current directory\r
   will be stored in DirectoryMenu for future use.\r
 \r
-  @param FileHandle    Parent file handle. \r
+  @param FileHandle    Parent file handle.\r
   @param FileName      Parent file name.\r
   @param DeviceHandle  Driver handle for this partition.\r
 \r
@@ -1223,7 +1213,7 @@ LibFindFiles (
       } else {\r
         NewMenuEntry->DisplayString = LibStrDuplicate (DirInfo->FileName);\r
       }\r
-      \r
+\r
       NewMenuEntry->DisplayStringToken = HiiSetString (\r
                                            gFileExplorerPrivate.FeHiiHandle,\r
                                            0,\r
@@ -1459,7 +1449,7 @@ LibGetDevicePath (
 }\r
 \r
 /**\r
-  Choose a file in the specified directory. \r
+  Choose a file in the specified directory.\r
 \r
   If user input NULL for the RootDirectory, will choose file in the system.\r
 \r
@@ -1612,7 +1602,7 @@ FileExplorerLibConstructor (
   //\r
   Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &gFileExplorerPrivate.FormBrowser2);\r
   ASSERT_EFI_ERROR (Status);\r
-    \r
+\r
   InitializeListHead (&gFileExplorerPrivate.FsOptionMenu->Head);\r
 \r
   return EFI_SUCCESS;\r
@@ -1647,8 +1637,9 @@ FileExplorerLibDestructor (
                     NULL\r
                     );\r
     ASSERT_EFI_ERROR (Status);\r
-    \r
+\r
     HiiRemovePackages (gFileExplorerPrivate.FeHiiHandle);\r
+    gFileExplorerPrivate.FeDriverHandle = NULL;\r
   }\r
 \r
   FreePool (gHiiVendorDevicePath);\r