]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg/DnsDxe: Remove unnecessary NULL pointer check.
authorJiaxin Wu <Jiaxin.wu@intel.com>
Wed, 16 Jan 2019 02:56:19 +0000 (10:56 +0800)
committerJiaxin Wu <Jiaxin.wu@intel.com>
Wed, 23 Jan 2019 00:46:50 +0000 (08:46 +0800)
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 <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Hao A <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Wu Hao A <hao.a.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
NetworkPkg/DnsDxe/DnsDriver.c

index b74f5ba18e8235f151f720fa9fb2e51819094600..6a4214caea1f8efb68f9cfc6e7016b108f562da7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 The driver binding and service binding protocol for DnsDxe driver.\r
 \r
-Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -376,36 +376,32 @@ DnsUnload (
 \r
     while (!IsListEmpty (&mDriverData->Dns4CacheList)) {\r
       Entry = NetListRemoveHead (&mDriverData->Dns4CacheList);\r
+      ASSERT (Entry != NULL);\r
       ItemCache4 = NET_LIST_USER_STRUCT (Entry, DNS4_CACHE, AllCacheLink);\r
-      if (ItemCache4->DnsCache.HostName != NULL) {\r
-        FreePool (ItemCache4->DnsCache.HostName);\r
-      }\r
-      if (ItemCache4->DnsCache.IpAddress != NULL) {\r
-        FreePool (ItemCache4->DnsCache.IpAddress);\r
-      }\r
+      FreePool (ItemCache4->DnsCache.HostName);\r
+      FreePool (ItemCache4->DnsCache.IpAddress);\r
       FreePool (ItemCache4);\r
     }\r
 \r
     while (!IsListEmpty (&mDriverData->Dns4ServerList)) {\r
       Entry = NetListRemoveHead (&mDriverData->Dns4ServerList);\r
+      ASSERT (Entry != NULL);\r
       ItemServerIp4 = NET_LIST_USER_STRUCT (Entry, DNS4_SERVER_IP, AllServerLink);\r
       FreePool (ItemServerIp4);\r
     }\r
 \r
     while (!IsListEmpty (&mDriverData->Dns6CacheList)) {\r
       Entry = NetListRemoveHead (&mDriverData->Dns6CacheList);\r
+      ASSERT (Entry != NULL);\r
       ItemCache6 = NET_LIST_USER_STRUCT (Entry, DNS6_CACHE, AllCacheLink);\r
-      if (ItemCache6->DnsCache.HostName != NULL) {\r
-        FreePool (ItemCache6->DnsCache.HostName);\r
-      }\r
-      if (ItemCache6->DnsCache.IpAddress != NULL) {\r
-        FreePool (ItemCache6->DnsCache.IpAddress);\r
-      }\r
+      FreePool (ItemCache6->DnsCache.HostName);\r
+      FreePool (ItemCache6->DnsCache.IpAddress);\r
       FreePool (ItemCache6);\r
     }\r
 \r
     while (!IsListEmpty (&mDriverData->Dns6ServerList)) {\r
       Entry = NetListRemoveHead (&mDriverData->Dns6ServerList);\r
+      ASSERT (Entry != NULL);\r
       ItemServerIp6 = NET_LIST_USER_STRUCT (Entry, DNS6_SERVER_IP, AllServerLink);\r
       FreePool (ItemServerIp6);\r
     }\r