pldm: Migrate off deprecated libpldm BIOS table entry encoding APIs

libpldm has deprecated the affected APIs. Prefer using their `*_check()`
variants as these return an error code rather than prevent misbehaviour
with assert().

1. pldm_bios_table_attr_entry_integer_encode()
2. pldm_bios_table_attr_value_entry_encode_enum()
3. pldm_bios_table_attr_value_entry_encode_string()
4. pldm_bios_table_attr_value_entry_encode_integer()

Tested: Successfully booted a p10bmc host, dumped each of the BIOS
        tables with pldmtool without issue

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I823b24884e518f8c53fd153b3bc30569595ecd86
diff --git a/libpldmresponder/bios_table.cpp b/libpldmresponder/bios_table.cpp
index 898a34a..f29d813 100644
--- a/libpldmresponder/bios_table.cpp
+++ b/libpldmresponder/bios_table.cpp
@@ -161,7 +161,6 @@
                    "LIBPLDM_ERROR", rc);
         throw std::runtime_error("Failed to encode BIOS table string entry");
     }
-
     return reinterpret_cast<pldm_bios_attr_table_entry*>(table.data() +
                                                          tableSize);
 }
@@ -173,8 +172,16 @@
     auto entryLength = pldm_bios_table_attr_entry_integer_encode_length();
     auto tableSize = table.size();
     table.resize(tableSize + entryLength, 0);
-    pldm_bios_table_attr_entry_integer_encode(table.data() + tableSize,
-                                              entryLength, info);
+    int rc = pldm_bios_table_attr_entry_integer_encode_check(
+        table.data() + tableSize, entryLength, info);
+    if (rc != PLDM_SUCCESS)
+    {
+        lg2::error(
+            "Failed to encode BIOS attribute table integer entry: {LIBPLDM_ERROR}",
+            "LIBPLDM_ERROR", rc);
+        throw std::runtime_error(
+            "Failed to encode BIOS attribute table integer entry");
+    }
     return reinterpret_cast<pldm_bios_attr_table_entry*>(table.data() +
                                                          tableSize);
 }
@@ -299,9 +306,17 @@
         pldm_bios_table_attr_value_entry_encode_string_length(strLen);
     auto tableSize = table.size();
     table.resize(tableSize + entryLength);
-    pldm_bios_table_attr_value_entry_encode_string(
+    int rc = pldm_bios_table_attr_value_entry_encode_string_check(
         table.data() + tableSize, entryLength, attrHandle, attrType, strLen,
         str.c_str());
+    if (rc != PLDM_SUCCESS)
+    {
+        lg2::error(
+            "Failed to encode BIOS attribute table string entry: {LIBPLDM_ERROR}",
+            "LIBPLDM_ERROR", rc);
+        throw std::runtime_error(
+            "Failed to encode BIOS attribute table string entry");
+    }
     return reinterpret_cast<pldm_bios_attr_val_table_entry*>(table.data() +
                                                              tableSize);
 }
@@ -329,9 +344,17 @@
         handleIndices.size());
     auto tableSize = table.size();
     table.resize(tableSize + entryLength);
-    pldm_bios_table_attr_value_entry_encode_enum(
+    int rc = pldm_bios_table_attr_value_entry_encode_enum_check(
         table.data() + tableSize, entryLength, attrHandle, attrType,
         handleIndices.size(), handleIndices.data());
+    if (rc != PLDM_SUCCESS)
+    {
+        lg2::error(
+            "Failed to encode BIOS attribute table enum entry: {LIBPLDM_ERROR}",
+            "LIBPLDM_ERROR", rc);
+        throw std::runtime_error(
+            "Failed to encode BIOS attribute table enum entry");
+    }
     return reinterpret_cast<pldm_bios_attr_val_table_entry*>(table.data() +
                                                              tableSize);
 }