msgbuf: Add error code personalities
libpldm is in a bit of a transitional period with respect to returned
error codes. A historical choice was to return PLDM completion codes
from the library API to indicate errors. This is unfortunate because
we're now constrained to errors that are specified by the PLDM protocol,
which is much less expressive than the set of errors that might be
produced by a run-time environment for the library.
The choice going forward is to return C's errno codes. However at this
point we step on another rake in the libpldm design, which is that some
internal data structures are very much the wire format of corresponding
PLDM messages (such as the PDR repository implementation). Working with
wire-format buffers is most safely done via the msgbuf APIs, however we
then hit the conflict of different error code styles in various parts of
the API surface.
Do a bit of surgery to provide different error code personalities for
msgbuf, such that the caller can pick the style of error code they need
it to return to maintain consistency.
Note that like the previous patch marking all msgbuf APIs as
__attribute__((always_inline)), the rework here makes another small
impact on the argument register allocation of several stable APIs. The
ABI dump is updated accordingly.
Change-Id: Id59c39c5c822f514f546dab88575317071a97c96
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/tests/libpldm_firmware_update_test.cpp b/tests/libpldm_firmware_update_test.cpp
index 76c5814..24bde16 100644
--- a/tests/libpldm_firmware_update_test.cpp
+++ b/tests/libpldm_firmware_update_test.cpp
@@ -1326,8 +1326,8 @@
struct pldm_msgbuf _buf;
struct pldm_msgbuf* buf = &_buf;
- rc = pldm_msgbuf_init(buf, 0, responseMsg.data() + hdrSize,
- responseMsg.size() - hdrSize);
+ rc = pldm_msgbuf_init_cc(buf, 0, responseMsg.data() + hdrSize,
+ responseMsg.size() - hdrSize);
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm_msgbuf_insert_uint8(buf, completion_code_resp);
@@ -1373,8 +1373,8 @@
struct pldm_msgbuf _buf;
struct pldm_msgbuf* buf = &_buf;
- rc = pldm_msgbuf_init(buf, 0, responseMsg.data() + hdrSize,
- responseMsg.size() - hdrSize);
+ rc = pldm_msgbuf_init_cc(buf, 0, responseMsg.data() + hdrSize,
+ responseMsg.size() - hdrSize);
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm_msgbuf_insert_uint8(buf, completion_code_resp);
@@ -1414,8 +1414,8 @@
struct pldm_msgbuf _buf;
struct pldm_msgbuf* buf = &_buf;
- rc = pldm_msgbuf_init(buf, 0, responseMsg.data() + hdrSize,
- responseMsg.size() - hdrSize);
+ rc = pldm_msgbuf_init_cc(buf, 0, responseMsg.data() + hdrSize,
+ responseMsg.size() - hdrSize);
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm_msgbuf_insert_uint8(buf, completion_code_resp);
@@ -1507,8 +1507,8 @@
struct pldm_msgbuf _buf;
struct pldm_msgbuf* buf = &_buf;
- rc = pldm_msgbuf_init(buf, 0, responseMsg.data() + hdrSize,
- responseMsg.size() - hdrSize);
+ rc = pldm_msgbuf_init_cc(buf, 0, responseMsg.data() + hdrSize,
+ responseMsg.size() - hdrSize);
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm_msgbuf_insert_uint8(buf, complition_code_resp);
@@ -1599,8 +1599,8 @@
struct pldm_msgbuf _buf;
struct pldm_msgbuf* buf = &_buf;
- rc = pldm_msgbuf_init(buf, 0, responseMsg.data() + hdrSize,
- responseMsg.size() - hdrSize);
+ rc = pldm_msgbuf_init_cc(buf, 0, responseMsg.data() + hdrSize,
+ responseMsg.size() - hdrSize);
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm_msgbuf_insert_uint8(buf, complition_code_resp);
@@ -1662,8 +1662,8 @@
struct pldm_msgbuf _buf;
struct pldm_msgbuf* buf = &_buf;
- rc = pldm_msgbuf_init(buf, 0, responseMsg.data() + hdrSize,
- responseMsg.size() - hdrSize);
+ rc = pldm_msgbuf_init_cc(buf, 0, responseMsg.data() + hdrSize,
+ responseMsg.size() - hdrSize);
EXPECT_EQ(rc, PLDM_SUCCESS);
pldm_msgbuf_insert_uint8(buf, complition_code_resp);