[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>

Comments

Gert Doering Oct. 9, 2025, 2:50 p.m. UTC | #1
Trivial and definitely save :-) not tested beyond "BB all green".

Your patch has been applied to the master branch.

commit 5ec23295f03bec3e241f65363bcd0f5b0b2afde6
Author: Frank Lichtenheld
Date:   Wed Oct 8 19:01:57 2025 +0200

     options_util: Fix conversion warning in atoi_constrained

     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
     Message-Id: <20251008170202.10333-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/search?l=mid&q=20251008170202.10333-1-gert@greenie.muc.de
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering
Gert Doering Oct. 9, 2025, 2:52 p.m. UTC | #2
Hi,

On Thu, Oct 09, 2025 at 04:50:22PM +0200, Gert Doering wrote:
> Trivial and definitely save :-) not tested beyond "BB all green".
> 
> Your patch has been applied to the master branch.
> 
> commit 5ec23295f03bec3e241f65363bcd0f5b0b2afde6
> Author: Frank Lichtenheld
> Date:   Wed Oct 8 19:01:57 2025 +0200

Or not...  wrong mail archive URL, corrected, did not adjust the mail.

This is what I will push now:

commit 8fd8c4fa5d6c113925ebf42d47d9e8d3f292309f (HEAD -> master)
Author: Frank Lichtenheld <frank@lichtenheld.com>
Date:   Wed Oct 8 19:01:57 2025 +0200

    options_util: Fix conversion warning in atoi_constrained
    
    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
    Message-Id: <20251008170202.10333-1-gert@greenie.muc.de>
    URL: https://sourceforge.net/p/openvpn/mailman/message/59244107/
    Signed-off-by: Gert Doering <gert@greenie.muc.de>

(same commit, different URL: in the message -> different ID)

sorry,

gert

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",