Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

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

    https://gerrit.openvpn.net/c/openvpn/+/2340?usp=email

to review the following change.


Change subject: argv: Fix conversion warnings in argv_printf_arglist
......................................................................

argv: Fix conversion warnings in argv_printf_arglist

Due to the int return of vsnprintf this is always
going to be somewhat ugly.

Change-Id: Id5152a5aacdd50f2fa9c5b3dfab92be8887541db
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M src/openvpn/argv.c
1 file changed, 5 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/40/2340/1

diff --git a/src/openvpn/argv.c b/src/openvpn/argv.c
index c716e5b0..cf841a5 100644
--- a/src/openvpn/argv.c
+++ b/src/openvpn/argv.c
@@ -323,11 +323,6 @@
     return f;
 }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-
 /**
  *  Create a struct argv based on a format string
  *
@@ -378,9 +373,9 @@
      */
     va_list tmplist;
     va_copy(tmplist, arglist);
-    int len = vsnprintf(NULL, 0, f, tmplist);
+    int test_len = vsnprintf(NULL, 0, f, tmplist);
     va_end(tmplist);
-    if (len < 0)
+    if (test_len < 0)
     {
         goto out;
     }
@@ -389,10 +384,10 @@
      *  Do the actual vsnprintf() operation, which expands the format
      *  string with the provided arguments.
      */
-    int size = len + 1;
+    size_t size = (size_t)test_len + 1;
     char *buf = gc_malloc(size, false, &argres->gc);
-    len = vsnprintf(buf, size, f, arglist);
-    if (len < 0 || len >= size)
+    int len = vsnprintf(buf, size, f, arglist);
+    if (len < 0 || len > test_len)
     {
         goto out;
     }
@@ -423,10 +418,6 @@
     return res;
 }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 /**
  *  printf() variant which populates a struct argv.  It processes the
  *  format string with the provided arguments.  For each space separator found

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id5152a5aacdd50f2fa9c5b3dfab92be8887541db
Gerrit-Change-Number: 2340
Gerrit-PatchSet: 1
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
  • [Openvpn-devel] [S] Chan... Frank Lichtenheld (Code Review) via Openvpn-devel

Reply via email to