Skip to content

Commit 6a8e56f

Browse files
authored
Merge pull request #590 from branupama/fix_convert_to_binary
vpd-tool: fix even length keyword value
2 parents d80714e + ed2551d commit 6a8e56f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

vpd-tool/include/tool_utils.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,17 +356,17 @@ inline types::BinaryVector convertToBinary(const std::string& i_value)
356356
"Provide a valid hexadecimal input. (Ex. 0x30313233)");
357357
}
358358

359-
if (i_value.length() % 2 != 0)
360-
{
361-
throw std::runtime_error(
362-
"Write option accepts 2 digit hex numbers. (Ex. 0x1 "
363-
"should be given as 0x01).");
364-
}
365-
366359
std::vector<uint8_t> l_binaryValue{};
367360

368361
if (i_value.substr(0, 2).compare("0x") == constants::STR_CMP_SUCCESS)
369362
{
363+
if (i_value.length() % 2 != 0)
364+
{
365+
throw std::runtime_error(
366+
"Write option accepts 2 digit hex numbers. (Ex. 0x1 "
367+
"should be given as 0x01).");
368+
}
369+
370370
auto l_value = i_value.substr(2);
371371

372372
if (l_value.empty())

0 commit comments

Comments
 (0)