From f855c5b5bbbc6d5436741fd8108be64825a3c76b Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Mon, 15 Sep 2025 14:06:55 +0200 Subject: general refactorin in lib, more local variables, real booleans --- lib/utils_tcp.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/utils_tcp.c') diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c index 1482458b..a82d5a3f 100644 --- a/lib/utils_tcp.c +++ b/lib/utils_tcp.c @@ -26,8 +26,10 @@ * *****************************************************************************/ -#include "common.h" +#include "../config.h" #include "utils_tcp.h" +#include +#include #define VERBOSE(message) \ do { \ @@ -37,9 +39,9 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count, int flags) { - int i, match = 0, partial = 0; - - for (i = 0; i < expect_count; i++) { + int match = 0; + int partial = 0; + for (int i = 0; i < expect_count; i++) { if (flags & NP_MATCH_VERBOSE) { printf("looking for [%s] %s [%s]\n", server_expect[i], (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); @@ -50,7 +52,9 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp VERBOSE("found it"); match++; continue; - } else if (strncmp(status, server_expect[i], strlen(status)) == 0) { + } + + if (strncmp(status, server_expect[i], strlen(status)) == 0) { VERBOSE("found a substring"); partial++; continue; @@ -66,9 +70,9 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp if ((flags & NP_MATCH_ALL && match == expect_count) || (!(flags & NP_MATCH_ALL) && match >= 1)) { return NP_MATCH_SUCCESS; - } else if (partial > 0 || !(flags & NP_MATCH_EXACT)) { + } + if (partial > 0 || !(flags & NP_MATCH_EXACT)) { return NP_MATCH_RETRY; - } else { - return NP_MATCH_FAILURE; } + return NP_MATCH_FAILURE; } -- cgit v1.2.3-74-g34f1