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>
diff --git a/src/oem/meta/file_io.c b/src/oem/meta/file_io.c
index ab6c7a6..0495ac5 100644
--- a/src/oem/meta/file_io.c
+++ b/src/oem/meta/file_io.c
@@ -26,8 +26,8 @@
return rc;
}
- pldm_msgbuf_extract(buf, file_handle);
- pldm_msgbuf_extract(buf, length);
+ pldm_msgbuf_extract_p(buf, file_handle);
+ pldm_msgbuf_extract_p(buf, length);
pldm_msgbuf_extract_array_uint8(buf, data, *length);
return pldm_msgbuf_destroy_consumed(buf);