Improving the clarity of the code
Callers of the function
pldm_bios_table_attr_value_entry_enum_decode_handles() provide the
pointer to the buffer and its size. Modifying the buffer size and using
it in the library can be error-prone. Adjust the code to only read the
buffer size and not to modify it.
Tested:
Unit Tests passed.
Change-Id: I26e843fa817e969719aa19f1922b4ea8622078f2
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/tests/libpldm_bios_table_test.cpp b/tests/libpldm_bios_table_test.cpp
index 83e7fd9..d42d126 100644
--- a/tests/libpldm_bios_table_test.cpp
+++ b/tests/libpldm_bios_table_test.cpp
@@ -637,6 +637,21 @@
EXPECT_EQ(rc, 2);
EXPECT_EQ(handles[0], 0);
EXPECT_EQ(handles[1], 1);
+
+ /* Buffer size is more than the number of current string handles */
+ std::vector<uint8_t> handleIndexes(3, 0);
+ rc = pldm_bios_table_attr_value_entry_enum_decode_handles(
+ entry, handleIndexes.data(), handleIndexes.size());
+ EXPECT_EQ(rc, 2);
+ EXPECT_EQ(handleIndexes[0], 0);
+ EXPECT_EQ(handleIndexes[1], 1);
+
+ /* Buffersize is less than the number of current string handles */
+ std::vector<uint8_t> strHandles(1, 0);
+ rc = pldm_bios_table_attr_value_entry_enum_decode_handles(
+ entry, strHandles.data(), strHandles.size());
+ EXPECT_EQ(rc, 1);
+ EXPECT_EQ(strHandles[0], 0);
}
TEST(AttrValTable, stringEntryEncodeTest)