From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com []) by mx.groups.io with SMTP id smtpd.web12.2688.1570866187085018288 for ; Sat, 12 Oct 2019 00:43:08 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=fail (domain: intel.com, ip: , mailfrom: shenglei.zhang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2019 00:43:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,286,1566889200"; d="scan'208";a="198925960" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 12 Oct 2019 00:43:07 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Siyuan Fu , Jiaxin Wu Subject: [PATCH] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement Date: Sat, 12 Oct 2019 15:43:02 +0800 Message-Id: <20191012074302.11928-2-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 In-Reply-To: <20191012074302.11928-1-shenglei.zhang@intel.com> References: <20191012074302.11928-1-shenglei.zhang@intel.com> 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 Cc: Jiaxin Wu Signed-off-by: Shenglei Zhang --- 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