From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E28C2211B81AD for ; Wed, 16 Jan 2019 17:01:13 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 17:01:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,488,1539673200"; d="scan'208";a="138930271" Received: from jiaxinwu-mobl.ccr.corp.intel.com ([10.239.193.52]) by fmsmga001.fm.intel.com with ESMTP; 16 Jan 2019 17:01:07 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Hao A , Wu Jiaxin Date: Thu, 17 Jan 2019 09:00:48 +0800 Message-Id: <20190117010048.19020-4-Jiaxin.wu@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 In-Reply-To: <20190117010048.19020-1-Jiaxin.wu@intel.com> References: <20190117010048.19020-1-Jiaxin.wu@intel.com> Subject: [PATCH v1 3/3] NetworkPkg/DnsDxe: Remove unnecessary NULL pointer check. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2019 01:01:14 -0000 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1469 Since the value of ItemCache4/ItemCache6 is retrieved from the list Entry, it can't be the NULL pointer, so just remove the unnecessary check. Cc: Ye Ting Cc: Fu Siyuan Cc: Wu Hao A Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Wu Jiaxin --- NetworkPkg/DnsDxe/DnsDriver.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/NetworkPkg/DnsDxe/DnsDriver.c b/NetworkPkg/DnsDxe/DnsDriver.c index b74f5ba18e..6a4214caea 100644 --- a/NetworkPkg/DnsDxe/DnsDriver.c +++ b/NetworkPkg/DnsDxe/DnsDriver.c @@ -1,9 +1,9 @@ /** @file The driver binding and service binding protocol for DnsDxe driver. -Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -374,40 +374,36 @@ DnsUnload ( gBS->CloseEvent (mDriverData->Timer); } while (!IsListEmpty (&mDriverData->Dns4CacheList)) { Entry = NetListRemoveHead (&mDriverData->Dns4CacheList); + ASSERT (Entry != NULL); ItemCache4 = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink); - if (ItemCache4->DnsCache.HostName != NULL) { - FreePool (ItemCache4->DnsCache.HostName); - } - if (ItemCache4->DnsCache.IpAddress != NULL) { - FreePool (ItemCache4->DnsCache.IpAddress); - } + FreePool (ItemCache4->DnsCache.HostName); + FreePool (ItemCache4->DnsCache.IpAddress); FreePool (ItemCache4); } while (!IsListEmpty (&mDriverData->Dns4ServerList)) { Entry = NetListRemoveHead (&mDriverData->Dns4ServerList); + ASSERT (Entry != NULL); ItemServerIp4 = NET_LIST_USER_STRUCT (Entry, DNS4_SERVER_IP, AllServerLink); FreePool (ItemServerIp4); } while (!IsListEmpty (&mDriverData->Dns6CacheList)) { Entry = NetListRemoveHead (&mDriverData->Dns6CacheList); + ASSERT (Entry != NULL); ItemCache6 = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink); - if (ItemCache6->DnsCache.HostName != NULL) { - FreePool (ItemCache6->DnsCache.HostName); - } - if (ItemCache6->DnsCache.IpAddress != NULL) { - FreePool (ItemCache6->DnsCache.IpAddress); - } + FreePool (ItemCache6->DnsCache.HostName); + FreePool (ItemCache6->DnsCache.IpAddress); FreePool (ItemCache6); } while (!IsListEmpty (&mDriverData->Dns6ServerList)) { Entry = NetListRemoveHead (&mDriverData->Dns6ServerList); + ASSERT (Entry != NULL); ItemServerIp6 = NET_LIST_USER_STRUCT (Entry, DNS6_SERVER_IP, AllServerLink); FreePool (ItemServerIp6); } FreePool (mDriverData); -- 2.17.1.windows.2