Re: [PATCH] gpiolib: annotate struct acpi_gpio_mapping with __counted_by_ptr

From: Bill Wendling

Date: Mon Oct 05 2026 - 06:28:59 EST


On Mon, Oct 5, 2026 at 2:31 AM Justin Stitt <justinstitt@xxxxxxxxxx> wrote:
>
> Hi,
>
> On Thu, Oct 01, 2026 at 01:04:47PM -0700, Bill Wendling wrote:
> > On Thu, Oct 1, 2026 at 12:56 PM Linus Walleij <linusw@xxxxxxxxxx> wrote:
>
> <snip>
>
> > It's being #included transitively:
> >
> > In file included from drivers/firmware/efi/libstub/efi-stub-helper.c:12:
> > In file included from ./include/linux/efi.h:20:
> > In file included from ./include/linux/rtc.h:18:
> > In file included from ./include/linux/nvmem-provider.h:16:
> > ./include/linux/gpio/consumer.h:670:55: error: use of undeclared
> > identifier 'size'; did you
> > mean 'ksize'?
> > 670 | const struct acpi_gpio_params *data __counted_by_ptr(size);
> > | ^~~~
> > | ksize
> > ././include/linux/compiler_types.h:392:64: note: expanded from macro
> > '__counted_by_ptr'
> > 392 | #define __counted_by_ptr(member)
> > __attribute__((__counted_by__(member)))
> > |
> > ^~~~~~
> > ./include/linux/slab.h:602:8: note: 'ksize' declared here
> > 602 | size_t ksize(const void *objp);
> > | ^
> >
>
> I wonder if we could have a better warning here guiding you towards
> -fexperimental-late-parse-attributes?
>
I sent a patch to add `__NO_COUNTED_BY` AND `__NO_COUNTED_BY_PTR`
macros to prevent this. They're similar to `__NO_FORTIFY`.

https://lore.kernel.org/all/20261005102518.2400984-1-morbo@xxxxxxxxxx/

-bw