public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement
@ 2020-05-20  3:08 Zhang, Shenglei
  2020-05-20  9:03 ` Maciej Rabeda
  2020-05-20 11:41 ` [edk2-devel] " Philippe Mathieu-Daudé
  0 siblings, 2 replies; 5+ messages in thread
From: Zhang, Shenglei @ 2020-05-20  3:08 UTC (permalink / raw)
  To: devel; +Cc: Maciej Rabeda, Siyuan Fu, Jiaxin Wu

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>
---

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--;
       }
     }
-- 
2.18.0.windows.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement
       [not found] <16109DC42FE5E79D.3891@groups.io>
@ 2020-05-20  3:10 ` Zhang, Shenglei
  0 siblings, 0 replies; 5+ messages in thread
From: Zhang, Shenglei @ 2020-05-20  3:10 UTC (permalink / raw)
  To: devel@edk2.groups.io, Zhang, Shenglei, Gao, Liming
  Cc: Maciej Rabeda, Fu, Siyuan, Wu, Jiaxin

Hi,

For this patch, I'd like to catch this stable tag.

Thanks,
Shenglei

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Wednesday, May 20, 2020 11:09 AM
> To: devel@edk2.groups.io
> Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu, Siyuan
> <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>
> Subject: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order
> of conditions in IF statement
> 
> 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>
> ---
> 
> 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--;
>        }
>      }
> --
> 2.18.0.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement
  2020-05-20  3:08 [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement Zhang, Shenglei
@ 2020-05-20  9:03 ` Maciej Rabeda
  2020-05-20 11:41 ` [edk2-devel] " Philippe Mathieu-Daudé
  1 sibling, 0 replies; 5+ messages in thread
From: Maciej Rabeda @ 2020-05-20  9:03 UTC (permalink / raw)
  To: Shenglei Zhang, devel; +Cc: Siyuan Fu, Jiaxin Wu

Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>

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 <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>
> ---
>
> 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--;
>         }
>       }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement
  2020-05-20  3:08 [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement Zhang, Shenglei
  2020-05-20  9:03 ` Maciej Rabeda
@ 2020-05-20 11:41 ` Philippe Mathieu-Daudé
  2020-05-20 12:48   ` Maciej Rabeda
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-20 11:41 UTC (permalink / raw)
  To: devel, shenglei.zhang; +Cc: Maciej Rabeda, Siyuan Fu, Jiaxin Wu

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 <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>
> ---
> 
> 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 <philmd@redhat.com>

>           Index--;
>         }
>       }
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [edk2-devel] [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement
  2020-05-20 11:41 ` [edk2-devel] " Philippe Mathieu-Daudé
@ 2020-05-20 12:48   ` Maciej Rabeda
  0 siblings, 0 replies; 5+ messages in thread
From: Maciej Rabeda @ 2020-05-20 12:48 UTC (permalink / raw)
  To: devel, philmd, shenglei.zhang; +Cc: Siyuan Fu, Jiaxin Wu

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 <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>
>> ---
>>
>> 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 <philmd@redhat.com>
>
>>           Index--;
>>         }
>>       }
>>
>
>
> 
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-20 12:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-20  3:08 [PATCH v2] NetworkPkg/DxeNetLib: Change the order of conditions in IF statement Zhang, Shenglei
2020-05-20  9:03 ` Maciej Rabeda
2020-05-20 11:41 ` [edk2-devel] " Philippe Mathieu-Daudé
2020-05-20 12:48   ` Maciej Rabeda
     [not found] <16109DC42FE5E79D.3891@groups.io>
2020-05-20  3:10 ` Zhang, Shenglei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox