From c02bdb276baf8c37a42c87dff68fb0d3f264b124 Mon Sep 17 00:00:00 2001 From: wenyi xie Date: Thu, 26 Nov 2020 09:50:33 +0800 Subject: MdeModulePkg/FileExplorerLib: remove redundant null pointer check 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 Cc: Hao A Wu Cc: Dandan Bi Cc: Eric Dong Signed-off-by: Wenyi Xie Reviewed-by: Liming Gao Reviewed-by: Laszlo Ersek --- MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'MdeModulePkg') diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 58e4910259..13a214b06a 100644 --- a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c +++ b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c @@ -821,13 +821,9 @@ LibFindFileSystem ( if (Info == NULL) { VolumeLabel = L"NO FILE SYSTEM INFO"; } else { - if (Info->VolumeLabel == NULL) { - VolumeLabel = L"NULL VOLUME LABEL"; - } else { - VolumeLabel = Info->VolumeLabel; - if (*VolumeLabel == 0x0000) { - VolumeLabel = L"NO VOLUME LABEL"; - } + VolumeLabel = Info->VolumeLabel; + if (*VolumeLabel == 0x0000) { + VolumeLabel = L"NO VOLUME LABEL"; } } MenuEntry->DisplayString = AllocateZeroPool (MAX_CHAR); -- cgit v1.2.3