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/+/2354?usp=email
to review the following change.
Change subject: Remove redundant statements
......................................................................
Remove redundant statements
- Fields set to zero right after ALLOC_OBJ_CLEAR (buffer_list_new,
env_set_create, status_open).
- hash_init(): ALLOC_ARRAY_CLEAR instead of ALLOC_ARRAY plus a loop
setting each bucket list to NULL.
- route.c: CLEAR(rtm) after CLEAR(m_rtmsg); rtm is m_rtmsg.m_rtm.
- win32-util.c: checks on gc_malloc() results; it never returns NULL.
- should_trigger_renegotiation(): return the comparison directly.
- peer_info_extract_varstr(): NULL check the while loop already does.
Change-Id: I9f3ee97589606af5904a580f594fc1647eb91395
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M src/openvpn/buffer.c
M src/openvpn/env_set.c
M src/openvpn/list.c
M src/openvpn/route.c
M src/openvpn/ssl.c
M src/openvpn/ssl_util.c
M src/openvpn/status.c
M src/openvpn/win32-util.c
8 files changed, 3 insertions(+), 30 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/2354/1
diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c
index c33a987..4b660da 100644
--- a/src/openvpn/buffer.c
+++ b/src/openvpn/buffer.c
@@ -1186,7 +1186,6 @@
{
struct buffer_list *ret;
ALLOC_OBJ_CLEAR(ret, struct buffer_list);
- ret->size = 0;
return ret;
}
diff --git a/src/openvpn/env_set.c b/src/openvpn/env_set.c
index 55190b8..5bbb17b 100644
--- a/src/openvpn/env_set.c
+++ b/src/openvpn/env_set.c
@@ -156,7 +156,6 @@
{
struct env_set *es;
ALLOC_OBJ_CLEAR_GC(es, struct env_set, gc);
- es->list = NULL;
es->gc = gc;
return es;
}
diff --git a/src/openvpn/list.c b/src/openvpn/list.c
index 505be30..7b385da 100644
--- a/src/openvpn/list.c
+++ b/src/openvpn/list.c
@@ -49,12 +49,7 @@
/* create random hash key */
prng_bytes(h->hash_key, sizeof(h->hash_key));
- ALLOC_ARRAY(h->buckets, struct hash_bucket, h->n_buckets);
- for (uint32_t i = 0; i < h->n_buckets; ++i)
- {
- struct hash_bucket *b = &h->buckets[i];
- b->list = NULL;
- }
+ ALLOC_ARRAY_CLEAR(h->buckets, struct hash_bucket, h->n_buckets);
return h;
}
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 82cb7f0..4553e73 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3334,7 +3334,6 @@
CLEAR(m_rtmsg);
CLEAR(so_dst);
CLEAR(so_mask);
- CLEAR(rtm);
rtm.rtm_type = RTM_GET;
rtm.rtm_flags = RTF_UP | RTF_GATEWAY;
@@ -3552,7 +3551,6 @@
CLEAR(m_rtmsg);
CLEAR(so_dst);
CLEAR(so_mask);
- CLEAR(rtm);
rtm.rtm_type = RTM_GET;
rtm.rtm_flags = RTF_UP;
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c
index ca5958f..5c72b56 100644
--- a/src/openvpn/ssl.c
+++ b/src/openvpn/ssl.c
@@ -3105,14 +3105,7 @@
{
/* We only need to check the send key as we always keep send
* key epoch >= recv key epoch in \c epoch_replace_update_recv_key */
- if (ks->crypto_options.epoch_key_send.epoch >= 0xF000)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return ks->crypto_options.epoch_key_send.epoch >= 0xF000;
}
diff --git a/src/openvpn/ssl_util.c b/src/openvpn/ssl_util.c
index 6c17fe5..9bfb75f 100644
--- a/src/openvpn/ssl_util.c
+++ b/src/openvpn/ssl_util.c
@@ -35,11 +35,6 @@
static const char *
peer_info_extract_varstr(const char *peer_info, const char *field)
{
- if (!peer_info)
- {
- return NULL;
- }
-
while (peer_info)
{
/* peer info starts with this field */
diff --git a/src/openvpn/status.c b/src/openvpn/status.c
index 0a3fc019..e96ff51 100644
--- a/src/openvpn/status.c
+++ b/src/openvpn/status.c
@@ -72,8 +72,6 @@
so->msglevel = msglevel;
so->vout = vout;
so->fd = -1;
- buf_reset(&so->read_buf);
- event_timeout_clear(&so->et);
if (filename)
{
switch (so->flags)
diff --git a/src/openvpn/win32-util.c b/src/openvpn/win32-util.c
index 5f99e2b..f586e09 100644
--- a/src/openvpn/win32-util.c
+++ b/src/openvpn/win32-util.c
@@ -92,7 +92,6 @@
}
work = gc_malloc(maxlen + 1, false, gc);
- check_malloc_return(work);
buf = alloc_buf_gc(nchars, gc);
for (i = 0; i < a->argc; ++i)
@@ -128,10 +127,7 @@
if (n > 0)
{
utf8 = gc_malloc(n, true, gc);
- if (utf8)
- {
- WideCharToMultiByte(CP_UTF8, 0, utf16, -1, utf8, n, NULL, NULL);
- }
+ WideCharToMultiByte(CP_UTF8, 0, utf16, -1, utf8, n, NULL, NULL);
}
return utf8;
}
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2354?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: I9f3ee97589606af5904a580f594fc1647eb91395
Gerrit-Change-Number: 2354
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[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