From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web11.5502.1589942041939947719 for ; Tue, 19 May 2020 19:34:02 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.88, mailfrom: shenglei.zhang@intel.com) IronPort-SDR: L7DN/84tiEY09WPPx85c1jB6VbwDztvDivMRUOOEQUCOxpVMMh+tWMLNWJubDSIWENOjUPffgo 9BYoAQE8flvQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 19:34:01 -0700 IronPort-SDR: Jp5E7962/QrJLqrLJokcMZ6Td9xqS26sllrwzGTBS1u8gVzl4C6Sf6tYgBMTdwV8Vru32Zg7zd ExIvyTxRpl2w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,412,1583222400"; d="scan'208";a="253541168" Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by fmsmga007.fm.intel.com with ESMTP; 19 May 2020 19:34:00 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Maciej Rabeda , Siyuan Fu , Jiaxin Wu Subject: [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement Date: Wed, 20 May 2020 10:33:56 +0800 Message-Id: <20200520023356.13996-1-shenglei.zhang@intel.com> X-Mailer: git-send-email 2.18.0.windows.1 MIME-Version: 1.0 Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit 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 --- 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 a232802c9a21..77634dabf912 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