On 2/25/19 4:00 PM, Huw Davies wrote:
On Mon, Feb 25, 2019 at 03:39:14PM +0200, Gabriel Ivăncescu wrote:
Ok, I have a question now: can I use a small helper that uses the cast instead of a union? Something like:
static inline BYTE *get_nodata_items(const LB_DESCR *descr) { return (BYTE*)descr->items; }
And use it where needed? It would require less changes to the code and, IMO, keep it cleaner (other than the one helper above). Such helpers are frequent in other parts of the code (mostly dealing with COM stuff).
No. That's just hiding the hack. The issue is that regular storage and no date storage should have an equal footing. With a union it's clear. The only places you should need to change of the helpers and most of those don't do anything in the no data case, so it shouldn't be too bad.
Yes I just find the "descr->u.items" slightly uglier and wanted to avoid it even if it's a simple no-op (the u. part) since we don't have anon unions, but okay I'll use an union then :-)