[Openvpn-devel,v1] socket: Initialize struct in_addr_t in getaddr()

Message ID 20251208170320.4696-1-gert@greenie.muc.de
State New
Headers show
Series [Openvpn-devel,v1] socket: Initialize struct in_addr_t in getaddr() | expand

Commit Message

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

We have false-positive "‘addr’ may be used uninitialized"
warnings with MinGW 13.0.0 compiler. Work around them.

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

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

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

Comments

Gert Doering Dec. 8, 2025, 7:28 p.m. UTC | #1
This is somewhat of a silly-compiler-syndrome - especially since the 
last warning in this area was a true positive, now the addition of
the "if(ai)" clause - which has nothing whatsoever to do with the
return data or not - causes a warning (that we treat fatal) in mingw,
and only in the release builds...

But anyway, this is just a 32bit integer, not in the fast path, and
initializing things is generally a good idea :-)

Tested with the (upcoming) GHA mingw+release builds that reproduceably
fail without this change.

Your patch has been applied to the master branch.

commit e8dc7f35584df1f1cf920636cd5ac7232f0009a9
Author: Frank Lichtenheld
Date:   Mon Dec 8 18:03:13 2025 +0100

     socket: Initialize struct in_addr_t in getaddr()

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Gert Doering <gert@greenie.muc.de>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1420
     Message-Id: <20251208170320.4696-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34894.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 80c2895..3e90833 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -202,7 +202,7 @@ 
 getaddr(unsigned int flags, const char *hostname, int resolve_retry_seconds, bool *succeeded,
         struct signal_info *sig_info)
 {
-    in_addr_t addr;
+    in_addr_t addr = { 0 };
     int status;
 
     status = get_addr_generic(AF_INET, flags, hostname, &addr, NULL, resolve_retry_seconds,