From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web11.11790.1589978901703748289 for ; Wed, 20 May 2020 05:48:21 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: linux.intel.com, ip: 134.134.136.126, mailfrom: maciej.rabeda@linux.intel.com) IronPort-SDR: zZd1HYP0UHfNuh8WTyGAhtXIQy8dnNnW97G7diPqEURSfZQPAjhWkMKfzL737S0qxMsJcDm8OU zPREN8zWAzKw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 05:48:20 -0700 IronPort-SDR: f+0dDIkj2U5UeoB6zSXYHCgcw2Y0BLqTmiPTGT0siyzwb4mA0I6gpXNqoUTbfS61Pb029bGA2G IN4m/tNtEn5g== X-IronPort-AV: E=Sophos;i="5.73,414,1583222400"; d="scan'208";a="412006998" Received: from mrabeda-mobl.ger.corp.intel.com (HELO [10.213.22.193]) ([10.213.22.193]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 05:48:19 -0700 Subject: Re: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement To: devel@edk2.groups.io, philmd@redhat.com, shenglei.zhang@intel.com Cc: Siyuan Fu , Jiaxin Wu References: <20200520030847.11416-1-shenglei.zhang@intel.com> From: "Maciej Rabeda" Message-ID: <55233fdb-6fc8-b03a-1448-234f2bdd2798@linux.intel.com> Date: Wed, 20 May 2020 14:48:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: pl Merged: https://github.com/tianocore/edk2/pull/634 https://github.com/tianocore/edk2/commit/d3733188a2162abf72dd08c0cedd1119b5cfe6c4 Thanks, Maciej On 20-May-20 13:41, Philippe Mathieu-Daudé wrote: > On 5/20/20 5:08 AM, Zhang, Shenglei wrote: >> 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 >> --- >> >> v2: Update 'Index > 0' to 'Index != 0' >> >>   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..329a17623d94 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)) { > > Reviewed-by: Philippe Mathieu-Daude > >>           Index--; >>         } >>       } >> > > > >