Skip to contentSkip to conversation

staging: comedi: ni_660x: fix missing break in switch statement

PATCH In review Gustavo A. R. Silva 2 participants 3 messages Feb 12, 2019 – Feb 13, 2019 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: comedi: ni_660x: fix missing break in switch statement

Add missing break statement in order to prevent the code from falling through to the default case and return -EINVAL every time.

This bug was found thanks to the ongoing efforts to enable -Wimplicit-fallthrough.

Fixes aa94f2888825 ("staging: comedi: ni_660x: tidy up ni_660x_set_pfi_routing()")

---
Changes in v2:
- Fix Fixes tag.

 drivers/staging/comedi/drivers/ni_660x.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/comedi/drivers/ni_660x.c +1 -0
index e70a461e723f..405573e927cf 100644
@@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device *dev,
 	case NI_660X_PFI_OUTPUT_DIO:
 		if (chan > 31)
 			return -EINVAL;
+		break;
 	default:
 		return -EINVAL;
 	}
Signature · 1 line
2.20.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 22 lines · Gustavo A. R. Silva

Add missing break statement in order to prevent the code from falling through to the default case and return -EINVAL every time.

This bug was found thanks to the ongoing efforts to enable -Wimplicit-fallthrough.

Fixes aa94f2888825 ("staging: comedi: ni_660x: tidy up ni_660x_set_pfi_routing()")

---
Changes in v2:
- Fix Fixes tag.

  drivers/staging/comedi/drivers/ni_660x.c | 1 +
  1 file changed, 1 insertion(+)
drivers/staging/comedi/drivers/ni_660x.c +0 -0
index e70a461e723f..405573e927cf 100644

drivers/staging/comedi/drivers/ni_660x.c static int ni_660x_set_pfi_routing(struct comedi_device *dev, · line 662

Quoted 7 lines
drivers/staging/comedi/drivers/ni_660x.c +1 -0
@@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device *dev,
  	case NI_660X_PFI_OUTPUT_DIO:
  		if (chan > 31)
  			return -EINVAL;
+		break;
  	default:
  		return -EINVAL;
  	}

Thanks for the bug fix!

Signature · 4 lines
-=( Ian Abbott <[email protected]> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268.  Registered address:    )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-
#2 lore raw
Quoted 17 lines · Ian Abbott
Quoted 16 lines · Gustavo A. R. Silva

Add missing break statement in order to prevent the code from falling through to the default case and return -EINVAL every time.

This bug was found thanks to the ongoing efforts to enable -Wimplicit-fallthrough.

Fixes aa94f2888825 ("staging: comedi: ni_660x: tidy up ni_660x_set_pfi_routing()")

---
Changes in v2:
  - Fix Fixes tag.

  drivers/staging/comedi/drivers/ni_660x.c | 1 +

  1 file changed, 1 insertion(+)
Quoted 16 lines
Quoted 5 lines
drivers/staging/comedi/drivers/ni_660x.c +0 -0
index e70a461e723f..405573e927cf 100644
@@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device *dev,
Quoted 8 lines

      case NI_660X_PFI_OUTPUT_DIO:
          if (chan > 31)
              return -EINVAL;
+        break;
      default:
          return -EINVAL;
      }

Thanks for the bug fix!

Glad to help. :)

Quoted 2 lines

Thanks, Ian.

--
Gustavo