NetworkPkg/Library/DxeNetLib/NetBuffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is meaningless
if Index < 0. So 'Index < 0' should be performed first in the if statement.
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
---
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 2408e9a10456..a35e67aa1f6c 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
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#48863): https://edk2.groups.io/g/devel/message/48863
Mute This Topic: https://groups.io/mt/34508855/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: Siyuan Fu <siyuan.fu@intel.com> > -----Original Message----- > From: Zhang, Shenglei <shenglei.zhang@intel.com> > Sent: 2019年10月12日 15:43 > To: devel@edk2.groups.io > Cc: Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com> > Subject: [PATCH] NetworkPkg/DxeNetLib: Change the order of conditions in > IF statement > > The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is > meaningless > if Index < 0. So 'Index < 0' should be performed first in the if statement. > > Cc: Siyuan Fu <siyuan.fu@intel.com> > Cc: Jiaxin Wu <jiaxin.wu@intel.com> > Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> > --- > 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 2408e9a10456..a35e67aa1f6c 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 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48877): https://edk2.groups.io/g/devel/message/48877 Mute This Topic: https://groups.io/mt/34508855/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Hi Zhang, On 10/12/19 9:43 AM, Zhang, Shenglei wrote: > The condition, NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len, is meaningless > if Index < 0. So 'Index < 0' should be performed first in the if statement. > > Cc: Siyuan Fu <siyuan.fu@intel.com> > Cc: Jiaxin Wu <jiaxin.wu@intel.com> > Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> > --- > 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 2408e9a10456..a35e67aa1f6c 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)) { I'm not sure this is correct. Index is unsigned, so it won't be negative. NetbufGetByte() can set Index=0. With your change this case is not covered anymore. Maybe your tool is unhappy because the return value of NetbufGetByte() isn't checked? > Index--; > } > } > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#48886): https://edk2.groups.io/g/devel/message/48886 Mute This Topic: https://groups.io/mt/34508855/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.