Re: [PATCH v2 1/1] scsi: qla2xxx: replace non-standard flexible array purex_item.iocb

Gustavo A. R. Silva
2025-07-29T01:37:32Z

> default item was replaced with the header and a static sized array,
> cast to a purex_item * when returned through the alloc function
>
> - struct purex_item default_item;
> + struct purex_item_hdr default_item;
> + uint8_t __default_item_iocb[QLA_DEFAULT_PAYLOAD_SIZE];

I see; yeah, this works as `(struct purex_item *)default_item->iocb`
and `__default_item_iocb` happen to be just perfectly aligned. However,
I wonder if there is any chance of this changing in the future...

Probably, a code comment stating that both `(struct purex_item *)default_item->iocb`
and `__default_item_iocb` are expected to share the same address would
likely be helpful for anyone modifying something around this code in
the future.

BTW, instead of directly casting to `struct purex_item *`, you could
use `container_of()` like this:

item = container_of(&vha->default_item, struct purex_item, __hdr);

but I guess that's up to maintainer's preference.

Thanks
-Gustavo