Skip to content

Commit 9ad37cc

Browse files
Fix logical error from changing type to unsigned
1 parent c76864d commit 9ad37cc

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

SPDAccessor/SPDAccessor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ std::string SPDAccessor::read_part_nr_at(uint16_t address, std::size_t len)
131131
| Note: To prevent infinite loop, end_of_string_idx |
132132
| MUST be signed. |
133133
\*-----------------------------------------------------*/
134-
std::size_t end_of_string_idx = part_number.length() - 1;
134+
std::size_t end_of_string_idx = part_number.length();
135135

136-
for(; end_of_string_idx >= 0; end_of_string_idx--)
136+
for(; end_of_string_idx > 0; end_of_string_idx--)
137137
{
138-
if((part_number[end_of_string_idx] != '\0')
139-
&& (part_number[end_of_string_idx] != ' '))
138+
if((part_number[end_of_string_idx - 1] != '\0')
139+
&& (part_number[end_of_string_idx - 1] != ' '))
140140
{
141141
break;
142142
}

0 commit comments

Comments
 (0)