[Openvpn-devel,v1] options_util: Fix conversion warning in atoi_constrained

Message ID 20251008170202.10333-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] options_util: Fix conversion warning in atoi_constrained | expand

Commit Message

Gert Doering Oct. 8, 2025, 5:01 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

The whole purpose of the function is to make sure
that cast is safe.

Change-Id: Id08524661aa5bcc5cd42f27a1aacc636e2b2b004
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1261
---

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

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

Patch

diff --git a/src/openvpn/options_util.c b/src/openvpn/options_util.c
index 8a1c083..eba7d39 100644
--- a/src/openvpn/options_util.c
+++ b/src/openvpn/options_util.c
@@ -162,11 +162,6 @@ 
     return (int)i;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 bool
 atoi_constrained(const char *str, int *value, const char *name, int min, int max, msglvl_t msglevel)
 {
@@ -194,14 +189,10 @@ 
         return false;
     }
 
-    *value = i;
+    *value = (int)i;
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static const char *updatable_options[] = { "block-ipv6", "block-outside-dns",
                                            "dhcp-option", "dns",
                                            "ifconfig", "ifconfig-ipv6",