]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/FileExplorerLib: remove redundant null pointer check
authorwenyi xie <xiewenyi2=huawei.com@groups.io>
Thu, 26 Nov 2020 01:50:33 +0000 (09:50 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 4 Dec 2020 05:56:09 +0000 (05:56 +0000)
If "Info" is a valid pointer to an EFI_FILE_SYSTEM_VOLUME_LABEL
structure, then "Info->VolumeLabel" denotes a valid array object.
When the "Info->VolumeLabel" expression is evaluated, as seen in
the LibFindFileSystem(), it is implicitly converted to
(&Info->VolumeLabel[0]). Because the object described by the
expression (Info->VolumeLabel[0]) is a valid CHAR16 object, its
address can never compare equal to NULL. Therefore, the condition
(Info->VolumeLabel == NULL) will always evaluate to FALSE.
Substitute the constant FALSE into the "if" statement, and
simplify the resultant code (eliminate the dead branch).

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
MdeModulePkg/Library/FileExplorerLib/FileExplorer.c

index 58e49102593cfc4632ca009d1e81e012d6fe698a..13a214b06af9fdc262fababe32abd614a0c4ed6c 100644 (file)
@@ -821,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