From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.9109.1589965446541889645 for ; Wed, 20 May 2020 02:04:06 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: linux.intel.com, ip: 192.55.52.115, mailfrom: maciej.rabeda@linux.intel.com) IronPort-SDR: u8/3brJQvjqy5VYYmb/LwnkNfg0jVLQ90kuCy4rUm2bTzlDas/v9J8hmgJrEiD5YseqkzlDf5j LEL/dzjj4jgg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2020 02:04:06 -0700 IronPort-SDR: 1MWL2d06aCRXZSuwbvnj9NT1UpsjhqC4k5haIxGZcRRMxSbW2vK4ZHfW8kRJqlwZt7sb5n8TLt M8F+ipZhyrzg== X-IronPort-AV: E=Sophos;i="5.73,413,1583222400"; d="scan'208";a="411949823" 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 02:04:04 -0700 Subject: Re: [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement To: Shenglei Zhang , devel@edk2.groups.io Cc: Siyuan Fu , Jiaxin Wu References: <20200520030847.11416-1-shenglei.zhang@intel.com> From: "Maciej Rabeda" Message-ID: Date: Wed, 20 May 2020 11:03:56 +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: <20200520030847.11416-1-shenglei.zhang@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: pl Reviewed-by: Maciej Rabeda On 20-May-20 05:08, Shenglei Zhang 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)) { > Index--; > } > }