Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by
From: Kees Cook
Date: Mon Oct 02 2023 - 03:36:40 EST
On Mon, Oct 02, 2023 at 07:38:42AM +0200, Julia Lawall wrote:
> The sizeof with an expression argument is treated differently than the
> sizeof with a type argument. So you need to write:
>
> @allocated@
> identifier STRUCT, ARRAY;
> expression COUNT;
> struct STRUCT *PTR;
> identifier ALLOC;
> type ELEMENT_TYPE;
> @@
>
> PTR = ALLOC(..., \(sizeof(*PTR)\|sizeof(struct STRUCT)\) +
> COUNT * \(sizeof(*PTR->ARRAY)\|sizeof(PTR->ARRAY[0])\|sizeof(ELEMENT_TYPE)\), ...);
Ah! Thank you thank you! Yes, this works great now. :)
--
Kees Cook