diff mbox series

net: ethernet/nvidia: fix possible condition with no effect

Message ID 20220626103539.80283-1-praghadeeshthevendria@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet/nvidia: fix possible condition with no effect | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Praghadeesh T K S June 26, 2022, 10:35 a.m. UTC
Fix Coccinelle bug, removed condition with no effect.

Signed-off-by: Praghadeesh T K S <praghadeeshthevendria@gmail.com>
---
 drivers/net/ethernet/nvidia/forcedeth.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

Andrew Lunn June 26, 2022, 11:08 a.m. UTC | #1
On Sun, Jun 26, 2022 at 10:35:39AM +0000, Praghadeesh T K S wrote:
> Fix Coccinelle bug, removed condition with no effect.

This is not a coccinelle bug. If it was, you would be patching
coccinelle, not the kernel.

> Signed-off-by: Praghadeesh T K S <praghadeeshthevendria@gmail.com>
> ---
>  drivers/net/ethernet/nvidia/forcedeth.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
> index 5116bad..8e49cfa 100644
> --- a/drivers/net/ethernet/nvidia/forcedeth.c
> +++ b/drivers/net/ethernet/nvidia/forcedeth.c
> @@ -3471,9 +3471,6 @@ static int nv_update_linkspeed(struct net_device *dev)
>  	} else if (adv_lpa & LPA_10FULL) {
>  		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
>  		newdup = 1;
> -	} else if (adv_lpa & LPA_10HALF) {
> -		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
> -		newdup = 0;
>  	} else {
>  		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
>  		newdup = 0;

Please google this, see the past discussion about why this code is
there.

	Andrew
Jakub Kicinski June 27, 2022, 6:38 p.m. UTC | #2
On Sun, 26 Jun 2022 13:08:37 +0200 Andrew Lunn wrote:
> On Sun, Jun 26, 2022 at 10:35:39AM +0000, Praghadeesh T K S wrote:
> > Fix Coccinelle bug, removed condition with no effect.  
> 
> This is not a coccinelle bug. If it was, you would be patching
> coccinelle, not the kernel.

I'd say the commit message is better than the commit ;)
Praghadeesh, could you fix Coccinelle to avoid matching:

	if (/* case 1 */) {
		/* BLOCK 1*/
	} else (/* case 2 */ {
		/* BLOCK 2 */
	} else {
		/* default == BLOCK 2 */
	}

Because 99% of the time that construct is intentional.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 5116bad..8e49cfa 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -3471,9 +3471,6 @@  static int nv_update_linkspeed(struct net_device *dev)
 	} else if (adv_lpa & LPA_10FULL) {
 		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
 		newdup = 1;
-	} else if (adv_lpa & LPA_10HALF) {
-		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
-		newdup = 0;
 	} else {
 		newls = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
 		newdup = 0;