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
