[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHp75VdSQP8yeHNg7ZEGiYfPLJN9-oRywyASUPQxdazWpi=WdQ@mail.gmail.com>
Date: Tue, 19 Aug 2025 12:52:07 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Jonathan Cameron <jic23@...nel.org>
Cc: Junjie Cao <junjie.cao@...el.com>, linux-iio@...r.kernel.org, dlechner@...libre.com,
nuno.sa@...log.com, andy@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: core: Cast info mask to 'unsigned long *' in bit-ops
On Sat, Aug 16, 2025 at 2:11 PM Jonathan Cameron <jic23@...nel.org> wrote:
> On Fri, 15 Aug 2025 10:25:28 +0800
> Junjie Cao <junjie.cao@...el.com> wrote:
>
> > for_each_set_bit()/find_*_bit() expect 'const unsigned long *' (see
> > include/linux/find.h), but industrialio-core.c passes 'const long *'
> > in iio_device_add_info_mask_type{,_avail}(). Sparse flags a signedness
> > mismatch.
>
> How do you get that warning? I'm not seeing it.
With or without any warning the casting is a very bad practice for
bitmaps. NAK for any patch like this to any place in the kernel. I
already fixed some of such castings in the past (one may browse the
Git log with my name for that). Yes, I understand that in this case
it's not critical as the sizeof(long) == sizeof(unsigned long), but in
general this is not a good style leading to 3 potential issues
(out-of-boundary accesses or endianess).
> > The masks are used purely as bit arrays. Cast them to 'const unsigned
> > long *' at the call sites to match the helpers' prototypes, without
> > changing memory layout or behavior. Changing the field types would cause
> > unnecessary churn across IIO.
>
> Did you have a go? Superficially feels like we should fix this up and
> that it should be almost entirely confined to relatively few core functions
> and the types of the various elements of struct iio_dev.
>
> Might just be (builds and I'm not seeing new warning but then I couldn't trigger
> the one you saw!)
Jonathan, the patch you provided LGTM as I have in mind to do
something like this a long time ago. Please, proceed with it. It would
be better to have unsigned long * for bitmaps to make it uniform and
follow the API.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists