[Openvpn-devel,v1] Fix warnings about conversion from int to unsigned char/uint8_t

Message ID 20251030193834.1186-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] Fix warnings about conversion from int to unsigned char/uint8_t | expand

Commit Message

Gert Doering Oct. 30, 2025, 7:38 p.m. UTC
From: Arne Schwabe <arne@rfc2549.org>

When compiling with cmake -DCMAKE_BUILD_TYPE=ASAN under Ubuntu 25.10
(gcc 15.2.0).

Explicitly cast these instances to uint8_t/unssigned char to silence this
warning.

Change-Id: I648ee99b1152b1248d1b3e64af7679ab99f1388f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
---

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/+/1328
This mail reflects revision 1 of this Change.

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

Comments

Gert Doering Oct. 30, 2025, 9:01 p.m. UTC | #1
Looks reasonable.  I do not have an ubuntu 25 system yet to test, but
on the older boxes this does not warn either way, and the casts are
safe.  BB is happy.

Your patch has been applied to the master branch.

commit e7df832354fd476defe6a0fb35ab1aa05314c5e3
Author: Arne Schwabe
Date:   Thu Oct 30 20:38:20 2025 +0100

     Fix warnings about conversion from int to unsigned char/uint8_t

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1328
     Message-Id: <20251030193834.1186-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34065.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/httpdigest.c b/src/openvpn/httpdigest.c
index be20638..3e6520a 100644
--- a/src/openvpn/httpdigest.c
+++ b/src/openvpn/httpdigest.c
@@ -46,7 +46,7 @@ 
         }
         else
         {
-            Hex[i * 2] = (j + 'a' - 10);
+            Hex[i * 2] = (unsigned char)(j + 'a' - 10);
         }
         j = Bin[i] & 0xf;
         if (j <= 9)
@@ -55,7 +55,7 @@ 
         }
         else
         {
-            Hex[i * 2 + 1] = (j + 'a' - 10);
+            Hex[i * 2 + 1] = (unsigned char)(j + 'a' - 10);
         }
     }
     Hex[HASHHEXLEN] = '\0';
diff --git a/src/openvpn/mroute.c b/src/openvpn/mroute.c
index b50d48f..d17902f 100644
--- a/src/openvpn/mroute.c
+++ b/src/openvpn/mroute.c
@@ -337,7 +337,7 @@ 
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (uint8_t)(0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }