pldmtool: Report an error when an attribute is not found
The GetBIOSAttributeCurrentValue command requires attribute
name as a parameter, we should report an error to user
when the attribute name is not found
Tested:
root@fp5280g2:/tmp# ./pldmtool bios getbiosattributeCurrentValueByHandle -a Led
CurrentValue: On
root@fp5280g2:/tmp# ./pldmtool bios getbiosattributeCurrentValueByHandle -a xxx
Can not find the attribute xxx
root@fp5280g2:/tmp# ./pldmtool bios getbiosattributeCurrentValueByHandle -a 3
Can not find the attribute 3
Signed-off-by: John Wang <wangzqbj@inspur.com>
Change-Id: Ie57e438b28e1150512ec29ae0baa772e6f58bb1a
diff --git a/tool/pldm_bios_cmd.cpp b/tool/pldm_bios_cmd.cpp
index 823648b..3e554b1 100644
--- a/tool/pldm_bios_cmd.cpp
+++ b/tool/pldm_bios_cmd.cpp
@@ -685,6 +685,12 @@
}
auto handle = findAttrHandleByName(attrName, *attrTable, *stringTable);
+ if (!handle)
+ {
+
+ std::cerr << "Can not find the attribute " << attrName << std::endl;
+ return;
+ }
std::vector<uint8_t> requestMsg(
sizeof(pldm_msg_hdr) +