From: Zhang, Shenglei Date: Wed, 20 May 2020 03:08:47 +0000 (+0800) Subject: NetworkPkg/DxeNetLib: Change the order of conditions in IF statement X-Git-Tag: edk2-stable202005~18 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=d3733188a2162abf72dd08c0cedd1119b5cfe6c4 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 Cc: Siyuan Fu Cc: Jiaxin Wu Signed-off-by: Shenglei Zhang Reviewed-by: Maciej Rabeda Reviewed-by: Philippe Mathieu-Daude --- diff --git a/NetworkPkg/Library/DxeNetLib/NetBuffer.c b/NetworkPkg/Library/DxeNetLib/NetBuffer.c index a232802c9a..329a17623d 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--; } }