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@linux.intel.com>
Cc: Siyuan Fu <siyuan.fu@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
This commit is contained in:
Zhang, Shenglei 2020-05-20 11:08:47 +08:00 committed by mergify[bot]
parent 7b6327ff03
commit d3733188a2
1 changed files with 1 additions and 1 deletions

View File

@ -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--;
}
}