From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mx.groups.io with SMTP id smtpd.web12.1110.1606269273197359947 for ; Tue, 24 Nov 2020 17:54:33 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: huawei.com, ip: 45.249.212.190, mailfrom: xiewenyi2@huawei.com) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CgkTG1cyTz15RlS for ; Wed, 25 Nov 2020 09:54:10 +0800 (CST) Received: from HGH1000039998.huawei.com (10.184.68.188) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Wed, 25 Nov 2020 09:54:22 +0800 From: "wenyi,xie" To: , , , , CC: , Subject: [PATCH EDK2 v1 1/1] MdeModulePkg/FileExplorerLib: remove redundant null pointer check Date: Wed, 25 Nov 2020 09:52:51 +0800 Message-ID: <1606269171-21979-2-git-send-email-xiewenyi2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1606269171-21979-1-git-send-email-xiewenyi2@huawei.com> References: <1606269171-21979-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 Since Info is a pointer of struct EFI_FILE_SYSTEM_VOLUME_LABEL, and this struct has only one member VolumeLabel which is char array. So Info and Info->VolumeLabel are point to the same address, and if Info != NULL, Info->VolumeLabel == NULL is always false, it's no necessary to do null pointer check again. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Eric Dong Signed-off-by: Wenyi Xie --- 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