[Openvpn-devel,v1] platform.c: Do not depend Windows build on HAVE_CHDIR

Message ID 20231111081808.30967-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v1] platform.c: Do not depend Windows build on HAVE_CHDIR | expand

Commit Message

Gert Doering Nov. 11, 2023, 8:18 a.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

This broke in the CMake build since previously we
just always set HAVE_CHDIR to 1 in the MSVC build.
But actually the code should just not check HAVE_CHDIR
on Windows.

Change-Id: I0c78ce452135fe2c80275da449215ba926471018
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
---

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/+/425
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Lev Stipakov <lstipakov@gmail.com>

Comments

Gert Doering Nov. 11, 2023, 8:45 a.m. UTC | #1
This patch will do the job, but I think (at least for "master") we should
do a bit more thorough job - as in, get rid of HAVE_CHDIR completely, in
autoconf, cmake, header files.  There is no platform where we have a remote
chance in getting OpenVPN ported that has no chdir(), so this is all
a nice excercise in achieving nothing.

I have not tested this beyond "does it compile?" but the change looks
reasonable and Lev has ACKed it.

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

commit 012ea92c414282488e3d60c87452849bde64aac4 (master)
commit b705517b12d14876a12593416a45756b7a952f1e (release/2.6)
Author: Frank Lichtenheld
Date:   Sat Nov 11 09:18:08 2023 +0100

     platform.c: Do not depend Windows build on HAVE_CHDIR

     Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
     Acked-by: Lev Stipakov <lstipakov@gmail.com>
     Message-Id: <20231111081808.30967-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27362.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/platform.c b/src/openvpn/platform.c
index 32c4fe6..62acabe 100644
--- a/src/openvpn/platform.c
+++ b/src/openvpn/platform.c
@@ -392,7 +392,6 @@ 
 int
 platform_chdir(const char *dir)
 {
-#ifdef HAVE_CHDIR
 #ifdef _WIN32
     int res;
     struct gc_arena gc = gc_new();
@@ -400,11 +399,12 @@ 
     gc_free(&gc);
     return res;
 #else  /* ifdef _WIN32 */
+#ifdef HAVE_CHDIR
     return chdir(dir);
-#endif
 #else  /* ifdef HAVE_CHDIR */
     return -1;
 #endif
+#endif
 }
 
 /*