* [PATCH v1 0/3] Remove unnecessary NULL pointer check.
@ 2019-01-17 1:00 Jiaxin Wu
2019-01-17 1:00 ` [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: " Jiaxin Wu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jiaxin Wu @ 2019-01-17 1:00 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Hao A, Gao Liming, Wu
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1469
Since the value retrieved from the list Entry can't be the NULL
pointer, the unnecessary check can be removed.
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Hao A <hao.a.wu@intel.com>
Cc: Gao Liming <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com
Jiaxin Wu (3):
MdeModulePkg/Dhcp4Dxe: Remove unnecessary NULL pointer check.
NetworkPkg/IScsiDxe: Remove unnecessary NULL pointer check.
NetworkPkg/DnsDxe: Remove unnecessary NULL pointer check.
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 15 +++++--------
NetworkPkg/DnsDxe/DnsDriver.c | 22 ++++++++-----------
NetworkPkg/IScsiDxe/IScsiConfig.c | 6 +----
3 files changed, 16 insertions(+), 27 deletions(-)
--
2.17.1.windows.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: Remove unnecessary NULL pointer check.
2019-01-17 1:00 [PATCH v1 0/3] Remove unnecessary NULL pointer check Jiaxin Wu
@ 2019-01-17 1:00 ` Jiaxin Wu
2019-01-18 1:59 ` Fu, Siyuan
2019-01-17 1:00 ` [PATCH v1 2/3] NetworkPkg/IScsiDxe: " Jiaxin Wu
2019-01-17 1:00 ` [PATCH v1 3/3] NetworkPkg/DnsDxe: " Jiaxin Wu
2 siblings, 1 reply; 6+ messages in thread
From: Jiaxin Wu @ 2019-01-17 1:00 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Hao A, Gao Liming, Wu Jiaxin
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1469
Since the value of Instance 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>
Cc: Gao Liming <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
---
MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
index 98a22a77b4..04d47e0759 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
@@ -1,9 +1,9 @@
/** @file
EFI DHCP protocol implementation.
-Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -1493,15 +1493,15 @@ DhcpOnTimerTick (
IN EFI_EVENT Event,
IN VOID *Context
)
{
LIST_ENTRY *Entry;
- LIST_ENTRY *Next;
DHCP_SERVICE *DhcpSb;
DHCP_PROTOCOL *Instance;
EFI_STATUS Status;
+ Entry = NULL;
DhcpSb = (DHCP_SERVICE *) Context;
Instance = DhcpSb->ActiveChild;
//
// 0xffff is the maximum supported value for elapsed time according to RFC.
@@ -1644,18 +1644,15 @@ DhcpOnTimerTick (
ON_EXIT:
//
// Iterate through all the DhcpSb Children.
//
- NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) {
+ NET_LIST_FOR_EACH (Entry, &DhcpSb->Children) {
Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
-
- if ((Instance != NULL) && (Instance->Token != NULL)) {
- Instance->Timeout--;
- if (Instance->Timeout == 0) {
- PxeDhcpDone (Instance);
- }
+ Instance->Timeout--;
+ if (Instance->Timeout == 0) {
+ PxeDhcpDone (Instance);
}
}
return ;
--
2.17.1.windows.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 2/3] NetworkPkg/IScsiDxe: Remove unnecessary NULL pointer check.
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-17 1:00 ` Jiaxin Wu
2019-01-17 1:00 ` [PATCH v1 3/3] NetworkPkg/DnsDxe: " Jiaxin Wu
2 siblings, 0 replies; 6+ messages in thread
From: Jiaxin Wu @ 2019-01-17 1:00 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Hao A, Wu Jiaxin
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1469
Since the value of AttemptConfigData 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/IScsiDxe/IScsiConfig.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/NetworkPkg/IScsiDxe/IScsiConfig.c b/NetworkPkg/IScsiDxe/IScsiConfig.c
index 83644f51d8..78135b411c 100644
--- a/NetworkPkg/IScsiDxe/IScsiConfig.c
+++ b/NetworkPkg/IScsiDxe/IScsiConfig.c
@@ -1,9 +1,9 @@
/** @file
Helper functions for configuring or getting the parameters relating to iSCSI.
-Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 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
@@ -2290,14 +2290,10 @@ IScsiConfigDeleteAttempts (
//
// Delete the attempt.
//
AttemptConfigData = NET_LIST_USER_STRUCT (Entry, ISCSI_ATTEMPT_CONFIG_NVDATA, Link);
- if (AttemptConfigData == NULL) {
- Status = EFI_NOT_FOUND;
- goto Error;
- }
//
// Remove this attempt from UI configured attempt list.
//
RemoveEntryList (&AttemptConfigData->Link);
--
2.17.1.windows.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v1 3/3] NetworkPkg/DnsDxe: Remove unnecessary NULL pointer check.
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-17 1:00 ` [PATCH v1 2/3] NetworkPkg/IScsiDxe: " Jiaxin Wu
@ 2019-01-17 1:00 ` Jiaxin Wu
2 siblings, 0 replies; 6+ messages in thread
From: Jiaxin Wu @ 2019-01-17 1:00 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Fu Siyuan, Wu Hao A, Wu Jiaxin
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: Remove unnecessary NULL pointer check.
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
0 siblings, 1 reply; 6+ messages in thread
From: Fu, Siyuan @ 2019-01-18 1:59 UTC (permalink / raw)
To: Wu, Jiaxin, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wu, Hao A, Gao, Liming
Hi, Jiaxin
> -----Original Message-----
> From: Wu, Jiaxin
> Sent: Thursday, January 17, 2019 9:01 AM
> 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>; Gao, Liming <liming.gao@intel.com>; Wu, Jiaxin
> <jiaxin.wu@intel.com>
> Subject: [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: Remove unnecessary NULL pointer
> check.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1469
>
> Since the value of Instance 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>
> Cc: Gao Liming <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> ---
> MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> index 98a22a77b4..04d47e0759 100644
> --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> @@ -1,9 +1,9 @@
> /** @file
> EFI DHCP protocol implementation.
>
> -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2006 - 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
>
> @@ -1493,15 +1493,15 @@ DhcpOnTimerTick (
> IN EFI_EVENT Event,
> IN VOID *Context
> )
> {
> LIST_ENTRY *Entry;
> - LIST_ENTRY *Next;
> DHCP_SERVICE *DhcpSb;
> DHCP_PROTOCOL *Instance;
> EFI_STATUS Status;
>
> + Entry = NULL;
> DhcpSb = (DHCP_SERVICE *) Context;
> Instance = DhcpSb->ActiveChild;
>
> //
> // 0xffff is the maximum supported value for elapsed time according to RFC.
> @@ -1644,18 +1644,15 @@ DhcpOnTimerTick (
>
> ON_EXIT:
> //
> // Iterate through all the DhcpSb Children.
> //
> - NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) {
> + NET_LIST_FOR_EACH (Entry, &DhcpSb->Children) {
The DHCP Instance might be destroyed in PxeDhcpDone (it singals upper layer that the DHCP is completed), and the NET_LIST_FOR_EACH is not delete-safe, you should not replace it with NET_LIST_FOR_EACH.
> Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
> -
> - if ((Instance != NULL) && (Instance->Token != NULL)) {
> - Instance->Timeout--;
> - if (Instance->Timeout == 0) {
> - PxeDhcpDone (Instance);
> - }
> + Instance->Timeout--;
> + if (Instance->Timeout == 0) {
> + PxeDhcpDone (Instance);
> }
> }
>
> return ;
>
> --
> 2.17.1.windows.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: Remove unnecessary NULL pointer check.
2019-01-18 1:59 ` Fu, Siyuan
@ 2019-01-18 2:17 ` Wu, Jiaxin
0 siblings, 0 replies; 6+ messages in thread
From: Wu, Jiaxin @ 2019-01-18 2:17 UTC (permalink / raw)
To: Fu, Siyuan, edk2-devel@lists.01.org; +Cc: Ye, Ting, Wu, Hao A, Gao, Liming
Thanks Siyuan, I will double check that.
> -----Original Message-----
> From: Fu, Siyuan
> Sent: Friday, January 18, 2019 10:00 AM
> To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org
> Cc: Ye, Ting <ting.ye@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Gao,
> Liming <liming.gao@intel.com>
> Subject: RE: [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: Remove
> unnecessary NULL pointer check.
>
> Hi, Jiaxin
>
> > -----Original Message-----
> > From: Wu, Jiaxin
> > Sent: Thursday, January 17, 2019 9:01 AM
> > 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>; Gao, Liming <liming.gao@intel.com>; Wu, Jiaxin
> > <jiaxin.wu@intel.com>
> > Subject: [PATCH v1 1/3] MdeModulePkg/Dhcp4Dxe: Remove unnecessary
> NULL pointer
> > check.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1469
> >
> > Since the value of Instance 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>
> > Cc: Gao Liming <liming.gao@intel.com>
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
> > ---
> > MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c | 15 ++++++----
> -----
> > 1 file changed, 6 insertions(+), 9 deletions(-)
> >
> > diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> > b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> > index 98a22a77b4..04d47e0759 100644
> > --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> > +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
> > @@ -1,9 +1,9 @@
> > /** @file
> > EFI DHCP protocol implementation.
> >
> > -Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> > +Copyright (c) 2006 - 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
> >
> > @@ -1493,15 +1493,15 @@ DhcpOnTimerTick (
> > IN EFI_EVENT Event,
> > IN VOID *Context
> > )
> > {
> > LIST_ENTRY *Entry;
> > - LIST_ENTRY *Next;
> > DHCP_SERVICE *DhcpSb;
> > DHCP_PROTOCOL *Instance;
> > EFI_STATUS Status;
> >
> > + Entry = NULL;
> > DhcpSb = (DHCP_SERVICE *) Context;
> > Instance = DhcpSb->ActiveChild;
> >
> > //
> > // 0xffff is the maximum supported value for elapsed time according to
> RFC.
> > @@ -1644,18 +1644,15 @@ DhcpOnTimerTick (
> >
> > ON_EXIT:
> > //
> > // Iterate through all the DhcpSb Children.
> > //
> > - NET_LIST_FOR_EACH_SAFE (Entry, Next, &DhcpSb->Children) {
> > + NET_LIST_FOR_EACH (Entry, &DhcpSb->Children) {
>
> The DHCP Instance might be destroyed in PxeDhcpDone (it singals upper
> layer that the DHCP is completed), and the NET_LIST_FOR_EACH is not
> delete-safe, you should not replace it with NET_LIST_FOR_EACH.
>
> > Instance = NET_LIST_USER_STRUCT (Entry, DHCP_PROTOCOL, Link);
> > -
> > - if ((Instance != NULL) && (Instance->Token != NULL)) {
> > - Instance->Timeout--;
> > - if (Instance->Timeout == 0) {
> > - PxeDhcpDone (Instance);
> > - }
> > + Instance->Timeout--;
> > + if (Instance->Timeout == 0) {
> > + PxeDhcpDone (Instance);
> > }
> > }
> >
> > return ;
> >
> > --
> > 2.17.1.windows.2
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-18 2:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH v1 3/3] NetworkPkg/DnsDxe: " Jiaxin Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox