From: "flichtenheld (Code Review)"
Date: Wed, 6 May 2026 21:20:59 +0000
In-Reply-To:
References:
Reply-To: frank@...2641..., arne-openvpn@...1227...,
openvpn-devel@lists.sourceforge.net
Message-ID:
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Content-Type: multipart/alternative; boundary="jEQ1hmBv+3w="; charset=UTF-8
Subject: [Openvpn-devel] [M] Change in openvpn[master]: Remove various
useless assignments
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
To: plaisthos
Cc: openvpn-devel
--jEQ1hmBv+3w=
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1617?usp=3Demail
to look at the new patch set (#5).
Change subject: Remove various useless assignments
......................................................................
Remove various useless assignments
The values assigned by these are never actually used
for something.
Identified by cppcheck.
Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Signed-off-by: Frank Lichtenheld
---
M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvpn/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c
M src/openvpn/push_util.c
M src/openvpn/ssl_openssl.c
M src/openvpn/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M tests/unit_tests/openvpn/test_ssl.c
M tests/unit_tests/openvpnserv/test_openvpnserv.c
15 files changed, 41 insertions(+), 58 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/17/1617/5
diff --git a/src/openvpn/console_builtin.c b/src/openvpn/console_builtin.c
index 2a9f3b6..9c8d72a 100644
--- a/src/openvpn/console_builtin.c
+++ b/src/openvpn/console_builtin.c
@@ -192,7 +192,6 @@
static bool
get_console_input(const char *prompt, const bool echo, char *input, const =
int capacity)
{
- bool ret =3D false;
ASSERT(prompt);
ASSERT(input);
ASSERT(capacity > 0);
@@ -200,8 +199,11 @@
#if defined(_WIN32)
return get_console_input_win32(prompt, echo, input, capacity);
-#elif defined(HAVE_TERMIOS_H)
+#elif !defined(HAVE_TERMIOS_H)
+ msg(M_FATAL, "Sorry, but I can't get console input on this OS (%s)", p=
rompt);
+#else
bool restore_tty =3D false;
+ bool ret =3D false;
struct termios tty_tmp, tty_save;
/* did we --daemon'ize before asking for passwords?
@@ -258,10 +260,8 @@
}
close_tty(fp);
-#else /* if defined(_WIN32) */
- msg(M_FATAL, "Sorry, but I can't get console input on this OS (%s)", p=
rompt);
-#endif /* if defined(_WIN32) */
return ret;
+#endif /* if defined(_WIN32) */
}
/**
diff --git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index 7954e8a..df9b905 100644
--- a/src/openvpn/crypto.c
+++ b/src/openvpn/crypto.c
@@ -1204,8 +1204,6 @@
struct buffer work =3D alloc_buf_gc(BUF_SIZE(frame), &gc);
struct buffer encrypt_workspace =3D alloc_buf_gc(BUF_SIZE(frame), &gc);
struct buffer decrypt_workspace =3D alloc_buf_gc(BUF_SIZE(frame), &gc);
- struct buffer buf =3D clear_buf();
- void *buf_p;
/* init work */
ASSERT(buf_init(&work, frame->buf.headroom));
@@ -1242,8 +1240,8 @@
ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
/* copy source to input buf */
- buf =3D work;
- buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
+ struct buffer buf =3D work;
+ void *buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
ASSERT(buf_p);
memcpy(buf_p, BPTR(&src), BLENZ(&src));
diff --git a/src/openvpn/error.h b/src/openvpn/error.h
index 45826a2..a887fc7 100644
--- a/src/openvpn/error.h
+++ b/src/openvpn/error.h
@@ -408,8 +408,8 @@
openvpn_errno_maybe_crt(bool *crt_error)
{
int err =3D 0;
- *crt_error =3D false;
#ifdef _WIN32
+ *crt_error =3D false;
err =3D GetLastError();
if (err =3D=3D ERROR_SUCCESS)
{
diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c
index 27cfd36..53eab4d 100644
--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -1746,7 +1746,6 @@
process_outgoing_link(struct context *c, struct link_socket *sock)
{
struct gc_arena gc =3D gc_new();
- int error_code =3D 0;
if (c->c2.to_link.len > 0 && c->c2.to_link.len <=3D c->c2.frame.buf.pa=
yload_size)
{
@@ -1821,7 +1820,7 @@
}
/* Check return status */
- error_code =3D openvpn_errno();
+ int error_code =3D openvpn_errno();
check_status(size, "write", sock, NULL);
if (size > 0)
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 2a3023c..f1dccc1 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -916,10 +916,9 @@
static void
man_remote_entry_count(struct management *man)
{
- unsigned count =3D 0;
if (man->persist.callback.remote_entry_count)
{
- count =3D (*man->persist.callback.remote_entry_count)(man->persist=
.callback.arg);
+ unsigned int count =3D (*man->persist.callback.remote_entry_count)=
(man->persist.callback.arg);
msg(M_CLIENT, "%u", count);
msg(M_CLIENT, "END");
}
@@ -3745,7 +3744,6 @@
struct gc_arena gc =3D gc_new();
int ret =3D 0;
volatile int signal_received =3D 0;
- struct buffer alert_msg =3D clear_buf();
const bool standalone_disabled_save =3D man->persist.standalone_disabl=
ed;
struct man_connection *mc =3D &man->connection;
@@ -3757,6 +3755,7 @@
*state =3D EKS_SOLICIT;
+ struct buffer alert_msg;
if (b64_data)
{
alert_msg =3D alloc_buf_gc(strlen(b64_data) + strlen(prompt) +=
3, &gc);
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 0c2866c..1d3d649 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -7091,7 +7091,6 @@
if (streq(p[1], "FORWARD_COMPATIBLE") && p[2] && streq(p[2], "=
1"))
{
options->forward_compatible =3D true;
- msglevel_fc =3D msglevel_forward_compatible(options, msgle=
vel);
}
setenv_str(es, p[1], p[2] ? p[2] : "");
}
diff --git a/src/openvpn/pkcs11.c b/src/openvpn/pkcs11.c
index cfcd372..d115e0a 100644
--- a/src/openvpn/pkcs11.c
+++ b/src/openvpn/pkcs11.c
@@ -79,6 +79,9 @@
static msglvl_t
_pkcs11_msg_pkcs112openvpn(const unsigned flags)
{
+#ifdef ENABLE_PKCS11_FORCE_DEBUG
+ return M_INFO;
+#else
msglvl_t openvpn_flags;
switch (flags)
@@ -108,16 +111,16 @@
break;
}
-#if defined(ENABLE_PKCS11_FORCE_DEBUG)
- openvpn_flags =3D M_INFO;
-#endif
-
return openvpn_flags;
+#endif
}
static unsigned
_pkcs11_msg_openvpn2pkcs11(const msglvl_t flags)
{
+#ifdef ENABLE_PKCS11_FORCE_DEBUG
+ return PKCS11H_LOG_DEBUG2;
+#else
unsigned pkcs11_flags;
if ((flags & D_PKCS11_DEBUG) !=3D 0)
@@ -145,11 +148,8 @@
pkcs11_flags =3D PKCS11H_LOG_ERROR;
}
-#if defined(ENABLE_PKCS11_FORCE_DEBUG)
- pkcs11_flags =3D PKCS11H_LOG_DEBUG2;
-#endif
-
return pkcs11_flags;
+#endif
}
static void
diff --git a/src/openvpn/pkcs11_openssl.c b/src/openvpn/pkcs11_openssl.c
index b6c1624..69c5a50 100644
--- a/src/openvpn/pkcs11_openssl.c
+++ b/src/openvpn/pkcs11_openssl.c
@@ -384,7 +384,6 @@
if (certificate !=3D NULL)
{
pkcs11h_certificate_freeCertificate(certificate);
- certificate =3D NULL;
}
/*
@@ -400,7 +399,6 @@
if (openssl_session !=3D NULL)
{
pkcs11h_openssl_freeSession(openssl_session);
- openssl_session =3D NULL;
}
return ret;
#endif /* ifdef H=
AVE_XKEY_PROVIDER */
diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c
index f57f54d..af22af5 100644
--- a/src/openvpn/push_util.c
+++ b/src/openvpn/push_util.c
@@ -99,7 +99,6 @@
}
char *str =3D gc_strdup(s, gc);
- size_t i =3D 0;
while (*str)
{
@@ -112,11 +111,11 @@
/* if no commas were found go to fail, do not send any mes=
sage */
return false;
}
+ /* copy from current position to (ci - 1) */
str[ci] =3D '\0';
- /* copy from i to (ci -1) */
struct buffer tmp =3D forge_msg(str, ",push-continuation 2", g=
c);
buffer_list_push(msgs, BSTR(&tmp));
- i =3D ci + 1;
+ str +=3D ci + 1;
}
else
{
@@ -130,9 +129,8 @@
struct buffer tmp =3D forge_msg(str, NULL, gc);
buffer_list_push(msgs, BSTR(&tmp));
}
- i =3D strlen(str);
+ break;
}
- str =3D &str[i];
}
return true;
}
diff --git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index c47e3d2..306f85cd 100644
--- a/src/openvpn/ssl_openssl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -2353,13 +2353,13 @@
}
int typeid =3D EVP_PKEY_id(pkey);
+
+#ifndef OPENSSL_NO_EC
#if OPENSSL_VERSION_NUMBER < 0x30000000L
bool is_ec =3D typeid =3D=3D EVP_PKEY_EC;
#else
bool is_ec =3D EVP_PKEY_is_a(pkey, "EC");
#endif
-
-#ifndef OPENSSL_NO_EC
char groupname[64];
if (is_ec)
{
@@ -2667,15 +2667,13 @@
"builtin EC curves. It does not list additional curves nor X448=
or X25519\n");
#ifndef OPENSSL_NO_EC
EC_builtin_curve *curves =3D NULL;
- size_t crv_len =3D 0;
- size_t n =3D 0;
- crv_len =3D EC_get_builtin_curves(NULL, 0);
+ size_t crv_len =3D EC_get_builtin_curves(NULL, 0);
ALLOC_ARRAY(curves, EC_builtin_curve, crv_len);
if (EC_get_builtin_curves(curves, crv_len))
{
printf("\nAvailable Elliptic curves/groups:\n");
- for (n =3D 0; n < crv_len; n++)
+ for (size_t n =3D 0; n < crv_len; n++)
{
const char *sname;
sname =3D OBJ_nid2sn(curves[n].nid);
diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c
index b2a7331..5ee65fb 100644
--- a/src/openvpn/win32.c
+++ b/src/openvpn/win32.c
@@ -1293,9 +1293,6 @@
is_wow64_process2_t is_wow64_process2 =3D
(is_wow64_process2_t)GetProcAddress(GetModuleHandle("Kernel32.dll"=
), "IsWow64Process2");
- USHORT process_machine =3D 0;
- USHORT native_machine =3D 0;
-
#ifdef _ARM64_
*process_arch =3D ARCH_ARM64;
#elif defined(_WIN64)
@@ -1303,6 +1300,8 @@
if (is_wow64_process2)
{
/* this could be amd64 on arm64 */
+ USHORT process_machine =3D 0;
+ USHORT native_machine =3D 0;
BOOL is_wow64 =3D is_wow64_process2(GetCurrentProcess(), &process_=
machine, &native_machine);
if (is_wow64 && native_machine =3D=3D IMAGE_FILE_MACHINE_ARM64)
{
@@ -1315,6 +1314,8 @@
if (is_wow64_process2)
{
/* check if we're running on arm64 or amd64 machine */
+ USHORT process_machine =3D 0;
+ USHORT native_machine =3D 0;
BOOL is_wow64 =3D is_wow64_process2(GetCurrentProcess(), &process_=
machine, &native_machine);
if (is_wow64)
{
diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openvpnmsica/openvpnmsic=
a.c
index fdb610c..d698c04 100644
--- a/src/openvpnmsica/openvpnmsica.c
+++ b/src/openvpnmsica/openvpnmsica.c
@@ -711,7 +711,6 @@
uiResult =3D MsiViewFetch(hViewST, &hRecord);
if (uiResult =3D=3D ERROR_NO_MORE_ITEMS)
{
- uiResult =3D ERROR_SUCCESS;
break;
}
else if (uiResult !=3D ERROR_SUCCESS)
diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c
index 16e3c0b..6ed395d 100644
--- a/src/tapctl/tap.c
+++ b/src/tapctl/tap.c
@@ -473,7 +473,7 @@
return ERROR_OUTOFMEMORY;
}
- dwCountExpResult =3D ExpandEnvironmentStrings(szValue,=
szValueExp, dwCountExp);
+ ExpandEnvironmentStrings(szValue, szValueExp, dwCountE=
xp);
free(szValue);
*pszValue =3D szValueExp;
return ERROR_SUCCESS;
@@ -601,8 +601,6 @@
_In_ DWORD dwProperty, _Out_opt_ LPDWORD pdwProper=
tyRegDataType,
_Out_ LPVOID *ppData)
{
- DWORD dwResult =3D ERROR_BAD_ARGUMENTS;
-
if (ppData =3D=3D NULL)
{
return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@
}
else
{
- dwResult =3D GetLastError();
+ DWORD dwResult =3D GetLastError();
if (dwResult =3D=3D ERROR_INSUFFICIENT_BUFFER)
{
/* Allocate on heap and retry. */
diff --git a/tests/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn=
/test_ssl.c
index 0e9cecf..c40845a 100644
--- a/tests/unit_tests/openvpn/test_ssl.c
+++ b/tests/unit_tests/openvpn/test_ssl.c
@@ -303,8 +303,6 @@
struct buffer work =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);
struct buffer encrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc=
);
struct buffer decrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc=
);
- struct buffer buf =3D clear_buf();
- void *buf_p;
/* init work */
ASSERT(buf_init(&work, frame.buf.headroom));
@@ -325,8 +323,8 @@
ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
/* copy source to input buf */
- buf =3D work;
- buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
+ struct buffer buf =3D work;
+ void *buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
ASSERT(buf_p);
memcpy(buf_p, BPTR(&src), BLENZ(&src));
@@ -356,7 +354,6 @@
struct buffer encrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc=
);
struct buffer decrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc=
);
struct buffer work =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);
- struct buffer buf =3D clear_buf();
struct buffer src =3D alloc_buf_gc(frame.buf.payload_size, &gc);
void *buf_p;
@@ -371,7 +368,7 @@
ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
/* copy source to input buf */
- buf =3D work;
+ struct buffer buf =3D work;
buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
ASSERT(buf_p);
memcpy(buf_p, BPTR(&src), BLENZ(&src));
@@ -652,7 +649,6 @@
struct buffer work =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);
struct buffer encrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc=
);
struct buffer decrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc=
);
- struct buffer buf =3D clear_buf();
void *buf_p;
/* init work */
@@ -669,7 +665,7 @@
ASSERT(buf_write(&src, plaintext, strlen(plaintext)));
/* copy source to input buf */
- buf =3D work;
+ struct buffer buf =3D work;
buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
ASSERT(buf_p);
memcpy(buf_p, BPTR(&src), BLENZ(&src));
diff --git a/tests/unit_tests/openvpnserv/test_openvpnserv.c b/tests/unit_t=
ests/openvpnserv/test_openvpnserv.c
index 45096a1..6a6aee4 100644
--- a/tests/unit_tests/openvpnserv/test_openvpnserv.c
+++ b/tests/unit_tests/openvpnserv/test_openvpnserv.c
@@ -57,13 +57,13 @@
static void
test_convert_itf_dns_domains(void **state)
{
- DWORD size, orig_size, len, res_len;
+ DWORD size, len, res_len;
LSTATUS err;
const DWORD glyph_size =3D sizeof(wchar_t);
wchar_t domains_1[BUF_SIZE] =3D L"openvpn.com";
len =3D (DWORD)wcslen(domains_1) + 1;
- size =3D orig_size =3D len * glyph_size;
+ size =3D len * glyph_size;
wchar_t domains_1_res[BUF_SIZE] =3D L".openvpn.com";
res_len =3D len + 2; /* adds . and \0 */
err =3D ConvertItfDnsDomains(L"openvpn.net", domains_1, &size, BUF_SIZ=
E);
@@ -73,7 +73,7 @@
wchar_t domains_2[BUF_SIZE] =3D L"openvpn.com,openvpn.net";
len =3D (DWORD)wcslen(domains_2) + 1;
- size =3D orig_size =3D len * glyph_size;
+ size =3D len * glyph_size;
wchar_t domains_2_res[BUF_SIZE] =3D L".openvpn.com";
res_len =3D (DWORD)wcslen(domains_2_res) + 2;
err =3D ConvertItfDnsDomains(L"openvpn.net", domains_2, &size, BUF_SIZ=
E);
@@ -83,7 +83,7 @@
wchar_t domains_3[BUF_SIZE] =3D L"openvpn.com,openvpn.net";
len =3D (DWORD)wcslen(domains_3) + 1;
- size =3D orig_size =3D len * glyph_size;
+ size =3D len * glyph_size;
wchar_t domains_3_res[BUF_SIZE] =3D L".openvpn.net";
res_len =3D (DWORD)wcslen(domains_3_res) + 2;
err =3D ConvertItfDnsDomains(L"openvpn.com", domains_3, &size, BUF_SIZ=
E);
@@ -93,7 +93,7 @@
wchar_t domains_4[BUF_SIZE] =3D L"openvpn.com,openvpn.net";
len =3D (DWORD)wcslen(domains_4) + 1;
- size =3D orig_size =3D len * glyph_size;
+ size =3D len * glyph_size;
wchar_t domains_4_res[BUF_SIZE] =3D L".openvpn.com\0.openvpn.net";
res_len =3D len + 3; /* adds two . and one \0 */
err =3D ConvertItfDnsDomains(NULL, domains_4, &size, BUF_SIZE);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1617?usp=3Demail
To unsubscribe, or for help writing mail filters, visit http://gerrit.openv=
pn.net/settings?usp=3Demail
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld
Gerrit-Reviewer: plaisthos
Gerrit-CC: openvpn-devel
Gerrit-Attention: plaisthos
--jEQ1hmBv+3w=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Attention is cur=
rently required from: plaisthos.
flichtenheld uploaded patch set #5 to this change.
<=
p>View C=
hange
Remove various useless assignments
The va=
lues assigned by these are never actually used
for something.
Ide=
ntified by cppcheck.
Change-Id: Id0caa497c4ff1ad8743cb23f332f003b2d3=
393ed
Signed-off-by: Frank Lichtenheld <frank@...2641...>
---M src/openvpn/console_builtin.c
M src/openvpn/crypto.c
M src/openvp=
n/error.h
M src/openvpn/forward.c
M src/openvpn/manage.c
M src/ope=
nvpn/options.c
M src/openvpn/pkcs11.c
M src/openvpn/pkcs11_openssl.c<=
br>M src/openvpn/push_util.c
M src/openvpn/ssl_openssl.c
M src/openvp=
n/win32.c
M src/openvpnmsica/openvpnmsica.c
M src/tapctl/tap.c
M t=
ests/unit_tests/openvpn/test_ssl.c
M tests/unit_tests/openvpnserv/test_o=
penvpnserv.c
15 files changed, 41 insertions(+), 58 deletions(-)
=
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/ch=
anges/17/1617/5
diff --git a/src/openvpn/console_builtin.c b/src/op=
envpn/console_builtin.c
index 2a9f3b6..9c8d72a 100644
--- a/src/openvpn/console_builtin.c
+++ b/src/op=
envpn/console_builtin.c
@@ -192,7 +192,6 @@
static bool
get_console_input(const char *prompt, const =
bool echo, char *input, const int capacity)
{
- bool ret =3D false;
=
ASSERT(prompt);
ASSERT(input);
ASSERT(capacity > 0);
@@ -200,8 +199,11 @@
#if defined(_WIN32)
ret=
urn get_console_input_win32(prompt, echo, input, capacity);
-#elif defined(HAVE_TERMIOS_H)<=
br>+#elif !defined(HAVE_TERMIOS=
_H)
+ msg(M_FATAL,=
"Sorry, but I can't get console input on this OS (%s)", prom=
pt);
+#else
bool restore_tty =3D false;
+ bool ret =3D false;
struct ter=
mios tty_tmp, tty_save;
/* did we --=
daemon'ize before asking for passwords?
@@ -258,10 +260=
,8 @@
}
close_t=
ty(fp);
-#else /* if d=
efined(_WIN32) */
- =
msg(M_FATAL, "Sorry, but I can't get console input on this OS (%s)=
", prompt);
-#endi=
f /* if defined(_WIN32) */
return ret;
+#endif /* if defined(_WIN32) */
}
/**
diff=
--git a/src/openvpn/crypto.c b/src/openvpn/crypto.c
index =
7954e8a..df9b905 100644
--- a/src/openvpn/crypto.c+++ b/src/openvpn/crypto.c
@@ -1204,8 +1204,6 @@
struct buffer work =3D alloc_buf_gc(BUF_SIZE(frame), &am=
p;gc);
struct buffer encrypt_workspace =3D alloc_buf_g=
c(BUF_SIZE(frame), &gc);
struct buffer decrypt_wor=
kspace =3D alloc_buf_gc(BUF_SIZE(frame), &gc);
- struct buffer buf =3D clear_buf();<=
br>- void *buf_p;
/* init work */
ASSERT(buf_=
init(&work, frame->buf.headroom));
@@ -1242,8 +1240,=
8 @@
ASSERT(rand_bytes(BPTR(&src), BLEN(&s=
rc)));
/* copy source to input b=
uf */
- buf =3D =
work;
- buf_p =
=3D buf_write_alloc(&buf, BLENZ(&src));
+ struct buffer buf =3D work;
<=
span style=3D"color: hsl(120, 100%, 40%);">+ void *buf_p =3D buf_wri=
te_alloc(&buf, BLENZ(&src));
ASSERT(buf_p)=
;
memcpy(buf_p, BPTR(&src), BLENZ(&src));<=
/span>
diff --git a/src/openvpn/error.h b/src/op=
envpn/error.h
index 45826a2..a887fc7 100644
--- a/src/openvpn/error.h
+++ b/src/openvpn/error.h=
@@ -408,8 +408,8 @@
openvpn_errno_maybe_crt(bool=
*crt_error)
{
int err =3D 0;<=
br>- *crt_error =3D false;
#ifdef _WIN32
+ *crt_error =3D false;
err =3D GetLastError=
();
if (err =3D=3D ERROR_SUCCESS)
=
{
diff --git a/src/openvpn/forward.c b/src/openvpn/forward=
.c
index 27cfd36..53eab4d 100644
--- a/src/=
openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -1746,7 +1746,6 @@
process_outgoing_link(struct cont=
ext *c, struct link_socket *sock)
{
s=
truct gc_arena gc =3D gc_new();
- int error_code =3D 0;
=
if (c->c2.to_link.len > 0 && c->c2.to_link.len <=3D c-&=
gt;c2.frame.buf.payload_size)
{
@@ -18=
21,7 +1820,7 @@
}
/* Check return status */
- error_code =3D openvpn_errno();
+ int error_code =3D openvpn_errno=
();
check_status(size, "write", sock, NU=
LL);
if (size > 0)
=
diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 2a3023c..f1dccc1 100644
--- a/src/openvpn/manage.=
c
+++ b/src/openvpn/manage.c
@@ -916,10 +91=
6,9 @@
static void
man_remote_entry_count=
(struct management *man)
{
- unsigned count =3D 0;
if (ma=
n->persist.callback.remote_entry_count)
{
- count =3D (*man->per=
sist.callback.remote_entry_count)(man->persist.callback.arg);
=
+ unsigned int count =3D=
(*man->persist.callback.remote_entry_count)(man->persist.callback.ar=
g);
msg(M_CLIENT, "%u", count); msg(M_CLIENT, "END");
}
@@ -3745,7 +3744,6 @@
struct gc_arena gc =
=3D gc_new();
int ret =3D 0;
vola=
tile int signal_received =3D 0;
- struct buffer alert_msg =3D clear_buf();
=
const bool standalone_disabled_save =3D man->persist.standalone_disable=
d;
struct man_connection *mc =3D &man->connecti=
on;
@@ -3757,6 +3755,7 @@
*state =3D EKS_SOLICIT;
+ struct buffer ale=
rt_msg;
if (b64_data)
{=
span>
alert_msg =3D alloc_buf_gc(strlen(b64_data) + s=
trlen(prompt) + 3, &gc);
diff --git a/src/openvpn/optio=
ns.c b/src/openvpn/options.c
index 0c2866c..1d3d649 100644<=
/span>
--- a/src/openvpn/options.c
+++ b/src/openv=
pn/options.c
@@ -7091,7 +7091,6 @@
=
if (streq(p[1], "FORWARD_COMPATIBLE") && p[2] &&=
amp; streq(p[2], "1"))
{
<=
span> options->forward_compatible =3D true;
- msglevel_fc =3D ms=
glevel_forward_compatible(options, msglevel);
=
}
setenv_str(es, p[1], p[2] ? p[2] : "&qu=
ot;);
}
diff --git a/src/openvpn/p=
kcs11.c b/src/openvpn/pkcs11.c
index cfcd372..d115e0a 10064=
4
--- a/src/openvpn/pkcs11.c
+++ b/src/open=
vpn/pkcs11.c
@@ -79,6 +79,9 @@
static msgl=
vl_t
_pkcs11_msg_pkcs112openvpn(const unsigned flags)
{
+#ifde=
f ENABLE_PKCS11_FORCE_DEBUG
+ return M_INFO;
+#else
msglvl_t openvpn_flags;
=
switch (flags)
@@ -108,16 +111,16 @@<=
/span>
break;
}
=
-#if defined(ENABLE_P=
KCS11_FORCE_DEBUG)
- =
openvpn_flags =3D M_INFO;
-#endif
-
return openvpn_flags;
+#endif
}
=
static unsigned
_pkcs11_msg_openvpn2pkcs11(const msglvl_t =
flags)
{
+#ifdef ENABLE_PKCS11_FORCE_DEBUG
+ return PKCS11H_LOG_DEBUG2;
+#else
unsigned pkcs11_fl=
ags;
if ((flags & D_PKCS11_DEBUG=
) !=3D 0)
@@ -145,11 +148,8 @@
pkc=
s11_flags =3D PKCS11H_LOG_ERROR;
}
=
span>
-#if defined(ENABLE_PKCS=
11_FORCE_DEBUG)
- pk=
cs11_flags =3D PKCS11H_LOG_DEBUG2;
-#endif
-=
span>
return pkcs11_flags;
+#endif
}
=
static void
diff --git a/src/openvpn/pkcs11_openssl.=
c b/src/openvpn/pkcs11_openssl.c
index b6c1624..69c5a50 100=
644
--- a/src/openvpn/pkcs11_openssl.c
+++ =
b/src/openvpn/pkcs11_openssl.c
@@ -384,7 +384,6 @@ if (certificate !=3D NULL)
{
pkcs11h_certificate_freeCertificate(certificate);
- certificate =3D NULL;
}
/*
@@ -400,7 +399,6 @@
if (openssl_session !=3D NULL)=
span>
{
pkcs11h_openssl_freeSession(=
openssl_session);
- =
openssl_session =3D NULL;
}
r=
eturn ret;
#endif =
/* ifdef HAVE_XKEY_PROVIDER */
diff --git =
a/src/openvpn/push_util.c b/src/openvpn/push_util.c
index f=
57f54d..af22af5 100644
--- a/src/openvpn/push_util.c=
+++ b/src/openvpn/push_util.c
@@ -99,7 +99,6 @@=
span>
}
char *str =3D =
gc_strdup(s, gc);
- =
size_t i =3D 0;
while (*str)<=
br> {
@@ -112,11 +111,11 @@
=
/* if no commas were found go to fail, do not send any message =
*/
return false;
=
}
+ /*=
copy from current position to (ci - 1) */
str=
[ci] =3D '\0';
=
- /* copy from i to (ci -1) */
stru=
ct buffer tmp =3D forge_msg(str, ",push-continuation 2", gc);
buffer_list_push(msgs, BSTR(&tmp));
- i =3D ci + 1;
+ str +=3D ci +=
1;
}
else
{
@@ -130,9 +129,8 @@
=
struct buffer tmp =3D forge_msg(str, NULL, gc);
=
buffer_list_push(msgs, BSTR(&tmp));
=
}
- i=
=3D strlen(str);
+ =
break;
}
- str =3D &str[i];
}=
span>
return true;
}
diff --=
git a/src/openvpn/ssl_openssl.c b/src/openvpn/ssl_openssl.c
index c47e3d2..306f85cd 100644
--- a/src/openvpn/ssl_opens=
sl.c
+++ b/src/openvpn/ssl_openssl.c
@@ -23=
53,13 +2353,13 @@
}
=
int typeid =3D EVP_PKEY_id(pkey);
+
+=
#ifndef OPENSSL_NO_EC
#if OPENSSL_VERSION_NUMBER < 0x30=
000000L
bool is_ec =3D typeid =3D=3D EVP_PKEY_EC;
#else
bool is_ec =3D EVP_PKEY_is_a(pkey, =
"EC");
#endif
-
-#i=
fndef OPENSSL_NO_EC
char groupname[64];
if (is_ec)
{
@@ -2667,15 +2667,=
13 @@
"builtin EC curves. It does not list=
additional curves nor X448 or X25519\n");
#ifndef OP=
ENSSL_NO_EC
EC_builtin_curve *curves =3D NULL;<=
br>- size_t crv_len =3D 0;
- size_t n =3D 0;
- crv_l=
en =3D EC_get_builtin_curves(NULL, 0);
+ size_t crv_len =3D EC_get_builtin_curves(NULL, 0);=
span>
ALLOC_ARRAY(curves, EC_builtin_curve, crv_len);<=
br> if (EC_get_builtin_curves(curves, crv_len))
=
{
printf("\nAvailable Elliptic curves/gro=
ups:\n");
- =
for (n =3D 0; n < crv_len; n++)
+ for (size_t n =3D 0; n < crv_len; n++)
{
const char *sname;
sname =3D OBJ_nid2sn(curves[n].nid);
di=
ff --git a/src/openvpn/win32.c b/src/openvpn/win32.c
index =
b2a7331..5ee65fb 100644
--- a/src/openvpn/win32.c
+++ b/src/openvpn/win32.c
@@ -1293,9 +1293,6 @@
is_wow64_process2_t is_wow64_process2 =3D
=
(is_wow64_process2_t)GetProcAddress(GetModuleHandle("Kernel32=
.dll"), "IsWow64Process2");
- USHORT process_machine =3D 0;
- USHORT native_machin=
e =3D 0;
-
#ifdef _ARM64_
*process_arch =3D ARCH_ARM64;
#elif defined(_WIN64)
@@ -1303,6 +1300,8 @@
if (is_wow64_process2)
{
=
/* this could be amd64 on arm64 */
+ USHORT process_machine =3D 0;<=
br>+ USHORT native_machi=
ne =3D 0;
BOOL is_wow64 =3D is_wow64_process2(GetC=
urrentProcess(), &process_machine, &native_machine);
if (is_wow64 && native_machine =3D=3D IMAGE_FILE_MACHINE=
_ARM64)
{
@@ -1315,6 +1314,8 @@
if (is_wow64_process2)
{
=
/* check if we're running on arm64 or amd64 machine */=
span>
+ USHORT proces=
s_machine =3D 0;
+ =
USHORT native_machine =3D 0;
BOOL is_wow64 =
=3D is_wow64_process2(GetCurrentProcess(), &process_machine, &nativ=
e_machine);
if (is_wow64)
=
{
diff --git a/src/openvpnmsica/openvpnmsica.c b/src/openv=
pnmsica/openvpnmsica.c
index fdb610c..d698c04 100644=
--- a/src/openvpnmsica/openvpnmsica.c
+++ b/src/o=
penvpnmsica/openvpnmsica.c
@@ -711,7 +711,6 @@
uiResult =3D MsiViewFetch(hViewST, &hRecord);
if (uiResult =3D=3D ERROR_NO_MORE_ITEMS)
=
{
- uiRe=
sult =3D ERROR_SUCCESS;
break;
}
else if (uiResult !=3D ERROR_SUCCESS)<=
/span>
diff --git a/src/tapctl/tap.c b/src/tapctl/tap.c
=
index 16e3c0b..6ed395d 100644
--- a/src/tapctl/tap.c<=
/span>
+++ b/src/tapctl/tap.c
@@ -473,7 +473,7 @@<=
/span>
return ERROR_OUTOFMEMORY; }
- dwCountExpResult =3D ExpandE=
nvironmentStrings(szValue, szValueExp, dwCountExp);
+ ExpandEnvironmentStri=
ngs(szValue, szValueExp, dwCountExp);
=
free(szValue);
*pszValue =3D szValueEx=
p;
return ERROR_SUCCESS;
@@ -601,8 +601,6 @@
_In_ DWORD =
dwProperty, _Out_opt_ LPDWORD pdwPropertyRegDataType,
=
_Out_ LPVOID *ppData)
{
- DWORD dwResult =3D ERROR_BAD_ARG=
UMENTS;
-
if (ppData =3D=3D NULL)
{
=
return ERROR_BAD_ARGUMENTS;
@@ -628,7 +626,7 @@=
}
else
{
- dwResult =3D GetLastErr=
or();
+ DWORD =
dwResult =3D GetLastError();
if (dwResult =3D=3D E=
RROR_INSUFFICIENT_BUFFER)
{
=
/* Allocate on heap and retry. */
diff --git a/tests=
/unit_tests/openvpn/test_ssl.c b/tests/unit_tests/openvpn/test_ssl.c=
index 0e9cecf..c40845a 100644
--- a/tests/unit_te=
sts/openvpn/test_ssl.c
+++ b/tests/unit_tests/openvpn/test_=
ssl.c
@@ -303,8 +303,6 @@
struct buffe=
r work =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);
=
struct buffer encrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &a=
mp;gc);
struct buffer decrypt_workspace =3D alloc_buf_=
gc(BUF_SIZE(&frame), &gc);
- struct buffer buf =3D clear_buf();
- void *buf_p;
/* init work */
ASSERT(buf_init(&work=
, frame.buf.headroom));
@@ -325,8 +323,8 @@
ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));
/* copy source to input buf */
- buf =3D work;
- buf_p =3D buf_write_alloc(&a=
mp;buf, BLENZ(&src));
+ struct buffer buf =3D work;
+ void *buf_p =3D buf_write_alloc(&buf, BLE=
NZ(&src));
ASSERT(buf_p);
=
memcpy(buf_p, BPTR(&src), BLENZ(&src));
@@ -356,7 +354,6 @@
struct buffer encrypt_=
workspace =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);
=
struct buffer decrypt_workspace =3D alloc_buf_gc(BUF_SIZE(&frame),=
&gc);
struct buffer work =3D alloc_buf_gc(BUF_SIZ=
E(&frame), &gc);
- struct buffer buf =3D clear_buf();
struct buffe=
r src =3D alloc_buf_gc(frame.buf.payload_size, &gc);
=
void *buf_p;
@@ -371,7 +368,7 @@
ASSERT(rand_bytes(BPTR(&src), BLEN(&src)));<=
br>
/* copy source to input buf */
- buf =3D work;
+ struct buffer buf =3D work;
buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
ASSERT(buf_p);
memcpy(buf_p, BPTR(&am=
p;src), BLENZ(&src));
@@ -652,7 +649,6 @@
struct buffer work =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);=
struct buffer encrypt_workspace =3D alloc_buf_gc(BUF_=
SIZE(&frame), &gc);
struct buffer decrypt_work=
space =3D alloc_buf_gc(BUF_SIZE(&frame), &gc);
- struct buffer buf =3D clear_buf();
void *buf_p;
/* in=
it work */
@@ -669,7 +665,7 @@
ASSERT(=
buf_write(&src, plaintext, strlen(plaintext)));
/* copy source to input buf */
- buf =3D work;
+ struct buffer buf =3D work;
=
buf_p =3D buf_write_alloc(&buf, BLENZ(&src));
=
ASSERT(buf_p);
memcpy(buf_p, BPTR(&src), BLENZ(&a=
mp;src));
diff --git a/tests/unit_tests/openvpnserv/test_op=
envpnserv.c b/tests/unit_tests/openvpnserv/test_openvpnserv.c
index 45096a1..6a6aee4 100644
--- a/tests/unit_tests/ope=
nvpnserv/test_openvpnserv.c
+++ b/tests/unit_tests/openvpns=
erv/test_openvpnserv.c
@@ -57,13 +57,13 @@
=
static void
test_convert_itf_dns_domains(void **state)
{
- D=
WORD size, orig_size, len, res_len;
+ DWORD size, len, res_len;
LSTATUS =
err;
const DWORD glyph_size =3D sizeof(wchar_t);
wchar_t domains_1[BUF_SIZE] =3D L"op=
envpn.com";
len =3D (DWORD)wcslen(domains_1) + 1;=
- size =3D orig_siz=
e =3D len * glyph_size;
+ size =3D len * glyph_size;
wchar_t domains_1_r=
es[BUF_SIZE] =3D L".openvpn.com";
res_len =
=3D len + 2; /* adds . and \0 */
err =3D ConvertItfDns=
Domains(L"openvpn.net", domains_1, &size, BUF_SIZE);@@ -73,7 +73,7 @@
wchar_t do=
mains_2[BUF_SIZE] =3D L"openvpn.com,openvpn.net";
len =3D (DWORD)wcslen(domains_2) + 1;
- size =3D orig_size =3D len * glyph_size;+ size =3D len * glyph_siz=
e;
wchar_t domains_2_res[BUF_SIZE] =3D L".openvpn=
.com";
res_len =3D (DWORD)wcslen(domains_2_res) +=
2;
err =3D ConvertItfDnsDomains(L"openvpn.net&qu=
ot;, domains_2, &size, BUF_SIZE);
@@ -83,7 +83,7 @@
wchar_t domains_3[BUF_SIZE] =3D L"=
openvpn.com,openvpn.net";
len =3D (DWORD)wcslen(d=
omains_3) + 1;
- siz=
e =3D orig_size =3D len * glyph_size;
+ size =3D len * glyph_size;
wchar=
_t domains_3_res[BUF_SIZE] =3D L".openvpn.net";
=
res_len =3D (DWORD)wcslen(domains_3_res) + 2;
err =
=3D ConvertItfDnsDomains(L"openvpn.com", domains_3, &size, BU=
F_SIZE);
@@ -93,7 +93,7 @@
wchar_t domains_4[BUF_SIZE] =3D L"openvpn.com,openvpn.net"=
;
len =3D (DWORD)wcslen(domains_4) + 1;
- size =3D orig_size =3D len * gly=
ph_size;
+ size =
=3D len * glyph_size;
wchar_t domains_4_res[BUF_SIZE] =
=3D L".openvpn.com\0.openvpn.net";
res_len =
=3D len + 3; /* adds two . and one \0 */
err =3D Conve=
rtItfDnsDomains(NULL, domains_4, &size, BUF_SIZE);
To view, visit change 1617. To unsubscribe, or for help writing=
mail filters, visit settings.
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id0caa497c4ff1ad8743cb23f332=
f003b2d3393ed
Gerrit-Change-Number: 1617
Gerrit-PatchSet: 5
Gerrit-Owner: flichtenheld <frank@...2723...=
.>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...=
.1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...=
ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...=
..1227...>
=
--jEQ1hmBv+3w=--