From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by mx.groups.io with SMTP id smtpd.web11.5966.1606355537142237501 for ; Wed, 25 Nov 2020 17:52:17 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.191, mailfrom: xiewenyi2@huawei.com) Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4ChLN61my5zhgf6; Thu, 26 Nov 2020 09:51:50 +0800 (CST) Received: from HGH1000039998.huawei.com (10.184.68.188) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 26 Nov 2020 09:52:04 +0800 From: "wenyi,xie" To: , , , , , CC: , Subject: [PATCH EDK2 v2 1/1] MdeModulePkg/FileExplorerLib: remove redundant null pointer check Date: Thu, 26 Nov 2020 09:50:33 +0800 Message-ID: <1606355433-2419-2-git-send-email-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1606355433-2419-1-git-send-email-xiewenyi2@huawei.com> References: <1606355433-2419-1-git-send-email-xiewenyi2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.184.68.188] X-CFilter-Loop: Reflected Content-Type: text/plain 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 --- MdeModulePkg/Library/FileExplorerLib/FileExplorer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c b/MdeModulePkg/Library/FileExplorerLib/FileExplorer.c index 58e49102593c..13a214b06af9 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); -- 2.20.1.windows.1