public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Jiaxin Wu <Jiaxin.wu@intel.com>
To: edk2-devel@lists.01.org
Cc: Ye Ting <ting.ye@intel.com>, Fu Siyuan <siyuan.fu@intel.com>,
	Wu Hao A <hao.a.wu@intel.com>, Wu Jiaxin <jiaxin.wu@intel.com>
Subject: [PATCH v1 3/3] NetworkPkg/DnsDxe: Remove unnecessary NULL pointer check.
Date: Thu, 17 Jan 2019 09:00:48 +0800	[thread overview]
Message-ID: <20190117010048.19020-4-Jiaxin.wu@intel.com> (raw)
In-Reply-To: <20190117010048.19020-1-Jiaxin.wu@intel.com>

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>
---
 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.<BR>
+Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
 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



      parent reply	other threads:[~2019-01-17  1:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17  1:00 [PATCH v1 0/3] Remove unnecessary NULL pointer check Jiaxin Wu
2019-01-17  1:00 ` [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: " Jiaxin Wu
2019-01-18  1:59   ` Fu, Siyuan
2019-01-18  2:17     ` Wu, Jiaxin
2019-01-17  1:00 ` [PATCH v1 2/3] NetworkPkg/IScsiDxe: " Jiaxin Wu
2019-01-17  1:00 ` Jiaxin Wu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190117010048.19020-4-Jiaxin.wu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox