bios_table: Relax pldm_bios_table_attr_entry_enum_decode_pv_hdls_check()

Allow the number of handles decoded by
pldm_bios_table_attr_entry_enum_decode_pv_hdls_check() to be fewer than
the number of handles reported by
pldm_bios_table_attr_entry_enum_decode_pv_num_check(). The relaxation
provides equivalent behaviour to
pldm_bios_table_attr_entry_enum_decode_pv_hdls() but provides assert()
safety by instead returning an error.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I1d51174450cbe97c9985a1361e235d90efc19b35
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b19d23e..15dd472 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -41,6 +41,7 @@
    when invoking `meson setup`
 
 4. bios_table: Relax pldm_bios_table_string_entry_decode_string_check()
+5. bios_table: Relax pldm_bios_table_attr_entry_enum_decode_pv_hdls_check()
 
 ### Removed
 
diff --git a/include/libpldm/bios_table.h b/include/libpldm/bios_table.h
index f56b066..30f3b14 100644
--- a/include/libpldm/bios_table.h
+++ b/include/libpldm/bios_table.h
@@ -316,9 +316,11 @@
  *  @param[in] pv_num - Number of PossibleValuesStringHandles the buffer can
  * store
  *  @return PLDM_SUCCESS on success, otherwise PLDM_ERROR_INVALID_DATA if entry or pv_hdls are NULL,
- *          or entry is not of type PLDM_BIOS_ENUMERATION, or the number of possible values is not
- *          equal to pv_num. An appropriate value for pv_num can be determined using @ref
- *          pldm_bios_table_attr_entry_enum_decode_pv_num_check
+ *          or entry is not of type PLDM_BIOS_ENUMERATION. An appropriate value for pv_num can be
+ *          determined using @ref pldm_bios_table_attr_entry_enum_decode_pv_num_check. pv_num may be
+ *          less than the value provided by @ref
+ *          pldm_bios_table_attr_entry_enum_decode_pv_num_check, in which case only the first pv_num
+ *          handles will be decoded.
  */
 int pldm_bios_table_attr_entry_enum_decode_pv_hdls_check(
 	const struct pldm_bios_attr_table_entry *entry, uint16_t *pv_hdls,
diff --git a/src/bios_table.c b/src/bios_table.c
index d6cf6f3..a861a87 100644
--- a/src/bios_table.c
+++ b/src/bios_table.c
@@ -287,10 +287,6 @@
 	POINTER_CHECK(entry);
 	POINTER_CHECK(pv_hdls);
 	ATTR_TYPE_EXPECT(entry->attr_type, PLDM_BIOS_ENUMERATION);
-	uint8_t num = pldm_bios_table_attr_entry_enum_decode_pv_num(entry);
-	if (num != pv_num) {
-		return PLDM_ERROR_INVALID_DATA;
-	}
 	pldm_bios_table_attr_entry_enum_decode_pv_hdls(entry, pv_hdls, pv_num);
 	return PLDM_SUCCESS;
 }
diff --git a/tests/libpldm_bios_table_test.cpp b/tests/libpldm_bios_table_test.cpp
index c677b99..9e9a767 100644
--- a/tests/libpldm_bios_table_test.cpp
+++ b/tests/libpldm_bios_table_test.cpp
@@ -102,7 +102,7 @@
     EXPECT_EQ(pvHandles[1], 3);
     rc = pldm_bios_table_attr_entry_enum_decode_pv_hdls_check(
         entry, pvHandles.data(), 1);
-    EXPECT_EQ(rc, PLDM_ERROR_INVALID_DATA);
+    EXPECT_EQ(rc, PLDM_SUCCESS);
 
     uint8_t defNumber = pldm_bios_table_attr_entry_enum_decode_def_num(entry);
     EXPECT_EQ(defNumber, 1);