[Openvpn-devel,v2] Fix some trivial sign-compare compiler warnings

Message ID 20250114165206.13187-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v2] Fix some trivial sign-compare compiler warnings | expand

Commit Message

Gert Doering Jan. 14, 2025, 4:52 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/865
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>

Comments

Gert Doering Jan. 15, 2025, 2:32 p.m. UTC | #1
Stared at the changes (make sense), BB confirms that no platform takes
offense either, so in it goes.

Your patch has been applied to the master branch.

commit 6d91eda5a120a4a18273d82fed6777b3efcce8cc
Author: Frank Lichtenheld
Date:   Tue Jan 14 17:52:06 2025 +0100

     Fix some trivial sign-compare compiler warnings

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     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 <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 1113663..b594b09 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -1448,7 +1448,7 @@ 
 
     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 234d590..4aeb613 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -3131,8 +3131,7 @@ 
 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))
         {
@@ -3145,8 +3144,7 @@ 
 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))
         {
@@ -3159,8 +3157,7 @@ 
 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)
         {
@@ -3182,9 +3179,8 @@ 
 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 3f2ec4a..22706f3 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -631,7 +631,7 @@ 
 {
     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)