Fix logical error from changing type to unsigned

master
Adam Honse 2 months ago
parent c76864dd4b
commit 9ad37cc98f

@ -131,12 +131,12 @@ std::string SPDAccessor::read_part_nr_at(uint16_t address, std::size_t len)
| Note: To prevent infinite loop, end_of_string_idx |
| MUST be signed. |
\*-----------------------------------------------------*/
std::size_t end_of_string_idx = part_number.length() - 1;
std::size_t end_of_string_idx = part_number.length();
for(; end_of_string_idx >= 0; end_of_string_idx--)
for(; end_of_string_idx > 0; end_of_string_idx--)
{
if((part_number[end_of_string_idx] != '\0')
&& (part_number[end_of_string_idx] != ' '))
if((part_number[end_of_string_idx - 1] != '\0')
&& (part_number[end_of_string_idx - 1] != ' '))
{
break;
}

Loading…
Cancel
Save