pdr: Introduce pldm_pdr_add_fru_record_set_check()
pldm_pdr_add_fru_record_set() relied on assert() to communicate failure
to the caller. Introduce pldm_pdr_add_fru_record_set_check() which
instead returns a value indicating success or failure.
pldm_pdr_add_fru_record_set() will be deprecated once
pldm_pdr_add_fru_record_set_check() is stabilised.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I1e09a5663895f1e09b5e40afe5db4b4864d3496e
diff --git a/src/pdr.c b/src/pdr.c
index 01f5002..2bafed7 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -293,13 +293,28 @@
uint16_t container_id,
uint32_t bmc_record_handle)
{
+ int rc = pldm_pdr_add_fru_record_set_check(
+ repo, terminus_handle, fru_rsi, entity_type,
+ entity_instance_num, container_id, &bmc_record_handle);
+ (void)rc;
+ assert(!rc);
+ return bmc_record_handle;
+}
+
+LIBPLDM_ABI_TESTING
+int pldm_pdr_add_fru_record_set_check(pldm_pdr *repo, uint16_t terminus_handle,
+ uint16_t fru_rsi, uint16_t entity_type,
+ uint16_t entity_instance_num,
+ uint16_t container_id,
+ uint32_t *bmc_record_handle)
+{
uint32_t size = sizeof(struct pldm_pdr_hdr) +
sizeof(struct pldm_pdr_fru_record_set);
uint8_t data[size];
struct pldm_pdr_hdr *hdr = (struct pldm_pdr_hdr *)&data;
hdr->version = 1;
- hdr->record_handle = bmc_record_handle;
+ hdr->record_handle = *bmc_record_handle;
hdr->type = PLDM_PDR_FRU_RECORD_SET;
hdr->record_change_num = 0;
hdr->length = htole16(sizeof(struct pldm_pdr_fru_record_set));
@@ -312,8 +327,8 @@
fru->entity_instance_num = htole16(entity_instance_num);
fru->container_id = htole16(container_id);
- return pldm_pdr_add(repo, data, size, bmc_record_handle, false,
- terminus_handle);
+ return pldm_pdr_add_check(repo, data, size, false, terminus_handle,
+ bmc_record_handle);
}
LIBPLDM_ABI_STABLE