libpldmresponder: Migrate to pldm_pdr_add_fru_record_set_check()
pldm_pdr_add_fru_record_set() is deprecated in libpldm as it used
assert() to communicate failure to the caller.
pldm_pdr_add_fru_record_set_check() instead returns a value indicating
success or failure.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I88ed90a03b15a949641788906495c9507a5a196b
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index dac7ff2..303f413 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -233,10 +233,16 @@
{
recordSetIdentifier = nextRSI();
bmc_record_handle = nextRecordHandle();
- pldm_pdr_add_fru_record_set(
+ int rc = pldm_pdr_add_fru_record_set_check(
pdrRepo, TERMINUS_HANDLE, recordSetIdentifier,
entity.entity_type, entity.entity_instance_num,
- entity.entity_container_id, bmc_record_handle);
+ entity.entity_container_id, &bmc_record_handle);
+ if (rc)
+ {
+ // pldm_pdr_add_fru_record_set() assert()ed on failure
+ throw std::runtime_error(
+ "Failed to add PDR FRU record set");
+ }
}
auto curSize = table.size();
table.resize(curSize + recHeaderSize + tlvs.size());