Skip to content

Commit

Permalink
Merge pull request #590 from branupama/fix_convert_to_binary
Browse files Browse the repository at this point in the history
vpd-tool: fix even length keyword value
  • Loading branch information
jinuthomas authored Jan 15, 2025
2 parents d80714e + ed2551d commit 6a8e56f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vpd-tool/include/tool_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,17 @@ inline types::BinaryVector convertToBinary(const std::string& i_value)
"Provide a valid hexadecimal input. (Ex. 0x30313233)");
}

if (i_value.length() % 2 != 0)
{
throw std::runtime_error(
"Write option accepts 2 digit hex numbers. (Ex. 0x1 "
"should be given as 0x01).");
}

std::vector<uint8_t> l_binaryValue{};

if (i_value.substr(0, 2).compare("0x") == constants::STR_CMP_SUCCESS)
{
if (i_value.length() % 2 != 0)
{
throw std::runtime_error(
"Write option accepts 2 digit hex numbers. (Ex. 0x1 "
"should be given as 0x01).");
}

auto l_value = i_value.substr(2);

if (l_value.empty())
Expand Down

0 comments on commit 6a8e56f

Please sign in to comment.