pdr: Introduce pldm_entity_association_pdr_add_from_node_check()
pldm_entity_association_pdr_add_from_node_check() returns whether or not
the operation was successful.
pldm_entity_association_pdr_add_from_node() is reimplemented in terms of
pldm_entity_association_pdr_add_from_node_check() with the intent that
it be deprecated once pldm_entity_association_pdr_add_from_node_check()
is stabilised.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I186c377bfc1038195540a6cdfd65db7e1126e869
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9883eb4..2b86199 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -21,6 +21,7 @@
1. bios_table: Introduce pldm_bios_table_append_pad_checksum_check()
2. fru: Introduce get_fru_record_by_option_check()
+3. pdr: Introduce pldm_entity_association_pdr_add_from_node_check()
### Changed
diff --git a/include/libpldm/pdr.h b/include/libpldm/pdr.h
index 413ef7a..8ace295 100644
--- a/include/libpldm/pdr.h
+++ b/include/libpldm/pdr.h
@@ -426,6 +426,7 @@
void pldm_entity_association_pdr_add(pldm_entity_association_tree *tree,
pldm_pdr *repo, bool is_remote,
uint16_t terminus_handle);
+
/** @brief Add entity association pdr from node
*
* @param[in] node - opaque pointer acting as a handle to an entity node
@@ -437,6 +438,19 @@
pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities,
size_t num_entities, bool is_remote, uint16_t terminus_handle);
+/** @brief Add entity association pdr from node, or return an error
+ *
+ * @param[in] node - opaque pointer acting as a handle to an entity node
+ * @param[in] repo - PDR repo where entity association records should be added
+ * @param[in] is_remote - if true, then the PDR is not from this terminus
+ * @param[in] terminus_handle - terminus handle of the terminus
+ *
+ * @return 0 on success, -EINVAL if the provided arguments are invalid.
+ */
+int pldm_entity_association_pdr_add_from_node_check(
+ pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities,
+ size_t num_entities, bool is_remote, uint16_t terminus_handle);
+
/** @brief Add entity association pdr record based on record handle
* earlier the records where added in a sequential way alone, with
* this change the entity association PDR records gets the new record
diff --git a/src/pdr.c b/src/pdr.c
index 7266ecd..bbda618 100644
--- a/src/pdr.c
+++ b/src/pdr.c
@@ -931,9 +931,18 @@
pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities,
size_t num_entities, bool is_remote, uint16_t terminus_handle)
{
- assert(repo != NULL);
+ int rc = pldm_entity_association_pdr_add_from_node_check(
+ node, repo, entities, num_entities, is_remote, terminus_handle);
+ (void)rc;
+ assert(!rc);
+}
- pldm_entity_association_pdr_add_from_node_with_record_handle(
+LIBPLDM_ABI_TESTING
+int pldm_entity_association_pdr_add_from_node_check(
+ pldm_entity_node *node, pldm_pdr *repo, pldm_entity **entities,
+ size_t num_entities, bool is_remote, uint16_t terminus_handle)
+{
+ return pldm_entity_association_pdr_add_from_node_with_record_handle(
node, repo, entities, num_entities, is_remote, terminus_handle,
0);
}