[Openvpn-devel,v1] ps: Clean up conversion warnings in journal_add function

Message ID 20250914134713.19315-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel,v1] ps: Clean up conversion warnings in journal_add function | expand

Commit Message

Gert Doering Sept. 14, 2025, 1:47 p.m. UTC
From: Frank Lichtenheld <frank@lichtenheld.com>

Since these are only local variables, these are trivial
changes.

Change-Id: I0f2fff8358d4645c4ace504c65ae8559a68794cc
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
---

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

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

Comments

Gert Doering Sept. 14, 2025, 5:26 p.m. UTC | #1
Trivial changes indeed, and I can confirm that the port-share stuff still
does its job :-)

Your patch has been applied to the master branch.

commit 3ae25e916fab9693a3edf16362e97248dc165965
Author: Frank Lichtenheld
Date:   Sun Sep 14 15:47:08 2025 +0200

     ps: Clean up conversion warnings in journal_add function

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


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/ps.c b/src/openvpn/ps.c
index eae03e3..e95a33b 100644
--- a/src/openvpn/ps.c
+++ b/src/openvpn/ps.c
@@ -334,26 +334,22 @@ 
 static void
 journal_add(const char *journal_dir, struct proxy_connection *pc, struct proxy_connection *cp)
 {
-    struct gc_arena gc = gc_new();
     struct openvpn_sockaddr from, to;
-    socklen_t slen, dlen;
-    int fnlen;
-    char *jfn;
-    int fd;
 
-    slen = sizeof(from.addr);
-    dlen = sizeof(to.addr);
+    socklen_t slen = sizeof(from.addr);
+    socklen_t dlen = sizeof(to.addr);
     if (!getpeername(pc->sd, (struct sockaddr *)&from.addr.sa, &slen)
         && !getsockname(cp->sd, (struct sockaddr *)&to.addr.sa, &dlen))
     {
+        struct gc_arena gc = gc_new();
         const char *f = print_openvpn_sockaddr(&from, &gc);
         const char *t = print_openvpn_sockaddr(&to, &gc);
-        fnlen = strlen(journal_dir) + strlen(t) + 2;
-        jfn = (char *)malloc(fnlen);
+        size_t fnlen = strlen(journal_dir) + strlen(t) + 2;
+        char *jfn = (char *)malloc(fnlen);
         check_malloc_return(jfn);
         snprintf(jfn, fnlen, "%s/%s", journal_dir, t);
         dmsg(D_PS_PROXY_DEBUG, "PORT SHARE PROXY: client origin %s -> %s", jfn, f);
-        fd = platform_open(jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
+        int fd = platform_open(jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
         if (fd != -1)
         {
             if (write(fd, f, strlen(f)) != strlen(f))
@@ -368,8 +364,8 @@ 
             msg(M_WARN | M_ERRNO, "PORT SHARE: unable to write journal file in %s", jfn);
             free(jfn);
         }
+        gc_free(&gc);
     }
-    gc_free(&gc);
 }
 
 /*