Skip to content

Commit 64bc2d0

Browse files
arndbjic23
authored andcommitted
iio: accel: sca3000_core: avoid potentially uninitialized variable
The newly added __sca3000_get_base_freq function handles all valid modes of the SCA3000_REG_ADDR_MODE register, but gcc notices that any other value (i.e. 0x00) causes the base_freq variable to not get initialized: drivers/staging/iio/accel/sca3000_core.c: In function 'sca3000_write_raw': drivers/staging/iio/accel/sca3000_core.c:527:23: error: 'base_freq' may be used uninitialized in this function [-Werror=maybe-uninitialized] This adds explicit error handling for unexpected register values, to ensure this cannot happen. Fixes: e0f3fc9 ("iio: accel: sca3000_core: implemented IIO_CHAN_INFO_SAMP_FREQ") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Ico Doornekamp <ico@pruts.nl> Cc: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent d1fe85e commit 64bc2d0

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/staging/iio/accel/sca3000_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ static inline int __sca3000_get_base_freq(struct sca3000_state *st,
468468
case SCA3000_MEAS_MODE_OP_2:
469469
*base_freq = info->option_mode_2_freq;
470470
break;
471+
default:
472+
ret = -EINVAL;
471473
}
472474
error_ret:
473475
return ret;

0 commit comments

Comments
 (0)