From 9ad37cc98fb7bd10988380fe49603158162b3c15 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 3 Mar 2026 11:25:22 -0600 Subject: [PATCH] Fix logical error from changing type to unsigned --- SPDAccessor/SPDAccessor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SPDAccessor/SPDAccessor.cpp b/SPDAccessor/SPDAccessor.cpp index 4cd8d62a..1c5b302d 100644 --- a/SPDAccessor/SPDAccessor.cpp +++ b/SPDAccessor/SPDAccessor.cpp @@ -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; }