[tor-commits] [tor/release-0.3.2] Fix some shadowed-global warnings.
nickm at torproject.org
nickm at torproject.org
Wed Jan 3 15:09:26 UTC 2018
commit 1bc95633fbd9c27db87d81593242e85d08afe116
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed Jan 3 09:13:00 2018 -0500
Fix some shadowed-global warnings.
These are all about local variables shadowing global
functions. That isn't normally a problem, but at least one
compiler we care about seems to treat this as a case of -Wshadow
violation, so let's fix it.
Fixes bug 24634; bugfix on 0.3.2.1-alpha.
---
changes/bug24634 | 3 +++
src/or/hs_common.c | 14 +++++++-------
src/or/hs_service.c | 12 ++++++------
src/test/test_hs_common.c | 6 +++---
4 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/changes/bug24634 b/changes/bug24634
new file mode 100644
index 000000000..ac82b94fb
--- /dev/null
+++ b/changes/bug24634
@@ -0,0 +1,3 @@
+ o Minor bugfixes (compilation):
+ - Resolve a few shadowed-variable warnings in the onion service code.
+ Fixes bug 24634; bugfix on 0.3.2.1-alpha.
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index ad783a36f..a5cfaf03a 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -984,18 +984,18 @@ hs_build_address(const ed25519_public_key_t *key, uint8_t version,
link_specifier_t *
hs_link_specifier_dup(const link_specifier_t *lspec)
{
- link_specifier_t *dup = link_specifier_new();
- memcpy(dup, lspec, sizeof(*dup));
+ link_specifier_t *result = link_specifier_new();
+ memcpy(result, lspec, sizeof(*result));
/* The unrecognized field is a dynamic array so make sure to copy its
* content and not the pointer. */
link_specifier_setlen_un_unrecognized(
- dup, link_specifier_getlen_un_unrecognized(lspec));
- if (link_specifier_getlen_un_unrecognized(dup)) {
- memcpy(link_specifier_getarray_un_unrecognized(dup),
+ result, link_specifier_getlen_un_unrecognized(lspec));
+ if (link_specifier_getlen_un_unrecognized(result)) {
+ memcpy(link_specifier_getarray_un_unrecognized(result),
link_specifier_getconstarray_un_unrecognized(lspec),
- link_specifier_getlen_un_unrecognized(dup));
+ link_specifier_getlen_un_unrecognized(result));
}
- return dup;
+ return result;
}
/* From a given ed25519 public key pk and an optional secret, compute a
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index dd836bf84..45810c5c5 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -1190,9 +1190,9 @@ setup_desc_intro_point(const ed25519_keypair_t *signing_kp,
/* Copy link specifier(s). */
SMARTLIST_FOREACH_BEGIN(ip->base.link_specifiers,
const hs_desc_link_specifier_t *, ls) {
- hs_desc_link_specifier_t *dup = tor_malloc_zero(sizeof(*dup));
- link_specifier_copy(dup, ls);
- smartlist_add(desc_ip->link_specifiers, dup);
+ hs_desc_link_specifier_t *copy = tor_malloc_zero(sizeof(*copy));
+ link_specifier_copy(copy, ls);
+ smartlist_add(desc_ip->link_specifiers, copy);
} SMARTLIST_FOREACH_END(ls);
/* For a legacy intro point, we'll use an RSA/ed cross certificate. */
@@ -2276,15 +2276,15 @@ upload_descriptor_to_hsdir(const hs_service_t *service,
/* Logging so we know where it was sent. */
{
int is_next_desc = (service->desc_next == desc);
- const uint8_t *index = (is_next_desc) ? hsdir->hsdir_index->store_second:
- hsdir->hsdir_index->store_first;
+ const uint8_t *idx = (is_next_desc) ? hsdir->hsdir_index->store_second:
+ hsdir->hsdir_index->store_first;
log_info(LD_REND, "Service %s %s descriptor of revision %" PRIu64
" initiated upload request to %s with index %s",
safe_str_client(service->onion_address),
(is_next_desc) ? "next" : "current",
desc->desc->plaintext_data.revision_counter,
safe_str_client(node_describe(hsdir)),
- safe_str_client(hex_str((const char *) index, 32)));
+ safe_str_client(hex_str((const char *) idx, 32)));
}
/* XXX: Inform control port of the upload event (#20699). */
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index b9b76d15b..21daa58ab 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -971,12 +971,12 @@ helper_init_service(time_t now)
/* Helper function to set the RFC 1123 time string into t. */
static void
-set_consensus_times(const char *time, time_t *t)
+set_consensus_times(const char *timestr, time_t *t)
{
- tt_assert(time);
+ tt_assert(timestr);
tt_assert(t);
- int ret = parse_rfc1123_time(time, t);
+ int ret = parse_rfc1123_time(timestr, t);
tt_int_op(ret, OP_EQ, 0);
done:
More information about the tor-commits
mailing list