Skip to contentSkip to conversation

Change in openvpn[master]: ps: Clean up conversion warnings in journal_add function

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Sep 2, 2025 – Sep 14, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1756814708000.I0f2fff8358d4645c4ace504c65ae8559a68794cc@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email

to review the following change.

Change subject: ps: Clean up conversion warnings in journal_add function
......................................................................

ps: Clean up conversion warnings in journal_add function

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

Change-Id I0f2fff8358d4645c4ace504c65ae8559a68794cc

---
M src/openvpn/ps.c

1 file changed, 7 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1163/1

src/openvpn/ps.c +7 -11
index eae03e3..e95a33b 100644
@@ -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);
 }
 
 /*

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0f2fff8358d4645c4ace504c65ae8559a68794cc
Gerrit-Change-Number: 1163
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email )

Change subject: ps: Clean up conversion warnings in journal_add function
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0f2fff8358d4645c4ace504c65ae8559a68794cc
Gerrit-Change-Number: 1163
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sun, 14 Sep 2025 13:46:40 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw

PATCH 1/1 ps: Clean up conversion warnings in journal_add function

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

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

Change-Id I0f2fff8358d4645c4ace504c65ae8559a68794cc

---

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 <[email protected]...>

src/openvpn/ps.c +7 -11
index eae03e3..e95a33b 100644
@@ -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);
 }
 
 /*
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: ps: Clean up conversion warnings in journal_add function

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 <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg32916.html
     URL: https://gerrit.openvpn.net/c/openvpn/+/1163
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: ps: Clean up conversion warnings in journal_add function
......................................................................

ps: Clean up conversion warnings in journal_add function

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

Change-Id I0f2fff8358d4645c4ace504c65ae8559a68794cc

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32916.html
URL: https://gerrit.openvpn.net/c/openvpn/+/1163

---
M src/openvpn/ps.c

1 file changed, 7 insertions(+), 11 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/63/1163/2

src/openvpn/ps.c +7 -11
index eae03e3..e95a33b 100644
@@ -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);
 }
 
 /*

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0f2fff8358d4645c4ace504c65ae8559a68794cc
Gerrit-Change-Number: 1163
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email )

Change subject: ps: Clean up conversion warnings in journal_add function
......................................................................

ps: Clean up conversion warnings in journal_add function

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

Change-Id I0f2fff8358d4645c4ace504c65ae8559a68794cc

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg32916.html
URL: https://gerrit.openvpn.net/c/openvpn/+/1163

---
M src/openvpn/ps.c

1 file changed, 7 insertions(+), 11 deletions(-)
src/openvpn/ps.c +7 -11
index eae03e3..e95a33b 100644
@@ -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);
 }
 
 /*

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1163?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I0f2fff8358d4645c4ace504c65ae8559a68794cc
Gerrit-Change-Number: 1163
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged