Messages in this thread | | | Date | Mon, 2 Oct 2023 00:36:28 -0700 | From | Kees Cook <> | Subject | Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by |
| |
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
| |