From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web12.4604.1606395461377921457 for ; Thu, 26 Nov 2020 04:57:41 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=e1LFFTeH; spf=pass (domain: redhat.com, ip: 216.205.24.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606395460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C6awmgFX3RRoJ/DpFCGsXaoY6B48fqQexwVesySPM9Q=; b=e1LFFTeHHLYkrxdelfy8uqHL6LFG91UhfpVqotvVSHKc0GSyABwI6YthGjjSyLCGJZRgKU cK++bgp2M6EpG+6bZn/0cuFMs9yUbcCiv386ogVNSM3+TlqDIy34e3JkhDziTLYXyMjKH4 GrOzVHhVVciA8/k9BotFUNLaedFDenY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-33-6hm9JD2pNHO6R-IxUk1seQ-1; Thu, 26 Nov 2020 07:57:38 -0500 X-MC-Unique: 6hm9JD2pNHO6R-IxUk1seQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 736251006CAB; Thu, 26 Nov 2020 12:57:17 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-34.ams2.redhat.com [10.36.113.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 88C685C1BD; Thu, 26 Nov 2020 12:57:15 +0000 (UTC) Subject: Re: [PATCH EDK2 v2 1/1] MdeModulePkg/FileExplorerLib: remove redundant null pointer check To: Wenyi Xie , devel@edk2.groups.io, jian.j.wang@intel.com, hao.a.wu@intel.com, dandan.bi@intel.com, eric.dong@intel.com Cc: songdongkuang@huawei.com References: <1606355433-2419-1-git-send-email-xiewenyi2@huawei.com> <1606355433-2419-2-git-send-email-xiewenyi2@huawei.com> From: "Laszlo Ersek" Message-ID: <71c96a71-3d97-8b31-15cf-27079fa7427c@redhat.com> Date: Thu, 26 Nov 2020 13:57:14 +0100 MIME-Version: 1.0 In-Reply-To: <1606355433-2419-2-git-send-email-xiewenyi2@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 11/26/20 02:50, Wenyi Xie wrote: > 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); > Reviewed-by: Laszlo Ersek