netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] liquidio: style:  Identical condition and return expression  'retval', return value is always 0.
@ 2020-12-30  6:07 YANG LI
  2020-12-30  6:28 ` Joe Perches
  2021-01-05 23:58 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: YANG LI @ 2020-12-30  6:07 UTC (permalink / raw)
  To: davem; +Cc: kuba, dchickles, sburla, fmanlunas, netdev, linux-kernel, YANG LI

The warning was because of the following line in function
liquidio_set_fec():

retval = wait_for_sc_completion_timeout(oct, sc, 0);
    if (retval)
	return (-EIO);

If this statement is not true, retval must be 0 and not updated
later. So, It is better to return 0 directly.

Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
Reported-by: Abaci <abaci@linux.alibaba.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index 37d0641..6e2426f 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -1747,7 +1747,7 @@ int liquidio_set_fec(struct lio *lio, int on_off)
 			oct->props[lio->ifidx].fec ? "on" : "off");
 	}
 
-	return retval;
+	return 0;
 }
 
 int liquidio_get_fec(struct lio *lio)
-- 
1.8.3.1


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

* Re: [PATCH] liquidio: style:  Identical condition and return expression  'retval', return value is always 0.
  2020-12-30  6:07 [PATCH] liquidio: style: Identical condition and return expression 'retval', return value is always 0 YANG LI
@ 2020-12-30  6:28 ` Joe Perches
  2021-01-05 23:58 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2020-12-30  6:28 UTC (permalink / raw)
  To: YANG LI, davem; +Cc: kuba, dchickles, sburla, fmanlunas, netdev, linux-kernel

On Wed, 2020-12-30 at 14:07 +0800, YANG LI wrote:
> The warning was because of the following line in function
> liquidio_set_fec():
> 
> retval = wait_for_sc_completion_timeout(oct, sc, 0);
>     if (retval)
> 	return (-EIO);

I presume abaci is a robot

Perhaps also the robot could look for code immediately above this like:

		oct->props[lio->ifidx].fec = var;
		if (resp->fec_setting == SEAPI_CMD_FEC_SET_RS)
			oct->props[lio->ifidx].fec = 1;
		else
			oct->props[lio->ifidx].fec = 0;

where a location is immediately overwritten.

so the line
		oct->props[lio->ifidx].fec = var;
could be highlighted and perhaps removed
and also perhaps the second test and set block could be written

		oct->props[lio->ifidx].fec = resp->fec_setting == SEAPI_CMD_FEC_SET_RS;




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

* Re: [PATCH] liquidio: style: Identical condition and return expression 'retval', return value is always 0.
  2020-12-30  6:07 [PATCH] liquidio: style: Identical condition and return expression 'retval', return value is always 0 YANG LI
  2020-12-30  6:28 ` Joe Perches
@ 2021-01-05 23:58 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2021-01-05 23:58 UTC (permalink / raw)
  To: abaci-bugfix; +Cc: kuba, dchickles, sburla, fmanlunas, netdev, linux-kernel

From: YANG LI <abaci-bugfix@linux.alibaba.com>
Date: Wed, 30 Dec 2020 14:07:30 +0800

> The warning was because of the following line in function
> liquidio_set_fec():
> 
> retval = wait_for_sc_completion_timeout(oct, sc, 0);
>     if (retval)
> 	return (-EIO);
> 
> If this statement is not true, retval must be 0 and not updated
> later. So, It is better to return 0 directly.
> 
> Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
> Reported-by: Abaci <abaci@linux.alibaba.com>

Maybe you can remove the rest of the 'retval' usage in this function
and even the variable itself?

Thanks.

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

* [PATCH] liquidio: style:  Identical condition and return expression 'retval', return value is always 0.
@ 2020-12-30  6:10 YANG LI
  0 siblings, 0 replies; 4+ messages in thread
From: YANG LI @ 2020-12-30  6:10 UTC (permalink / raw)
  To: davem; +Cc: kuba, dchickles, sburla, fmanlunas, netdev, linux-kernel, YANG LI

The warning was because of the following line in function
liquidio_get_fec():

retval = wait_for_sc_completion_timeout(oct, sc, 0);
    if (retval)
	return retval;

If this statement is not true, retval must be 0 and not updated
later. So, It is better to return 0 directly.

Signed-off-by: YANG LI <abaci-bugfix@linux.alibaba.com>
Reported-by: Abaci <abaci@linux.alibaba.com>
---
 drivers/net/ethernet/cavium/liquidio/lio_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index 37d0641..cff18a0 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -1811,5 +1811,5 @@ int liquidio_get_fec(struct lio *lio)
 			oct->props[lio->ifidx].fec ? "on" : "off");
 	}
 
-	return retval;
+	return 0;
 }
-- 
1.8.3.1


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

end of thread, other threads:[~2021-01-05 23:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-30  6:07 [PATCH] liquidio: style: Identical condition and return expression 'retval', return value is always 0 YANG LI
2020-12-30  6:28 ` Joe Perches
2021-01-05 23:58 ` David Miller
2020-12-30  6:10 YANG LI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).