66c7723a | 23-Apr-2024 |
Andrew Jeffery <andrew@codeconstruct.com.au> |
msgbuf: Enable pldm_msgbuf_extract() into packed members
`pldm_msgbuf_extract()` should work correctly regardless of whether the `dst` argument is a member of a packed or padded struct.
To get ther
msgbuf: Enable pldm_msgbuf_extract() into packed members
`pldm_msgbuf_extract()` should work correctly regardless of whether the `dst` argument is a member of a packed or padded struct.
To get there while still achieving type safety we have to jump through some hoops. Commentary in the patch hopefully captures many of them, but a side-effect of the hoop-jumping is a couple of changes to ergonomics of the msgbuf API:
1. `pldm_msgbuf_extract()` no-longer requires that the `dst` argument be a pointer. Instead, it must be an lvalue, removing all the `&<lvalue>` noise from the call-sites.
2. However, unfortunately the generic extraction macro has been split in two. We now have:
2.1 `pldm_msgbuf_extract()`, and 2.2 `pldm_msgbuf_extract_p()`, for when the reference we already have for the `dst` object is a pointer and not an lvalue.
The split was necessary because I couldn't get GCC and Clang to play nice with differences required in the assignment expression for lvalue and pointer type-names in the one macro. Whilst it causes a bunch of churn it isn't a great concern as the APIs are purely internal to the library implementation.
Change-Id: Ifc5440a5b838a48bb84c881ec334d9e145365edb Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au> Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
show more ...
|