Skip to contentSkip to conversation

iio: imu: inv_mpu6050: fix missing break in switch

PATCH In review Gustavo A. R. Silva 3 participants 3 messages Aug 22, 2017 – Sep 3, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: imu: inv_mpu6050: fix missing break in switch

Add missing break statement to prevent the code for case IIO_CHAN_INFO_CALIBBIAS falling through to the default case.

Also, add a break to the default case for the switch within case IIO_CHAN_INFO_CALIBBIAS.

Addresses-Coverity-ID: 1357377

---
This issue was reported by Coverity and it was tested by compilation only. Please, verify if this is an actual bug.

 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -0
index 44830bc..6d2268a 100644
@@ -542,7 +542,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
 			break;
 		default:
 			result = -EINVAL;
+			break;
 		}
+		break;
 	default:
 		result = -EINVAL;
 		break;
Signature · 1 line
2.5.0
#1 lore raw
Quoted 6 lines

Add missing break statement to prevent the code for case IIO_CHAN_INFO_CALIBBIAS falling through to the default case.

Also, add a break to the default case for the switch within case IIO_CHAN_INFO_CALIBBIAS.

fix seems to be cosmetic only...

Quoted 24 lines

Addresses-Coverity-ID: 1357377

---
This issue was reported by Coverity and it was tested by compilation only. Please, verify if this is an actual bug.

 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -0
index 44830bc..6d2268a 100644
@@ -542,7 +542,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
 			break;
 		default:
 			result = -EINVAL;
+			break;
 		}
+		break;
 	default:
 		result = -EINVAL;
 		break;
Signature · 2 lines
Peter Meerwald-Stadler
Mobile: +43 664 24 44 418
maintainer
#2 lore raw
Quoted 10 lines · On Wed, 23 Aug 2017 08:41:43 +0200 (CEST) Peter Meerwald-Stadler…
Quoted 5 lines

Add missing break statement to prevent the code for case IIO_CHAN_INFO_CALIBBIAS falling through to the default case.

Also, add a break to the default case for the switch within case IIO_CHAN_INFO_CALIBBIAS.

fix seems to be cosmetic only...

Quoted 2 lines

Addresses-Coverity-ID: 1357377

Indeed only cosmetic, but if it makes static analysis more productive by removing a trivial case, it is worth having.

Applied to the togreg branch of iio.git - will be pushed out as testing just as soon as I catch up with my backlog.

Jonathan

Quoted 23 lines
Quoted 22 lines

---
This issue was reported by Coverity and it was tested by compilation only. Please, verify if this is an actual bug.

 drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +2 -0
index 44830bc..6d2268a 100644
@@ -542,7 +542,9 @@ static int inv_mpu6050_write_raw(struct iio_dev *indio_dev,
 			break;
 		default:
 			result = -EINVAL;
+			break;
 		}
+		break;
 	default:
 		result = -EINVAL;
 		break;