Re: [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement


Zhang, Shenglei
 

Hi,

For this patch, I'd like to catch this stable tag.

Thanks,
Shenglei

-----Original Message-----
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Zhang, Shenglei
Sent: Wednesday, May 20, 2020 11:09 AM
To: devel@edk2.groups.io
Cc: Maciej Rabeda <maciej.rabeda@...>; Fu, Siyuan
<siyuan.fu@...>; Wu, Jiaxin <jiaxin.wu@...>
Subject: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order
of conditions in IF statement

The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is
meaningless if Index = 0. So checking 'Index != 0' should be
performed first in the if statement.

Cc: Maciej Rabeda <maciej.rabeda@...>
Cc: Siyuan Fu <siyuan.fu@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
Signed-off-by: Shenglei Zhang <shenglei.zhang@...>
---

v2: Update 'Index > 0' to 'Index != 0'

NetworkPkg/Library/DxeNetLib/NetBuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/Library/DxeNetLib/NetBuffer.c
b/NetworkPkg/Library/DxeNetLib/NetBuffer.c
index a232802c9a21..329a17623d94 100644
--- a/NetworkPkg/Library/DxeNetLib/NetBuffer.c
+++ b/NetworkPkg/Library/DxeNetLib/NetBuffer.c
@@ -1063,7 +1063,7 @@ NetbufAllocSpace (
} else {
NetbufGetByte (Nbuf, 0, &Index);

- if ((NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len) && (Index > 0)) {
+ if ((Index != 0) && (NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len))
{
Index--;
}
}
--
2.18.0.windows.1


Join devel@edk2.groups.io to automatically receive all group messages.