Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
On 24/09/16 17:18, SF Markus Elfring wrote: >> Applied to the togreg branch of iio.git - initially pushed out >> as testing for the autobuilders to play with it. > > Thanks for your positive response. > > > Do you see any need to improve the software situation around > the macro "BITS_TO_LONGS" further? > > Do you fiddle with a programming interface like "bitmap_alloc" occasionally? It might be clearer than having an array allocation as we do after this patch. Obviously the representation is an array, but it is a little ugly as it stands! > > Regards, > Markus > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
On 24/09/16 17:18, SF Markus Elfring wrote: >> Applied to the togreg branch of iio.git - initially pushed out >> as testing for the autobuilders to play with it. > > Thanks for your positive response. > > > Do you see any need to improve the software situation around > the macro "BITS_TO_LONGS" further? > > Do you fiddle with a programming interface like "bitmap_alloc" occasionally? It might be clearer than having an array allocation as we do after this patch. Obviously the representation is an array, but it is a little ugly as it stands! > > Regards, > Markus > -- > To unsubscribe from this list: send the line "unsubscribe linux-iio" in > the body of a message to majord...@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
> Applied to the togreg branch of iio.git - initially pushed out > as testing for the autobuilders to play with it. Thanks for your positive response. Do you see any need to improve the software situation around the macro "BITS_TO_LONGS" further? Do you fiddle with a programming interface like "bitmap_alloc" occasionally? Regards, Markus
Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
> Applied to the togreg branch of iio.git - initially pushed out > as testing for the autobuilders to play with it. Thanks for your positive response. Do you see any need to improve the software situation around the macro "BITS_TO_LONGS" further? Do you fiddle with a programming interface like "bitmap_alloc" occasionally? Regards, Markus
Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
On 24/09/16 07:24, SF Markus Elfring wrote: > From: Markus Elfring> Date: Fri, 23 Sep 2016 22:30:32 +0200 > > A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus use the corresponding function "kmalloc_array". > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/industrialio-buffer.c | 7 +++ > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/industrialio-buffer.c > b/drivers/iio/industrialio-buffer.c > index 49bf9c5..7a4d9499 100644 > --- a/drivers/iio/industrialio-buffer.c > +++ b/drivers/iio/industrialio-buffer.c > @@ -307,10 +307,9 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, > const unsigned long *mask; > unsigned long *trialmask; > > - trialmask = kmalloc(sizeof(*trialmask)* > - BITS_TO_LONGS(indio_dev->masklength), > - GFP_KERNEL); > - > + trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength), > + sizeof(*trialmask), > + GFP_KERNEL); > if (trialmask == NULL) > return -ENOMEM; > if (!indio_dev->masklength) { >
Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
On 24/09/16 07:24, SF Markus Elfring wrote: > From: Markus Elfring > Date: Fri, 23 Sep 2016 22:30:32 +0200 > > A multiplication for the size determination of a memory allocation > indicated that an array data structure should be processed. > Thus use the corresponding function "kmalloc_array". > > This issue was detected by using the Coccinelle software. > > Signed-off-by: Markus Elfring Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/industrialio-buffer.c | 7 +++ > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/industrialio-buffer.c > b/drivers/iio/industrialio-buffer.c > index 49bf9c5..7a4d9499 100644 > --- a/drivers/iio/industrialio-buffer.c > +++ b/drivers/iio/industrialio-buffer.c > @@ -307,10 +307,9 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, > const unsigned long *mask; > unsigned long *trialmask; > > - trialmask = kmalloc(sizeof(*trialmask)* > - BITS_TO_LONGS(indio_dev->masklength), > - GFP_KERNEL); > - > + trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength), > + sizeof(*trialmask), > + GFP_KERNEL); > if (trialmask == NULL) > return -ENOMEM; > if (!indio_dev->masklength) { >
[PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
From: Markus ElfringDate: Fri, 23 Sep 2016 22:30:32 +0200 A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/iio/industrialio-buffer.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 49bf9c5..7a4d9499 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -307,10 +307,9 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, const unsigned long *mask; unsigned long *trialmask; - trialmask = kmalloc(sizeof(*trialmask)* - BITS_TO_LONGS(indio_dev->masklength), - GFP_KERNEL); - + trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength), + sizeof(*trialmask), + GFP_KERNEL); if (trialmask == NULL) return -ENOMEM; if (!indio_dev->masklength) { -- 2.10.0
[PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
From: Markus Elfring Date: Fri, 23 Sep 2016 22:30:32 +0200 A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "kmalloc_array". This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/iio/industrialio-buffer.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 49bf9c5..7a4d9499 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -307,10 +307,9 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, const unsigned long *mask; unsigned long *trialmask; - trialmask = kmalloc(sizeof(*trialmask)* - BITS_TO_LONGS(indio_dev->masklength), - GFP_KERNEL); - + trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength), + sizeof(*trialmask), + GFP_KERNEL); if (trialmask == NULL) return -ENOMEM; if (!indio_dev->masklength) { -- 2.10.0