From 191099cab967c3ff0e8fc1d4a74cc697f4b6d338 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Sun, 15 Sep 2024 07:57:31 +0200 Subject: [PATCH] Fix some compiler warnings Fix compiler warnings about comparing signed with unsigned integers. --- src/hdlc.c | 4 ++-- src/ipv4.c | 2 +- src/tunnel.c | 4 ++-- src/userinput.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hdlc.c b/src/hdlc.c index f347d42d..65385a09 100644 --- a/src/hdlc.c +++ b/src/hdlc.c @@ -199,7 +199,7 @@ ssize_t hdlc_find_frame(const uint8_t *buffer, size_t bufsize, off_t *start) int s = -1, e = -1; // Look for frame start - for (int i = *start; i < bufsize; i++) { + for (size_t i = *start; i < bufsize; i++) { if (buffer[i] == 0x7e) { // Flag Sequence s = i + 1; break; @@ -213,7 +213,7 @@ ssize_t hdlc_find_frame(const uint8_t *buffer, size_t bufsize, off_t *start) s++; // Look for frame end - for (int i = s; i < bufsize; i++) { + for (size_t i = s; i < bufsize; i++) { if (buffer[i] == 0x7e) { // Flag Sequence e = i; break; diff --git a/src/ipv4.c b/src/ipv4.c index a86bcf24..f6e92e55 100644 --- a/src/ipv4.c +++ b/src/ipv4.c @@ -1052,7 +1052,7 @@ int ipv4_restore_routes(struct tunnel *tunnel) static inline char *replace_char(char *str, char find, char replace) { - for (int i = 0; i < strlen(str); i++) + for (size_t i = 0; i < strlen(str); i++) if (str[i] == find) str[i] = replace; return str; diff --git a/src/tunnel.c b/src/tunnel.c index f086dae9..bcdc6e39 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -773,7 +773,7 @@ static int tcp_connect(struct tunnel *tunnel) const char *response = NULL; memset(&(request), 0, sizeof(request)); - for (int j = 0; response == NULL; j++) { + for (unsigned int j = 0; response == NULL; j++) { if (j >= ARRAY_SIZE(request) - 1) { log_error("Proxy response is unexpectedly large and cannot fit in the %lu-bytes buffer.\n", ARRAY_SIZE(request)); @@ -819,7 +819,7 @@ static int tcp_connect(struct tunnel *tunnel) }; const char *eol = NULL; - for (int i = 0; (i < ARRAY_SIZE(HTTP_EOL)) && + for (unsigned int i = 0; (i < ARRAY_SIZE(HTTP_EOL)) && (eol == NULL); i++) eol = strstr(response, HTTP_EOL[i]); response = eol; diff --git a/src/userinput.c b/src/userinput.c index 53a50255..75ed10c9 100644 --- a/src/userinput.c +++ b/src/userinput.c @@ -332,7 +332,7 @@ void read_password(const char *pinentry, const char *hint, { int masked = 0; struct termios oldt, newt; - int i; + size_t i; if (pinentry && *pinentry) { pinentry_read_password(pinentry, hint, prompt, pass, len);