Skip to contentSkip to conversation

Change in openvpn[master]: Fix some trivial sign-compare compiler warnings

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Jan 14, 2025 – Jan 15, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1736860439000.I1918c43202b87f0c987bfd9155c739da7dd02632@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/865?usp=email

to review the following change.

Change subject: Fix some trivial sign-compare compiler warnings
......................................................................

Fix some trivial sign-compare compiler warnings

Change-Id I1918c43202b87f0c987bfd9155c739da7dd02632

---
M src/openvpn/options.c
M src/openvpn/socket.c
M src/openvpn/tun.c

3 files changed, 6 insertions(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/865/1

src/openvpn/options.c +1 -1
index 1113663..b594b09 100644
@@ -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)
             {
src/openvpn/socket.c +4 -8
index 234d590..4aeb613 100644
@@ -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)
         {
src/openvpn/tun.c +1 -1
index 3f2ec4a..22706f3 100644
@@ -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)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/865?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632
Gerrit-Change-Number: 865
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/865?usp=email )

Change subject: Fix some trivial sign-compare compiler warnings
......................................................................

Patch Set 2: Code-Review+2

(1 comment)

Patchset:

PS2:
looks good, +2 unless one of the "non smoketest" builders fails later on

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/865?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632
Gerrit-Change-Number: 865
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 14 Jan 2025 16:51:44 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH v2 1/1 Fix some trivial sign-compare compiler warnings

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

Change-Id I1918c43202b87f0c987bfd9155c739da7dd02632

---

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 <[email protected]...>

src/openvpn/options.c +1 -1
index 1113663..b594b09 100644
@@ -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)
             {
src/openvpn/socket.c +4 -8
index 234d590..4aeb613 100644
@@ -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)
         {
src/openvpn/tun.c +1 -1
index 3f2ec4a..22706f3 100644
@@ -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)
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix some trivial sign-compare compiler warnings

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg30455.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#4) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/865?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Fix some trivial sign-compare compiler warnings
......................................................................

Fix some trivial sign-compare compiler warnings

Change-Id I1918c43202b87f0c987bfd9155c739da7dd02632

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30455.html

---
M src/openvpn/options.c
M src/openvpn/socket.c
M src/openvpn/tun.c

3 files changed, 6 insertions(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/865/4

src/openvpn/options.c +1 -1
index eb0d9b5..3ef4d78 100644
@@ -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)
             {
src/openvpn/socket.c +4 -8
index f9f2a3b..7765372 100644
@@ -3132,8 +3132,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))
         {
@@ -3146,8 +3145,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))
         {
@@ -3160,8 +3158,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)
         {
@@ -3183,9 +3180,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)
         {
src/openvpn/tun.c +1 -1
index 7fbd6c3..33830fc 100644
@@ -669,7 +669,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)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/865?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632
Gerrit-Change-Number: 865
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/865?usp=email )

Change subject: Fix some trivial sign-compare compiler warnings
......................................................................

Fix some trivial sign-compare compiler warnings

Change-Id I1918c43202b87f0c987bfd9155c739da7dd02632

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30455.html

---
M src/openvpn/options.c
M src/openvpn/socket.c
M src/openvpn/tun.c

3 files changed, 6 insertions(+), 10 deletions(-)
src/openvpn/options.c +1 -1
index eb0d9b5..3ef4d78 100644
@@ -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)
             {
src/openvpn/socket.c +4 -8
index f9f2a3b..7765372 100644
@@ -3132,8 +3132,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))
         {
@@ -3146,8 +3145,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))
         {
@@ -3160,8 +3158,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)
         {
@@ -3183,9 +3180,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)
         {
src/openvpn/tun.c +1 -1
index 7fbd6c3..33830fc 100644
@@ -669,7 +669,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)

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/865?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I1918c43202b87f0c987bfd9155c739da7dd02632
Gerrit-Change-Number: 865
Gerrit-PatchSet: 4
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged