From: Frank Lichtenheld Date: Tue, 14 Jan 2025 16:52:06 +0000 (+0100) Subject: Fix some trivial sign-compare compiler warnings X-Git-Tag: v2.7_alpha1~118 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d91eda5a120a4a18273d82fed6777b3efcce8cc;p=thirdparty%2Fopenvpn.git Fix some trivial sign-compare compiler warnings Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Message-Id: <20250114165206.13187-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30455.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/options.c b/src/openvpn/options.c index eb0d9b5b7..3ef4d78d4 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -1448,7 +1448,7 @@ foreign_options_copy_dns(struct options *o, struct env_set *es) while (server) { - for (int i = 0; i < server->addr_count; ++i) + for (size_t i = 0; i < server->addr_count; ++i) { if (server->addr[i].family == AF_INET) { diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c index f9f2a3b9c..7765372f4 100644 --- a/src/openvpn/socket.c +++ b/src/openvpn/socket.c @@ -3132,8 +3132,7 @@ static const struct proto_names proto_names[] = { int ascii2proto(const char *proto_name) { - int i; - for (i = 0; i < SIZE(proto_names); ++i) + for (size_t i = 0; i < SIZE(proto_names); ++i) { if (!strcmp(proto_name, proto_names[i].short_form)) { @@ -3146,8 +3145,7 @@ ascii2proto(const char *proto_name) sa_family_t ascii2af(const char *proto_name) { - int i; - for (i = 0; i < SIZE(proto_names); ++i) + for (size_t i = 0; i < SIZE(proto_names); ++i) { if (!strcmp(proto_name, proto_names[i].short_form)) { @@ -3160,8 +3158,7 @@ ascii2af(const char *proto_name) const char * proto2ascii(int proto, sa_family_t af, bool display_form) { - unsigned int i; - for (i = 0; i < SIZE(proto_names); ++i) + for (size_t i = 0; i < SIZE(proto_names); ++i) { if (proto_names[i].proto_af == af && proto_names[i].proto == proto) { @@ -3183,9 +3180,8 @@ const char * proto2ascii_all(struct gc_arena *gc) { struct buffer out = alloc_buf_gc(256, gc); - int i; - for (i = 0; i < SIZE(proto_names); ++i) + for (size_t i = 0; i < SIZE(proto_names); ++i) { if (i) { diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 7fbd6c384..33830fc56 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -669,7 +669,7 @@ warn_on_use_of_common_subnets(openvpn_net_ctx_t *ctx) { struct gc_arena gc = gc_new(); struct route_gateway_info rgi; - const int needed = (RGI_ADDR_DEFINED|RGI_NETMASK_DEFINED); + const unsigned int needed = (RGI_ADDR_DEFINED|RGI_NETMASK_DEFINED); get_default_gateway(&rgi, ctx); if ((rgi.flags & needed) == needed)