Re: [PATCH v3 20/28] staging: iio: tsl2583: don't assume an unsigned int is 32 bits

From: Jonathan Cameron
Date: Sat Nov 12 2016 - 11:40:29 EST


On 10/11/16 09:25, Brian Masney wrote:
> in_illuminance_lux_table_store assumes that an unsigned int is 32 bits.
> Replace this with sizeof(unsigned int).
>
> Signed-off-by: Brian Masney <masneyb@xxxxxxxxxxxxx>
Preferred to use sizeof(value[0]) in case it changes type sometime in the future?
> ---
> drivers/staging/iio/light/tsl2583.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 1b883b5..bcee31b 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -578,7 +578,7 @@ static ssize_t in_illuminance_lux_table_store(struct device *dev,
>
> /* Zero out the table */
> memset(tsl2583_device_lux, 0, sizeof(tsl2583_device_lux));
> - memcpy(tsl2583_device_lux, &value[1], value[0] * 4);
> + memcpy(tsl2583_device_lux, &value[1], value[0] * sizeof(unsigned int));
>
> ret = len;
>
>