[dpdk-dev,2/4] net/bnx2x: remove unmeetable comparison

Message ID 152600348247.53624.13691884496521997911.stgit@localhost.localdomain (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK

Commit Message

Andy Green May 11, 2018, 1:51 a.m. UTC
  /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:
In function ‘elink_check_kr2_wa’:
/home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:12922:28:
error: bitwise comparison always evaluates to false
[-Werror=tautological-compare]
        ((next_page & 0xe0) == 0x2))));
---
 drivers/net/bnx2x/elink.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

De Lara Guarch, Pablo May 11, 2018, 4:32 p.m. UTC | #1
> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Andy Green

> Sent: Friday, May 11, 2018 2:51 AM

> To: dev@dpdk.org

> Subject: [dpdk-dev] [PATCH 2/4] net/bnx2x: remove unmeetable comparison

> 

> /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:

> In function ‘elink_check_kr2_wa’:

> /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:12922:28:

> error: bitwise comparison always evaluates to false [-Werror=tautological-

> compare]

>         ((next_page & 0xe0) == 0x2))));

> ---

>  drivers/net/bnx2x/elink.c |    4 +---

>  1 file changed, 1 insertion(+), 3 deletions(-)

> 

> diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c index

> 99684a5f9..2aef2b6da 100644

> --- a/drivers/net/bnx2x/elink.c

> +++ b/drivers/net/bnx2x/elink.c

> @@ -12919,9 +12919,7 @@ static void elink_check_kr2_wa(struct elink_params

> *params,

>  	 * but only KX is advertised, declare this link partner as non-KR2

>  	 * device.

>  	 */

> -	not_kr2_device = (((base_page & 0x8000) == 0) ||

> -			  (((base_page & 0x8000) &&

> -			    ((next_page & 0xe0) == 0x2))));

> +	not_kr2_device = !(base_page & 0x8000);

> 

>  	/* In case KR2 is already disabled, check if we need to re-enable it */

>  	if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {


Looks like a good fix, but I wonder what's the actual intention of that conditional.
CC'ing the maintainers and Stephen Hemminger (the author of this code) to figure it out.

Apart from that, missing signed-off-by, fixes line and Cc stable:

Fixes: b5bf7719221d ("bnx2x: driver support routines")
Cc: stable@dpdk.org
  
Stephen Hemminger May 11, 2018, 6:10 p.m. UTC | #2
On Fri, 11 May 2018 16:32:24 +0000
"De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com> wrote:

> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Andy Green
> > Sent: Friday, May 11, 2018 2:51 AM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH 2/4] net/bnx2x: remove unmeetable comparison
> > 
> > /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:
> > In function ‘elink_check_kr2_wa’:
> > /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:12922:28:
> > error: bitwise comparison always evaluates to false [-Werror=tautological-
> > compare]
> >         ((next_page & 0xe0) == 0x2))));
> > ---
> >  drivers/net/bnx2x/elink.c |    4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c index
> > 99684a5f9..2aef2b6da 100644
> > --- a/drivers/net/bnx2x/elink.c
> > +++ b/drivers/net/bnx2x/elink.c
> > @@ -12919,9 +12919,7 @@ static void elink_check_kr2_wa(struct elink_params
> > *params,
> >  	 * but only KX is advertised, declare this link partner as non-KR2
> >  	 * device.
> >  	 */
> > -	not_kr2_device = (((base_page & 0x8000) == 0) ||
> > -			  (((base_page & 0x8000) &&
> > -			    ((next_page & 0xe0) == 0x2))));
> > +	not_kr2_device = !(base_page & 0x8000);
> > 
> >  	/* In case KR2 is already disabled, check if we need to re-enable it */
> >  	if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {  
> 
> Looks like a good fix, but I wonder what's the actual intention of that conditional.
> CC'ing the maintainers and Stephen Hemminger (the author of this code) to figure it out.
> 
> Apart from that, missing signed-off-by, fixes line and Cc stable:
> 
> Fixes: b5bf7719221d ("bnx2x: driver support routines")
> Cc: stable@dpdk.org
> 

Actually, I didn't write this. It came from contractors.  Based of FreeBSD
driver so look there.
  
Andy Green May 12, 2018, 1:04 a.m. UTC | #3
On 05/12/2018 02:10 AM, Stephen Hemminger wrote:
> On Fri, 11 May 2018 16:32:24 +0000
> "De Lara Guarch, Pablo" <pablo.de.lara.guarch@intel.com> wrote:
> 
>>> -----Original Message-----
>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Andy Green
>>> Sent: Friday, May 11, 2018 2:51 AM
>>> To: dev@dpdk.org
>>> Subject: [dpdk-dev] [PATCH 2/4] net/bnx2x: remove unmeetable comparison
>>>
>>> /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:
>>> In function ‘elink_check_kr2_wa’:
>>> /home/agreen/projects/dpdk/drivers/net/bnx2x/elink.c:12922:28:
>>> error: bitwise comparison always evaluates to false [-Werror=tautological-
>>> compare]
>>>          ((next_page & 0xe0) == 0x2))));
>>> ---
>>>   drivers/net/bnx2x/elink.c |    4 +---
>>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c index
>>> 99684a5f9..2aef2b6da 100644
>>> --- a/drivers/net/bnx2x/elink.c
>>> +++ b/drivers/net/bnx2x/elink.c
>>> @@ -12919,9 +12919,7 @@ static void elink_check_kr2_wa(struct elink_params
>>> *params,
>>>   	 * but only KX is advertised, declare this link partner as non-KR2
>>>   	 * device.
>>>   	 */
>>> -	not_kr2_device = (((base_page & 0x8000) == 0) ||
>>> -			  (((base_page & 0x8000) &&
>>> -			    ((next_page & 0xe0) == 0x2))));
>>> +	not_kr2_device = !(base_page & 0x8000);
>>>
>>>   	/* In case KR2 is already disabled, check if we need to re-enable it */
>>>   	if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {
>>
>> Looks like a good fix, but I wonder what's the actual intention of that conditional.
>> CC'ing the maintainers and Stephen Hemminger (the author of this code) to figure it out.
>>
>> Apart from that, missing signed-off-by, fixes line and Cc stable:
>>
>> Fixes: b5bf7719221d ("bnx2x: driver support routines")
>> Cc: stable@dpdk.org
>>
> 
> Actually, I didn't write this. It came from contractors.  Based of FreeBSD
> driver so look there.

Googling around, the correct comparison is == 0x20, I updated the patch 
accordingly.

-Andy
  

Patch

diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c
index 99684a5f9..2aef2b6da 100644
--- a/drivers/net/bnx2x/elink.c
+++ b/drivers/net/bnx2x/elink.c
@@ -12919,9 +12919,7 @@  static void elink_check_kr2_wa(struct elink_params *params,
 	 * but only KX is advertised, declare this link partner as non-KR2
 	 * device.
 	 */
-	not_kr2_device = (((base_page & 0x8000) == 0) ||
-			  (((base_page & 0x8000) &&
-			    ((next_page & 0xe0) == 0x2))));
+	not_kr2_device = !(base_page & 0x8000);
 
 	/* In case KR2 is already disabled, check if we need to re-enable it */
 	if (!(vars->link_attr_sync & LINK_ATTR_SYNC_KR2_ENABLE)) {