[Openvpn-devel,5/5] Windows: fix signedness errors with recv/send

Message ID 20230203191440.136050-6-frank@lichtenheld.com
State Accepted
Headers show
Series Allow mingw builds with -Werror | expand

Commit Message

Frank Lichtenheld Feb. 3, 2023, 7:14 p.m. UTC
On Linux those functions actually take void pointer,
so no behavior change there. On Windows, we avoid
warnings about unsigned char vs char.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
---
 src/openvpn/manage.c | 4 ++--
 src/openvpn/proxy.c  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Gert Doering Feb. 25, 2023, 4:51 p.m. UTC | #1
Acked-by: Gert Doering <gert@greenie.muc.de>

I'm not a big fan of adding (cast) to silence compiler warnings,
but this signed/unsigned char * nonsense is really hard to avoid -
casting to (void *) is the right fix here.

I have only test compiled on MinGW - and my MinGW did not warn
about these anyway (maybe not enough -Wthing switches).  But it 
did not break anything, and does not introduce new warnings.

Your patch has been applied to the master and release/2.6 branch.

commit 7acd93a6bef2dd9b660571c29b5f41c8ca351161 (master)
commit e9ae7cee2ca9b9ab78de01f1d3c562610e5624d2 (release/2.6)
Author: Frank Lichtenheld
Date:   Fri Feb 3 20:14:40 2023 +0100

     Windows: fix signedness errors with recv/send

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Message-Id: <20230203191440.136050-6-frank@lichtenheld.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26144.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 8397d3cf..3ea1992b 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -2251,7 +2251,7 @@  man_read(struct management *man)
         man->connection.lastfdreceived = fd;
     }
 #else  /* ifdef TARGET_ANDROID */
-    len = recv(man->connection.sd_cli, buf, sizeof(buf), MSG_NOSIGNAL);
+    len = recv(man->connection.sd_cli, (void *)buf, sizeof(buf), MSG_NOSIGNAL);
 #endif
 
     if (len == 0)
@@ -2348,7 +2348,7 @@  man_write(struct management *man)
         }
         else
 #endif
-        sent = send(man->connection.sd_cli, BPTR(buf), len, MSG_NOSIGNAL);
+        sent = send(man->connection.sd_cli, (const void *)BPTR(buf), len, MSG_NOSIGNAL);
         if (sent >= 0)
         {
             buffer_list_advance(man->connection.out, sent);
diff --git a/src/openvpn/proxy.c b/src/openvpn/proxy.c
index aa10363c..ed47eaa2 100644
--- a/src/openvpn/proxy.c
+++ b/src/openvpn/proxy.c
@@ -126,7 +126,7 @@  recv_line(socket_descriptor_t sd,
         }
 
         /* read single char */
-        size = recv(sd, &c, 1, MSG_NOSIGNAL);
+        size = recv(sd, (void *)&c, 1, MSG_NOSIGNAL);
 
         /* error? */
         if (size != 1)