[M] Change in openvpn[master]: Rename variables that shadow other variables or functions

"flichtenheld (Code Review)" <[email protected]>
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
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/+/1618?usp=email

to review the following change.


Change subject: Rename variables that shadow other variables or functions
......................................................................

Rename variables that shadow other variables or functions

Identified by cppcheck.

Change-Id: I528f5fd200d877841e473e5e05b7ac7915fa2e33
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M src/openvpn/manage.c
M src/openvpn/options.c
M src/openvpn/push.c
M src/openvpn/tls_crypt.c
M src/openvpnserv/interactive.c
M tests/unit_tests/openvpn/test_push_update_msg.c
6 files changed, 42 insertions(+), 45 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/18/1618/1

diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c
index 31dcd4f..9efc08f 100644
--- a/src/openvpn/manage.c
+++ b/src/openvpn/manage.c
@@ -1254,8 +1254,6 @@
 static void
 man_load_stats(struct management *man)
 {
-    extern counter_type link_read_bytes_global;
-    extern counter_type link_write_bytes_global;
     int nclients = 0;
 
     if (man->persist.callback.n_clients)
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 28275cc..186b2d2 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -2689,12 +2689,12 @@
                     "may accept clients which do not present a certificate");
     }
 
-    const unsigned int tls_version_max =
+    const unsigned int tls_ver_max =
         (options->ssl_flags >> SSLF_TLS_VERSION_MAX_SHIFT) & SSLF_TLS_VERSION_MAX_MASK;
-    const unsigned int tls_version_min =
+    const unsigned int tls_ver_min =
         (options->ssl_flags >> SSLF_TLS_VERSION_MIN_SHIFT) & SSLF_TLS_VERSION_MIN_MASK;
 
-    if (tls_version_max > 0 && tls_version_max < tls_version_min)
+    if (tls_ver_max > 0 && tls_ver_max < tls_ver_min)
     {
         msg(M_USAGE, "--tls-version-min bigger than --tls-version-max");
     }
@@ -3641,16 +3641,16 @@
         {
             struct dns_domain **entry = &dns->search_domains;
             ALLOC_OBJ_CLEAR_GC(*entry, struct dns_domain, &dns->gc);
-            struct dns_domain *new = *entry;
-            new->name = dhcp->domain;
-            entry = &new->next;
+            struct dns_domain *domain = *entry;
+            domain->name = dhcp->domain;
+            entry = &domain->next;
 
             for (unsigned int i = 0; i < dhcp->domain_search_list_len; ++i)
             {
                 ALLOC_OBJ_CLEAR_GC(*entry, struct dns_domain, &dns->gc);
-                struct dns_domain *new = *entry;
-                new->name = dhcp->domain_search_list[i];
-                entry = &new->next;
+                struct dns_domain *search_domain = *entry;
+                search_domain->name = dhcp->domain_search_list[i];
+                entry = &search_domain->next;
             }
 
             struct dns_server *server = dns_server_get(&dns->servers, 0, &dns->gc);
@@ -3743,7 +3743,6 @@
 static void
 options_postprocess_mutate(struct options *o, struct env_set *es)
 {
-    int i;
     /*
      * Process helper-type options which map to other, more complex
      * sequences of options.
@@ -3776,7 +3775,7 @@
          * Convert remotes into connection list
          */
         const struct remote_list *rl = o->remote_list;
-        for (i = 0; i < rl->len; ++i)
+        for (int i = 0; i < rl->len; ++i)
         {
             const struct remote_entry *re = rl->array[i];
             struct connection_entry ce = o->ce;
@@ -3798,14 +3797,14 @@
     }
 
     ASSERT(o->connection_list);
-    for (i = 0; i < o->connection_list->len; ++i)
+    for (int i = 0; i < o->connection_list->len; ++i)
     {
         options_postprocess_mutate_ce(o, o->connection_list->array[i]);
     }
 
     if (o->ce.local_list)
     {
-        for (i = 0; i < o->ce.local_list->len; i++)
+        for (int i = 0; i < o->ce.local_list->len; i++)
         {
             options_postprocess_mutate_le(&o->ce, o->ce.local_list->array[i], o->mode);
         }
@@ -3833,7 +3832,7 @@
     }
 
     /* use the same listen list for every outgoing connection */
-    for (i = 0; i < o->connection_list->len; ++i)
+    for (int i = 0; i < o->connection_list->len; ++i)
     {
         o->connection_list->array[i]->local_list = o->ce.local_list;
     }
diff --git a/src/openvpn/push.c b/src/openvpn/push.c
index 564ce86..ae0f0e2 100644
--- a/src/openvpn/push.c
+++ b/src/openvpn/push.c
@@ -994,10 +994,10 @@
     else if (tls_authentication_status(c->c2.tls_multi) == TLS_AUTHENTICATION_SUCCEEDED
              && c->c2.tls_multi->multi_state >= CAS_CONNECT_DONE)
     {
-        time_t now;
+        time_t local_now;
 
-        openvpn_time(&now);
-        if (c->c2.sent_push_reply_expiry > now)
+        openvpn_time(&local_now);
+        if (c->c2.sent_push_reply_expiry > local_now)
         {
             ret = PUSH_MSG_ALREADY_REPLIED;
         }
@@ -1011,7 +1011,7 @@
             if (send_push_reply(c, &push_list))
             {
                 ret = PUSH_MSG_REQUEST;
-                c->c2.sent_push_reply_expiry = now + 30;
+                c->c2.sent_push_reply_expiry = local_now + 30;
             }
             gc_free(&gc);
         }
diff --git a/src/openvpn/tls_crypt.c b/src/openvpn/tls_crypt.c
index 70889dc..c25986f 100644
--- a/src/openvpn/tls_crypt.c
+++ b/src/openvpn/tls_crypt.c
@@ -769,24 +769,24 @@
     }
 
     /* Sanity check: load client key (as "client") */
-    struct key_ctx_bi test_client_key;
-    struct buffer test_wrapped_client_key;
+    struct key_ctx_bi check_client_key;
+    struct buffer check_wrapped_client_key;
     struct key2 keydata;
     msg(D_GENKEY, "Testing client-side key loading...");
-    tls_crypt_v2_init_client_key(&test_client_key, &keydata, &test_wrapped_client_key, client_file,
+    tls_crypt_v2_init_client_key(&check_client_key, &keydata, &check_wrapped_client_key, client_file,
                                  client_inline);
-    free_key_ctx_bi(&test_client_key);
+    free_key_ctx_bi(&check_client_key);
 
     /* Sanity check: unwrap and load client key (as "server") */
-    struct buffer test_metadata = alloc_buf_gc(TLS_CRYPT_V2_MAX_METADATA_LEN, &gc);
-    struct key2 test_client_key2 = { 0 };
+    struct buffer check_metadata = alloc_buf_gc(TLS_CRYPT_V2_MAX_METADATA_LEN, &gc);
+    struct key2 check_client_key2 = { 0 };
     free_key_ctx(&server_key);
     tls_crypt_v2_init_server_key(&server_key, false, server_key_file, server_key_inline);
     msg(D_GENKEY, "Testing server-side key loading...");
-    ASSERT(tls_crypt_v2_unwrap_client_key(&test_client_key2, &test_metadata,
-                                          test_wrapped_client_key, &server_key));
-    secure_memzero(&test_client_key2, sizeof(test_client_key2));
-    free_buf(&test_wrapped_client_key);
+    ASSERT(tls_crypt_v2_unwrap_client_key(&check_client_key2, &check_metadata,
+                                          check_wrapped_client_key, &server_key));
+    secure_memzero(&check_client_key2, sizeof(check_client_key2));
+    free_buf(&check_wrapped_client_key);
 
 cleanup:
     secure_memzero(&client_key, sizeof(client_key));
diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 322461e..a2f9f09 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -540,19 +540,19 @@
 static DWORD
 InterfaceLuid(const char *iface_name, PNET_LUID luid)
 {
-    NETIO_STATUS status;
+    NETIO_STATUS convert_status;
     LPWSTR wide_name = utf8to16(iface_name);
 
     if (wide_name)
     {
-        status = ConvertInterfaceAliasToLuid(wide_name, luid);
+        convert_status = ConvertInterfaceAliasToLuid(wide_name, luid);
         free(wide_name);
     }
     else
     {
-        status = ERROR_OUTOFMEMORY;
+        convert_status = ERROR_OUTOFMEMORY;
     }
-    return status;
+    return convert_status;
 }
 
 static BOOL
@@ -1174,8 +1174,8 @@
         goto out;
     }
 
-    SERVICE_STATUS status;
-    if (ControlService(dnssvc, SERVICE_CONTROL_PARAMCHANGE, &status) == 0)
+    SERVICE_STATUS control_status;
+    if (ControlService(dnssvc, SERVICE_CONTROL_PARAMCHANGE, &control_status) == 0)
     {
         MsgToEventLog(M_ERR, L"%S: ControlService call failed (%lu)", __func__, GetLastError());
         goto out;
@@ -3644,12 +3644,12 @@
 static DWORD WINAPI
 ServiceCtrlInteractive(DWORD ctrl_code, DWORD event, LPVOID data, LPVOID ctx)
 {
-    SERVICE_STATUS *status = ctx;
+    SERVICE_STATUS *svc_status = ctx;
     switch (ctrl_code)
     {
         case SERVICE_CONTROL_STOP:
-            status->dwCurrentState = SERVICE_STOP_PENDING;
-            ReportStatusToSCMgr(service, status);
+            svc_status->dwCurrentState = SERVICE_STOP_PENDING;
+            ReportStatusToSCMgr(service, svc_status);
             if (exit_event)
             {
                 SetEvent(exit_event);
diff --git a/tests/unit_tests/openvpn/test_push_update_msg.c b/tests/unit_tests/openvpn/test_push_update_msg.c
index 219b476..eb5b22c 100644
--- a/tests/unit_tests/openvpn/test_push_update_msg.c
+++ b/tests/unit_tests/openvpn/test_push_update_msg.c
@@ -350,8 +350,8 @@
 
     /* Message 1: first batch of routes, continuation 2 (more coming) */
     struct buffer buf1 = alloc_buf(512);
-    const char *msg1 = "PUSH_UPDATE, route 10.1.0.0 255.255.0.0, route 10.2.0.0 255.255.0.0, route 10.3.0.0 255.255.0.0,push-continuation 2";
-    buf_write(&buf1, msg1, strlen(msg1));
+    const char *cmsg1 = "PUSH_UPDATE, route 10.1.0.0 255.255.0.0, route 10.2.0.0 255.255.0.0, route 10.3.0.0 255.255.0.0,push-continuation 2";
+    buf_write(&buf1, cmsg1, strlen(cmsg1));
 
     assert_int_equal(process_incoming_push_msg(c, &buf1, c->options.pull, pull_permission_mask(c),
                                                &option_types_found),
@@ -360,8 +360,8 @@
 
     /* Message 2: more routes, continuation 2 (more coming) */
     struct buffer buf2 = alloc_buf(512);
-    const char *msg2 = "PUSH_UPDATE, route 10.4.0.0 255.255.0.0, route 10.5.0.0 255.255.0.0, route 10.6.0.0 255.255.0.0,push-continuation 2";
-    buf_write(&buf2, msg2, strlen(msg2));
+    const char *cmsg2 = "PUSH_UPDATE, route 10.4.0.0 255.255.0.0, route 10.5.0.0 255.255.0.0, route 10.6.0.0 255.255.0.0,push-continuation 2";
+    buf_write(&buf2, cmsg2, strlen(cmsg2));
 
     assert_int_equal(process_incoming_push_msg(c, &buf2, c->options.pull, pull_permission_mask(c),
                                                &option_types_found),
@@ -370,8 +370,8 @@
 
     /* Message 3: final batch of routes, continuation 1 (last message) */
     struct buffer buf3 = alloc_buf(512);
-    const char *msg3 = "PUSH_UPDATE, route 10.7.0.0 255.255.0.0, route 10.8.0.0 255.255.0.0, route 10.9.0.0 255.255.0.0,push-continuation 1";
-    buf_write(&buf3, msg3, strlen(msg3));
+    const char *cmsg3 = "PUSH_UPDATE, route 10.7.0.0 255.255.0.0, route 10.8.0.0 255.255.0.0, route 10.9.0.0 255.255.0.0,push-continuation 1";
+    buf_write(&buf3, cmsg3, strlen(cmsg3));
 
     assert_int_equal(process_incoming_push_msg(c, &buf3, c->options.pull, pull_permission_mask(c),
                                                &option_types_found),

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

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

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.