iio: core: Fix suspicious sizeof usage

Pointer size is variours in different system, say 32bit for 4 and 64bit
for 8. The 'sizeof(infomask)' may lead to wrong bit numbers.

Signed-off-by: Orson Zhai <orson.zhai@spreadtrum.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
Orson Zhai 2017-04-25 09:16:56 +08:00 committed by Jonathan Cameron
parent 80a49fd824
commit 1016d56765

View File

@ -1089,7 +1089,7 @@ static int iio_device_add_info_mask_type(struct iio_dev *indio_dev,
{ {
int i, ret, attrcount = 0; int i, ret, attrcount = 0;
for_each_set_bit(i, infomask, sizeof(infomask)*8) { for_each_set_bit(i, infomask, sizeof(*infomask)*8) {
if (i >= ARRAY_SIZE(iio_chan_info_postfix)) if (i >= ARRAY_SIZE(iio_chan_info_postfix))
return -EINVAL; return -EINVAL;
ret = __iio_add_chan_devattr(iio_chan_info_postfix[i], ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
@ -1118,7 +1118,7 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev,
int i, ret, attrcount = 0; int i, ret, attrcount = 0;
char *avail_postfix; char *avail_postfix;
for_each_set_bit(i, infomask, sizeof(infomask) * 8) { for_each_set_bit(i, infomask, sizeof(*infomask) * 8) {
avail_postfix = kasprintf(GFP_KERNEL, avail_postfix = kasprintf(GFP_KERNEL,
"%s_available", "%s_available",
iio_chan_info_postfix[i]); iio_chan_info_postfix[i]);