From ec20c707ea677c9b2c8e585b78c9837a2f6e7372 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 30 May 2022 13:11:38 +0200 Subject: refactor(minion): make reading wifi module more reliable --- minion/src/util.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'minion/src/util.cpp') diff --git a/minion/src/util.cpp b/minion/src/util.cpp index 15cf840..708e47d 100644 --- a/minion/src/util.cpp +++ b/minion/src/util.cpp @@ -3,22 +3,22 @@ namespace util { -auto str_ends_with(const char *str, const char *other_str) noexcept -> bool +auto str_ends_with(const char *target, size_t target_end, const char *other) noexcept + -> bool { - if (str == nullptr || other_str == nullptr) + if (target == nullptr || other == nullptr) { return false; } - auto str_length = strlen(str); - auto other_str_length = strlen(other_str); + const auto other_str_length = strlen(other); - if (other_str_length > str_length) + if (other_str_length > target_end) { return false; } - return strncmp(str + str_length - other_str_length, other_str, other_str_length) == 0; + return strncmp(target + target_end - other_str_length, other, other_str_length) == 0; } void substr(const char *str, const char *end, char *dest) noexcept -- cgit v1.2.3-18-g5258