NetworkPkg/DxeNetLib: Change the order of conditions in IF statement
authorZhang, Shenglei <shenglei.zhang@intel.com>
Wed, 20 May 2020 03:08:47 +0000 (11:08 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 20 May 2020 12:44:43 +0000 (12:44 +0000)
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>
NetworkPkg/Library/DxeNetLib/NetBuffer.c

index a232802..329a176 100644 (file)
@@ -1063,7 +1063,7 @@ NetbufAllocSpace (
     } else {\r
       NetbufGetByte (Nbuf, 0, &Index);\r
 \r
-      if ((NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len) && (Index > 0)) {\r
+      if ((Index != 0) && (NET_HEADSPACE(&(Nbuf->BlockOp[Index])) < Len)) {\r
         Index--;\r
       }\r
     }\r