tor-commits
Threads by month
- ----- 2025 -----
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
July 2016
- 21 participants
- 1271 discussions
commit 2f3c79c9fad27cdb04ee50573a462f4f9530588e
Author: Isis Lovecruft <isis(a)torproject.org>
Date: Mon May 30 15:34:56 2016 +0000
Bump the Twisted version.
---
requirements.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/requirements.txt b/requirements.txt
index 9e4aac1..4591511 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,7 @@
Babel==0.9.6
BeautifulSoup==3.2.1
Mako==0.8.1
-Twisted==13.2.0
+Twisted==14.0.2
https://ipaddr-py.googlecode.com/files/ipaddr-2.1.10.tar.gz#sha1=c608450b07…
pycrypto==2.6.1
pyOpenSSL==0.14
1
0

[bridgedb/master] Update CI test matrix to test using Debian Stretch versions.
by isis@torproject.org 28 Jul '16
by isis@torproject.org 28 Jul '16
28 Jul '16
commit edddab56cf064b4080905ba29116574bb892e977
Author: Isis Lovecruft <isis(a)torproject.org>
Date: Mon May 2 16:15:59 2016 +0000
Update CI test matrix to test using Debian Stretch versions.
* FIXES #18949: https://bugs.torproject.org/18949
---
.travis.yml | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index b058d71..4717c23 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -35,22 +35,22 @@ env:
# https://github.com/pypa/virtualenv/issues/459
- PYTHON_EGG_CACHE="${HOME}/.python-eggs-$(echo $RANDOM$PPID$RANDOM | sha256sum | cut -d ' ' -f 1)"
matrix:
- # Debian Wheezy
- - TWISTED_VERSION=13.2.0 PYOPENSSL_VERSION=0.13.1
# Debian Jessie
- TWISTED_VERSION=14.0.2 PYOPENSSL_VERSION=0.14
+ # Debian Stretch
+ - TWISTED_VERSION=16.1.1 PYOPENSSL_VERSION=16.0.0
matrix:
include:
- - python: "2.7"
- env: TWISTED_VERSION=15.0.0 PYOPENSSL_VERSION=0.14
- python: "pypy"
env: TWISTED_VERSION=14.0.2 PYOPENSSL_VERSION=0.14
+ - python: "pypy"
+ env: TWISTED_VERSION=16.1.1 PYOPENSSL_VERSION=16.0.0
allow_failures:
- - python: "2.7"
- env: TWISTED_VERSION=15.0.0 PYOPENSSL_VERSION=0.14
- python: "pypy"
env: TWISTED_VERSION=14.0.2 PYOPENSSL_VERSION=0.14
+ - python: "pypy"
+ env: TWISTED_VERSION=16.1.1 PYOPENSSL_VERSION=16.0.0
fast_finish: true
before_install:
1
0

[bridgedb/master] Revise HTTPS DummyRequest test utility for changes in Twisted>14.0.2.
by isis@torproject.org 28 Jul '16
by isis@torproject.org 28 Jul '16
28 Jul '16
commit 22817ee11fd7d21cf38ee6050a9bcd3dd2b7849a
Author: Isis Lovecruft <isis(a)torproject.org>
Date: Mon May 2 16:16:40 2016 +0000
Revise HTTPS DummyRequest test utility for changes in Twisted>14.0.2.
---
test/https_helpers.py | 228 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 226 insertions(+), 2 deletions(-)
diff --git a/test/https_helpers.py b/test/https_helpers.py
index cc1ddfa..14755ec 100644
--- a/test/https_helpers.py
+++ b/test/https_helpers.py
@@ -13,6 +13,10 @@
import io
+from twisted.internet.defer import Deferred
+from twisted.internet.address import IPv4Address
+from twisted.web.http_headers import Headers
+from twisted.web.server import NOT_DONE_YET, Session
from twisted.web.test import requesthelper
from bridgedb.persistent import Conf
@@ -121,15 +125,232 @@ class DummyHTTPSDistributor(object):
return [self._bridge_class() for _ in range(self._bridgesPerResponseMin)]
-class DummyRequest(requesthelper.DummyRequest):
+class RequestHelperDummyRequest(object):
+ """
+ Represents a dummy or fake request.
+
+ Taken from Twisted-14.0.2 because this helper class changed in 16.0.0.
+
+ @ivar _finishedDeferreds: C{None} or a C{list} of L{Deferreds} which will
+ be called back with C{None} when C{finish} is called or which will be
+ errbacked if C{processingFailed} is called.
+
+ @type headers: C{dict}
+ @ivar headers: A mapping of header name to header value for all request
+ headers.
+
+ @type outgoingHeaders: C{dict}
+ @ivar outgoingHeaders: A mapping of header name to header value for all
+ response headers.
+
+ @type responseCode: C{int}
+ @ivar responseCode: The response code which was passed to
+ C{setResponseCode}.
+
+ @type written: C{list} of C{bytes}
+ @ivar written: The bytes which have been written to the request.
+ """
+ uri = b'http://dummy/'
+ method = b'GET'
+ client = None
+
+ def registerProducer(self, prod,s):
+ self.go = 1
+ while self.go:
+ prod.resumeProducing()
+
+ def unregisterProducer(self):
+ self.go = 0
+
+
+ def __init__(self, postpath, session=None):
+ self.sitepath = []
+ self.written = []
+ self.finished = 0
+ self.postpath = postpath
+ self.prepath = []
+ self.session = None
+ self.protoSession = session or Session(0, self)
+ self.args = {}
+ self.outgoingHeaders = {}
+ self.requestHeaders = Headers()
+ self.responseHeaders = Headers()
+ self.responseCode = None
+ self.headers = {}
+ self._finishedDeferreds = []
+ self._serverName = b"dummy"
+ self.clientproto = b"HTTP/1.0"
+
+ def getHeader(self, name):
+ """
+ Retrieve the value of a request header.
+
+ @type name: C{bytes}
+ @param name: The name of the request header for which to retrieve the
+ value. Header names are compared case-insensitively.
+
+ @rtype: C{bytes} or L{NoneType}
+ @return: The value of the specified request header.
+ """
+ return self.headers.get(name.lower(), None)
+
+
+ def getAllHeaders(self):
+ """
+ Retrieve all the values of the request headers as a dictionary.
+
+ @return: The entire C{headers} L{dict}.
+ """
+ return self.headers
+
+
+ def setHeader(self, name, value):
+ """TODO: make this assert on write() if the header is content-length
+ """
+ self.outgoingHeaders[name.lower()] = value
+
+ def getSession(self):
+ if self.session:
+ return self.session
+ assert not self.written, "Session cannot be requested after data has been written."
+ self.session = self.protoSession
+ return self.session
+
+
+ def render(self, resource):
+ """
+ Render the given resource as a response to this request.
+
+ This implementation only handles a few of the most common behaviors of
+ resources. It can handle a render method that returns a string or
+ C{NOT_DONE_YET}. It doesn't know anything about the semantics of
+ request methods (eg HEAD) nor how to set any particular headers.
+ Basically, it's largely broken, but sufficient for some tests at least.
+ It should B{not} be expanded to do all the same stuff L{Request} does.
+ Instead, L{DummyRequest} should be phased out and L{Request} (or some
+ other real code factored in a different way) used.
+ """
+ result = resource.render(self)
+ if result is NOT_DONE_YET:
+ return
+ self.write(result)
+ self.finish()
+
+
+ def write(self, data):
+ if not isinstance(data, bytes):
+ raise TypeError("write() only accepts bytes")
+ self.written.append(data)
+
+ def notifyFinish(self):
+ """
+ Return a L{Deferred} which is called back with C{None} when the request
+ is finished. This will probably only work if you haven't called
+ C{finish} yet.
+ """
+ finished = Deferred()
+ self._finishedDeferreds.append(finished)
+ return finished
+
+
+ def finish(self):
+ """
+ Record that the request is finished and callback and L{Deferred}s
+ waiting for notification of this.
+ """
+ self.finished = self.finished + 1
+ if self._finishedDeferreds is not None:
+ observers = self._finishedDeferreds
+ self._finishedDeferreds = None
+ for obs in observers:
+ obs.callback(None)
+
+
+ def processingFailed(self, reason):
+ """
+ Errback and L{Deferreds} waiting for finish notification.
+ """
+ if self._finishedDeferreds is not None:
+ observers = self._finishedDeferreds
+ self._finishedDeferreds = None
+ for obs in observers:
+ obs.errback(reason)
+
+
+ def addArg(self, name, value):
+ self.args[name] = [value]
+
+
+ def setResponseCode(self, code, message=None):
+ """
+ Set the HTTP status response code, but takes care that this is called
+ before any data is written.
+ """
+ assert not self.written, "Response code cannot be set after data has been written: %s." % "@@@@".join(self.written)
+ self.responseCode = code
+ self.responseMessage = message
+
+
+ def setLastModified(self, when):
+ assert not self.written, "Last-Modified cannot be set after data has been written: %s." % "@@@@".join(self.written)
+
+
+ def setETag(self, tag):
+ assert not self.written, "ETag cannot be set after data has been written: %s." % "@@@@".join(self.written)
+
+
+ def getClientIP(self):
+ """
+ Return the IPv4 address of the client which made this request, if there
+ is one, otherwise C{None}.
+ """
+ if isinstance(self.client, IPv4Address):
+ return self.client.host
+ return None
+
+
+ def getRequestHostname(self):
+ """
+ Get a dummy hostname associated to the HTTP request.
+
+ @rtype: C{bytes}
+ @returns: a dummy hostname
+ """
+ return self._serverName
+
+
+ def getHost(self):
+ """
+ Get a dummy transport's host.
+
+ @rtype: C{IPv4Address}
+ @returns: a dummy transport's host
+ """
+ return IPv4Address('TCP', '127.0.0.1', 80)
+
+
+ def getClient(self):
+ """
+ Stub to get the client doing the HTTP request.
+ This merely just ensures that this method exists here. Feel free to
+ extend it.
+ """
+
+
+class DummyRequest(RequestHelperDummyRequest):
"""Wrapper for :api:`twisted.test.requesthelper.DummyRequest` to add
redirect support.
"""
def __init__(self, *args, **kwargs):
- requesthelper.DummyRequest.__init__(self, *args, **kwargs)
+ RequestHelperDummyRequest.__init__(self, *args, **kwargs)
self.redirect = self._redirect(self)
self.content = io.StringIO()
+ self.headers = {} # Needed for Twisted>14.0.2
+ #self.outgoingHeaders = {}
+ #self.responseHeaders = Headers()
+ #self.requestHeaders = Headers()
+
def writeContent(self, data):
"""Add some **data** to the faked body of this request.
@@ -159,3 +380,6 @@ class DummyRequest(requesthelper.DummyRequest):
newRequest = type(request)
newRequest.uri = request.uri
return newRequest
+
+
+#DummyRequest = RequestHelperDummyRequest
1
0

28 Jul '16
commit 6164c627a2653a81bcfa4197288b23a504f979e9
Merge: 0bb6014 2f3c79c
Author: Isis Lovecruft <isis(a)torproject.org>
Date: Mon May 30 16:06:46 2016 +0000
Merge branch 'fix/18949' into develop
.travis.yml | 12 +--
requirements.txt | 2 +-
test/https_helpers.py | 228 +++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 233 insertions(+), 9 deletions(-)
1
0
commit dffc6910b11d88544a93c3e3e80c1155f998f561
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Thu Jul 28 11:24:03 2016 -0400
Three more -Wshadow fixes.
---
src/common/util.c | 10 +++++-----
src/or/circuitbuild.c | 9 +++++----
src/or/rephist.c | 12 ++++++------
3 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/common/util.c b/src/common/util.c
index 0c04eb1..c7dd2a8 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -279,21 +279,21 @@ tor_reallocarray_(void *ptr, size_t sz1, size_t sz2 DMALLOC_PARAMS)
char *
tor_strdup_(const char *s DMALLOC_PARAMS)
{
- char *dup;
+ char *duplicate;
tor_assert(s);
#ifdef USE_DMALLOC
- dup = dmalloc_strdup(file, line, s, 0);
+ duplicate = dmalloc_strdup(file, line, s, 0);
#else
- dup = strdup(s);
+ duplicate = strdup(s);
#endif
- if (PREDICT_UNLIKELY(dup == NULL)) {
+ if (PREDICT_UNLIKELY(duplicate == NULL)) {
/* LCOV_EXCL_START */
log_err(LD_MM,"Out of memory on strdup(). Dying.");
exit(1);
/* LCOV_EXCL_STOP */
}
- return dup;
+ return duplicate;
}
/** Allocate and return a new string containing the first <b>n</b>
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index f3eab91..b07ddab 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1881,7 +1881,8 @@ choose_good_exit_server(uint8_t purpose,
/** Log a warning if the user specified an exit for the circuit that
* has been excluded from use by ExcludeNodes or ExcludeExitNodes. */
static void
-warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
+warn_if_last_router_excluded(origin_circuit_t *circ,
+ const extend_info_t *exit_ei)
{
const or_options_t *options = get_options();
routerset_t *rs = options->ExcludeNodes;
@@ -1928,13 +1929,13 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
break;
}
- if (routerset_contains_extendinfo(rs, exit)) {
+ if (routerset_contains_extendinfo(rs, exit_ei)) {
/* We should never get here if StrictNodes is set to 1. */
if (options->StrictNodes) {
log_warn(LD_BUG, "Using %s '%s' which is listed in ExcludeNodes%s, "
"even though StrictNodes is set. Please report. "
"(Circuit purpose: %s)",
- description, extend_info_describe(exit),
+ description, extend_info_describe(exit_ei),
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
circuit_purpose_to_string(purpose));
} else {
@@ -1943,7 +1944,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
"prevent this (and possibly break your Tor functionality), "
"set the StrictNodes configuration option. "
"(Circuit purpose: %s)",
- description, extend_info_describe(exit),
+ description, extend_info_describe(exit_ei),
rs==options->ExcludeNodes?"":" or ExcludeExitNodes",
circuit_purpose_to_string(purpose));
}
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 0eab5e0..6a54904 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2374,7 +2374,7 @@ rep_hist_reset_buffer_stats(time_t now)
if (!circuits_for_buffer_stats)
circuits_for_buffer_stats = smartlist_new();
SMARTLIST_FOREACH(circuits_for_buffer_stats, circ_buffer_stats_t *,
- stat, tor_free(stat));
+ stats, tor_free(stats));
smartlist_clear(circuits_for_buffer_stats);
start_of_buffer_stats_interval = now;
}
@@ -2415,15 +2415,15 @@ rep_hist_format_buffer_stats(time_t now)
buffer_stats_compare_entries_);
i = 0;
SMARTLIST_FOREACH_BEGIN(circuits_for_buffer_stats,
- circ_buffer_stats_t *, stat)
+ circ_buffer_stats_t *, stats)
{
int share = i++ * SHARES / number_of_circuits;
- processed_cells[share] += stat->processed_cells;
- queued_cells[share] += stat->mean_num_cells_in_queue;
- time_in_queue[share] += stat->mean_time_cells_in_queue;
+ processed_cells[share] += stats->processed_cells;
+ queued_cells[share] += stats->mean_num_cells_in_queue;
+ time_in_queue[share] += stats->mean_time_cells_in_queue;
circs_in_share[share]++;
}
- SMARTLIST_FOREACH_END(stat);
+ SMARTLIST_FOREACH_END(stats);
}
/* Write deciles to strings. */
1
0

[trunnel/master] Include trunnel-local.h before any standard C headers
by nickm@torproject.org 28 Jul '16
by nickm@torproject.org 28 Jul '16
28 Jul '16
commit 26713665d320b5e758dee8c52ffeaf330283c414
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Thu Jul 28 10:49:25 2016 -0400
Include trunnel-local.h before any standard C headers
This way, trunnel-local can do things like setting _FILE_OFFSET_BITS
other things that need to happen before the standards headers.
---
lib/trunnel/__init__.py | 2 +-
lib/trunnel/data/trunnel-impl.h | 6 +++---
lib/trunnel/data/trunnel.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/trunnel/__init__.py b/lib/trunnel/__init__.py
index 2633dfd..ec7b001 100644
--- a/lib/trunnel/__init__.py
+++ b/lib/trunnel/__init__.py
@@ -3,4 +3,4 @@
# a package.
#
-__version__ = "1.4.5"
+__version__ = "1.4.6"
diff --git a/lib/trunnel/data/trunnel-impl.h b/lib/trunnel/data/trunnel-impl.h
index e6de363..98dce21 100644
--- a/lib/trunnel/data/trunnel-impl.h
+++ b/lib/trunnel/data/trunnel-impl.h
@@ -7,12 +7,12 @@
#ifndef TRUNNEL_IMPL_H_INCLUDED_
#define TRUNNEL_IMPL_H_INCLUDED_
-#include "trunnel.h"
-#include <assert.h>
-#include <string.h>
#ifdef TRUNNEL_LOCAL_H
#include "trunnel-local.h"
#endif
+#include "trunnel.h"
+#include <assert.h>
+#include <string.h>
#if defined(_MSC_VER) && (_MSC_VER < 1600)
#define uint8_t unsigned char
diff --git a/lib/trunnel/data/trunnel.c b/lib/trunnel/data/trunnel.c
index 285a310..b533743 100644
--- a/lib/trunnel/data/trunnel.c
+++ b/lib/trunnel/data/trunnel.c
@@ -6,9 +6,9 @@
* See trunnel-impl.h for documentation of these functions.
*/
+#include "trunnel-impl.h"
#include <stdlib.h>
#include <string.h>
-#include "trunnel-impl.h"
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
1
0

[tor/master] Fix a set of variable-shadowing warnings in curve25519-donna.c
by nickm@torproject.org 28 Jul '16
by nickm@torproject.org 28 Jul '16
28 Jul '16
commit 0390e1a60cb91fa581ec568879bf300224db6322
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Thu Jul 28 10:03:29 2016 -0400
Fix a set of variable-shadowing warnings in curve25519-donna.c
---
src/ext/curve25519_donna/curve25519-donna.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/ext/curve25519_donna/curve25519-donna.c b/src/ext/curve25519_donna/curve25519-donna.c
index 5a0c340..1c5a27a 100644
--- a/src/ext/curve25519_donna/curve25519-donna.c
+++ b/src/ext/curve25519_donna/curve25519-donna.c
@@ -483,7 +483,6 @@ fcontract(u8 *output, limb *input_limbs) {
int i;
int j;
s32 input[10];
- s32 mask;
/* |input_limbs[i]| < 2^26, so it's valid to convert to an s32. */
for (i = 0; i < 10; i++) {
@@ -572,7 +571,7 @@ fcontract(u8 *output, limb *input_limbs) {
/* It still remains the case that input might be between 2^255-19 and 2^255.
* In this case, input[1..9] must take their maximum value and input[0] must
* be >= (2^255-19) & 0x3ffffff, which is 0x3ffffed. */
- mask = s32_gte(input[0], 0x3ffffed);
+ s32 mask = s32_gte(input[0], 0x3ffffed);
for (i = 1; i < 10; i++) {
if ((i & 1) == 1) {
mask &= s32_eq(input[i], 0x1ffffff);
1
0
commit 9fe6fea1cceb39fc415ad813020bbd863121e0c9
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Thu Jul 28 10:22:10 2016 -0400
Fix a huge pile of -Wshadow warnings.
These appeared on some of the Jenkins platforms. Apparently some
GCCs care when you shadow globals, and some don't.
---
src/common/compat.c | 16 ++++++------
src/common/crypto.c | 6 ++---
src/common/log.c | 4 +--
src/common/torgzip.c | 14 +++++-----
src/common/util.c | 65 +++++++++++++++++++++++-----------------------
src/ext/timeouts/timeout.c | 6 ++---
src/or/addressmap.c | 24 ++++++++---------
src/or/circuitbuild.c | 42 +++++++++++++++---------------
src/or/circuitstats.c | 10 +++----
src/or/config.c | 12 ++++-----
src/or/connection_edge.c | 16 +++++++-----
src/or/control.c | 6 ++---
src/or/dirvote.c | 3 ---
src/or/policies.c | 8 +++---
src/or/relay.c | 8 +++---
src/or/rendclient.c | 6 ++---
src/or/rephist.c | 19 +++++++-------
src/or/routerkeys.c | 12 ++++-----
src/or/shared_random.c | 10 +++----
src/test/test_address.c | 8 +++---
src/test/test_util.c | 6 ++---
21 files changed, 151 insertions(+), 150 deletions(-)
diff --git a/src/common/compat.c b/src/common/compat.c
index 081490d..e0807e4 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1181,10 +1181,10 @@ tor_open_socket,(int domain, int type, int protocol))
/** Mockable wrapper for connect(). */
MOCK_IMPL(tor_socket_t,
-tor_connect_socket,(tor_socket_t socket,const struct sockaddr *address,
+tor_connect_socket,(tor_socket_t sock, const struct sockaddr *address,
socklen_t address_len))
{
- return connect(socket,address,address_len);
+ return connect(sock,address,address_len);
}
/** As socket(), but creates a nonblocking socket and
@@ -1359,31 +1359,31 @@ get_n_open_sockets(void)
/** Mockable wrapper for getsockname(). */
MOCK_IMPL(int,
-tor_getsockname,(tor_socket_t socket, struct sockaddr *address,
+tor_getsockname,(tor_socket_t sock, struct sockaddr *address,
socklen_t *address_len))
{
- return getsockname(socket, address, address_len);
+ return getsockname(sock, address, address_len);
}
/** Turn <b>socket</b> into a nonblocking socket. Return 0 on success, -1
* on failure.
*/
int
-set_socket_nonblocking(tor_socket_t socket)
+set_socket_nonblocking(tor_socket_t sock)
{
#if defined(_WIN32)
unsigned long nonblocking = 1;
- ioctlsocket(socket, FIONBIO, (unsigned long*) &nonblocking);
+ ioctlsocket(sock, FIONBIO, (unsigned long*) &nonblocking);
#else
int flags;
- flags = fcntl(socket, F_GETFL, 0);
+ flags = fcntl(sock, F_GETFL, 0);
if (flags == -1) {
log_warn(LD_NET, "Couldn't get file status flags: %s", strerror(errno));
return -1;
}
flags |= O_NONBLOCK;
- if (fcntl(socket, F_SETFL, flags) == -1) {
+ if (fcntl(sock, F_SETFL, flags) == -1) {
log_warn(LD_NET, "Couldn't set file status flags: %s", strerror(errno));
return -1;
}
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 1c5b599..b87023f 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -3099,8 +3099,8 @@ crypto_rand_double(void)
{
/* We just use an unsigned int here; we don't really care about getting
* more than 32 bits of resolution */
- unsigned int uint;
- crypto_rand((char*)&uint, sizeof(uint));
+ unsigned int u;
+ crypto_rand((char*)&u, sizeof(u));
#if SIZEOF_INT == 4
#define UINT_MAX_AS_DOUBLE 4294967296.0
#elif SIZEOF_INT == 8
@@ -3108,7 +3108,7 @@ crypto_rand_double(void)
#else
#error SIZEOF_INT is neither 4 nor 8
#endif
- return ((double)uint) / UINT_MAX_AS_DOUBLE;
+ return ((double)u) / UINT_MAX_AS_DOUBLE;
}
/** Generate and return a new random hostname starting with <b>prefix</b>,
diff --git a/src/common/log.c b/src/common/log.c
index 51309aa..cb62a37 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -1071,13 +1071,13 @@ mark_logs_temp(void)
*/
int
add_file_log(const log_severity_list_t *severity, const char *filename,
- const int truncate)
+ const int truncate_log)
{
int fd;
logfile_t *lf;
int open_flags = O_WRONLY|O_CREAT;
- open_flags |= truncate ? O_TRUNC : O_APPEND;
+ open_flags |= truncate_log ? O_TRUNC : O_APPEND;
fd = tor_open_cloexec(filename, open_flags, 0644);
if (fd<0)
diff --git a/src/common/torgzip.c b/src/common/torgzip.c
index 331bb5a..3353f0e 100644
--- a/src/common/torgzip.c
+++ b/src/common/torgzip.c
@@ -418,13 +418,13 @@ struct tor_zlib_state_t {
* <b>compress</b>, it's for compression; otherwise it's for
* decompression. */
tor_zlib_state_t *
-tor_zlib_new(int compress, compress_method_t method,
+tor_zlib_new(int compress_, compress_method_t method,
zlib_compression_level_t compression_level)
{
tor_zlib_state_t *out;
int bits, memlevel;
- if (! compress) {
+ if (! compress_) {
/* use this setting for decompression, since we might have the
* max number of window bits */
compression_level = HIGH_COMPRESSION;
@@ -434,10 +434,10 @@ tor_zlib_new(int compress, compress_method_t method,
out->stream.zalloc = Z_NULL;
out->stream.zfree = Z_NULL;
out->stream.opaque = NULL;
- out->compress = compress;
+ out->compress = compress_;
bits = method_bits(method, compression_level);
memlevel = get_memlevel(compression_level);
- if (compress) {
+ if (compress_) {
if (deflateInit2(&out->stream, Z_BEST_COMPRESSION, Z_DEFLATED,
bits, memlevel,
Z_DEFAULT_STRATEGY) != Z_OK)
@@ -446,7 +446,7 @@ tor_zlib_new(int compress, compress_method_t method,
if (inflateInit2(&out->stream, bits) != Z_OK)
goto err; // LCOV_EXCL_LINE
}
- out->allocation = tor_zlib_state_size_precalc(!compress, bits, memlevel);
+ out->allocation = tor_zlib_state_size_precalc(!compress_, bits, memlevel);
total_zlib_allocation += out->allocation;
@@ -540,13 +540,13 @@ tor_zlib_free(tor_zlib_state_t *state)
/** Return an approximate number of bytes used in RAM to hold a state with
* window bits <b>windowBits</b> and compression level 'memlevel' */
static size_t
-tor_zlib_state_size_precalc(int inflate, int windowbits, int memlevel)
+tor_zlib_state_size_precalc(int inflate_, int windowbits, int memlevel)
{
windowbits &= 15;
#define A_FEW_KILOBYTES 2048
- if (inflate) {
+ if (inflate_) {
/* From zconf.h:
"The memory requirements for inflate are (in bytes) 1 << windowBits
diff --git a/src/common/util.c b/src/common/util.c
index 2369c5f..0c04eb1 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -305,17 +305,17 @@ tor_strdup_(const char *s DMALLOC_PARAMS)
char *
tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
{
- char *dup;
+ char *duplicate;
tor_assert(s);
tor_assert(n < SIZE_T_CEILING);
- dup = tor_malloc_((n+1) DMALLOC_FN_ARGS);
+ duplicate = tor_malloc_((n+1) DMALLOC_FN_ARGS);
/* Performance note: Ordinarily we prefer strlcpy to strncpy. But
* this function gets called a whole lot, and platform strncpy is
* much faster than strlcpy when strlen(s) is much longer than n.
*/
- strncpy(dup, s, n);
- dup[n]='\0';
- return dup;
+ strncpy(duplicate, s, n);
+ duplicate[n]='\0';
+ return duplicate;
}
/** Allocate a chunk of <b>len</b> bytes, with the same contents as the
@@ -323,12 +323,12 @@ tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
void *
tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS)
{
- char *dup;
+ char *duplicate;
tor_assert(len < SIZE_T_CEILING);
tor_assert(mem);
- dup = tor_malloc_(len DMALLOC_FN_ARGS);
- memcpy(dup, mem, len);
- return dup;
+ duplicate = tor_malloc_(len DMALLOC_FN_ARGS);
+ memcpy(duplicate, mem, len);
+ return duplicate;
}
/** As tor_memdup(), but add an extra 0 byte at the end of the resulting
@@ -336,13 +336,13 @@ tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS)
void *
tor_memdup_nulterm_(const void *mem, size_t len DMALLOC_PARAMS)
{
- char *dup;
+ char *duplicate;
tor_assert(len < SIZE_T_CEILING+1);
tor_assert(mem);
- dup = tor_malloc_(len+1 DMALLOC_FN_ARGS);
- memcpy(dup, mem, len);
- dup[len] = '\0';
- return dup;
+ duplicate = tor_malloc_(len+1 DMALLOC_FN_ARGS);
+ memcpy(duplicate, mem, len);
+ duplicate[len] = '\0';
+ return duplicate;
}
/** Helper for places that need to take a function pointer to the right
@@ -556,7 +556,7 @@ sample_laplace_distribution(double mu, double b, double p)
* The epsilon value must be between ]0.0, 1.0]. delta_f must be greater
* than 0. */
int64_t
-add_laplace_noise(int64_t signal, double random, double delta_f,
+add_laplace_noise(int64_t signal_, double random_, double delta_f,
double epsilon)
{
int64_t noise;
@@ -569,15 +569,15 @@ add_laplace_noise(int64_t signal, double random, double delta_f,
/* Just add noise, no further signal */
noise = sample_laplace_distribution(0.0,
delta_f / epsilon,
- random);
+ random_);
/* Clip (signal + noise) to [INT64_MIN, INT64_MAX] */
- if (noise > 0 && INT64_MAX - noise < signal)
+ if (noise > 0 && INT64_MAX - noise < signal_)
return INT64_MAX;
- else if (noise < 0 && INT64_MIN - noise > signal)
+ else if (noise < 0 && INT64_MIN - noise > signal_)
return INT64_MIN;
else
- return signal + noise;
+ return signal_ + noise;
}
/* Helper: return greatest common divisor of a,b */
@@ -638,12 +638,12 @@ n_bits_set_u8(uint8_t v)
void
tor_strstrip(char *s, const char *strip)
{
- char *read = s;
- while (*read) {
- if (strchr(strip, *read)) {
- ++read;
+ char *readp = s;
+ while (*readp) {
+ if (strchr(strip, *readp)) {
+ ++readp;
} else {
- *s++ = *read++;
+ *s++ = *readp++;
}
}
*s = '\0';
@@ -1559,11 +1559,12 @@ tv_to_msec(const struct timeval *tv)
#define IS_LEAPYEAR(y) (!(y % 4) && ((y % 100) || !(y % 400)))
/** Helper: Return the number of leap-days between Jan 1, y1 and Jan 1, y2. */
static int
-n_leapdays(int y1, int y2)
+n_leapdays(int year1, int year2)
{
- --y1;
- --y2;
- return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400);
+ --year1;
+ --year2;
+ return (year2/4 - year1/4) - (year2/100 - year1/100)
+ + (year2/400 - year1/400);
}
/** Number of days per month in non-leap year; used by tor_timegm and
* parse_rfc1123_time. */
@@ -5688,7 +5689,7 @@ tor_weak_random_range(tor_weak_rng_t *rng, int32_t top)
int64_t
clamp_double_to_int64(double number)
{
- int exp;
+ int exponent;
/* NaN is a special case that can't be used with the logic below. */
if (isnan(number)) {
@@ -5702,14 +5703,14 @@ clamp_double_to_int64(double number)
* magnitude of number is strictly less than 2^exp.
*
* If number is infinite, the call to frexp is legal but the contents of
- * exp are unspecified. */
- frexp(number, &exp);
+ * are exponent unspecified. */
+ frexp(number, &exponent);
/* If the magnitude of number is strictly less than 2^63, the truncated
* version of number is guaranteed to be representable. The only
* representable integer for which this is not the case is INT64_MIN, but
* it is covered by the logic below. */
- if (isfinite(number) && exp <= 63) {
+ if (isfinite(number) && exponent <= 63) {
return (int64_t)number;
}
diff --git a/src/ext/timeouts/timeout.c b/src/ext/timeouts/timeout.c
index bd463a7..713ec21 100644
--- a/src/ext/timeouts/timeout.c
+++ b/src/ext/timeouts/timeout.c
@@ -299,9 +299,9 @@ TIMEOUT_PUBLIC void timeouts_del(struct timeouts *T, struct timeout *to) {
TOR_TAILQ_REMOVE(to->pending, to, tqe);
if (to->pending != &T->expired && TOR_TAILQ_EMPTY(to->pending)) {
- ptrdiff_t index = to->pending - &T->wheel[0][0];
- int wheel = (int) (index / WHEEL_LEN);
- int slot = index % WHEEL_LEN;
+ ptrdiff_t index_ = to->pending - &T->wheel[0][0];
+ int wheel = (int) (index_ / WHEEL_LEN);
+ int slot = index_ % WHEEL_LEN;
T->pending[wheel] &= ~(WHEEL_C(1) << slot);
}
diff --git a/src/or/addressmap.c b/src/or/addressmap.c
index 047a863..f7544ab 100644
--- a/src/or/addressmap.c
+++ b/src/or/addressmap.c
@@ -264,18 +264,18 @@ addressmap_clear_invalid_automaps(const or_options_t *options)
clear_all = 1; /* This should be impossible, but let's be sure. */
STRMAP_FOREACH_MODIFY(addressmap, src_address, addressmap_entry_t *, ent) {
- int remove = clear_all;
+ int remove_this = clear_all;
if (ent->source != ADDRMAPSRC_AUTOMAP)
continue; /* not an automap mapping. */
- if (!remove) {
- remove = ! addressmap_address_should_automap(src_address, options);
+ if (!remove_this) {
+ remove_this = ! addressmap_address_should_automap(src_address, options);
}
- if (!remove && ! address_is_in_virtual_range(ent->new_address))
- remove = 1;
+ if (!remove_this && ! address_is_in_virtual_range(ent->new_address))
+ remove_this = 1;
- if (remove) {
+ if (remove_this) {
addressmap_ent_remove(src_address, ent);
MAP_DEL_CURRENT(src_address);
}
@@ -896,10 +896,10 @@ addressmap_get_virtual_address(int type)
tor_assert(addressmap);
if (type == RESOLVED_TYPE_HOSTNAME) {
- char rand[10];
+ char rand_bytes[10];
do {
- crypto_rand(rand, sizeof(rand));
- base32_encode(buf,sizeof(buf),rand,sizeof(rand));
+ crypto_rand(rand_bytes, sizeof(rand_bytes));
+ base32_encode(buf,sizeof(buf),rand_bytes,sizeof(rand_bytes));
strlcat(buf, ".virtual", sizeof(buf));
} while (strmap_get(addressmap, buf));
return tor_strdup(buf);
@@ -1107,11 +1107,11 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
smartlist_add_asprintf(sl, "%s%s %s%s NEVER",
src_wc, key, dst_wc, val->new_address);
else {
- char time[ISO_TIME_LEN+1];
- format_iso_time(time, val->expires);
+ char isotime[ISO_TIME_LEN+1];
+ format_iso_time(isotime, val->expires);
smartlist_add_asprintf(sl, "%s%s %s%s \"%s\"",
src_wc, key, dst_wc, val->new_address,
- time);
+ isotime);
}
} else {
smartlist_add_asprintf(sl, "%s%s %s%s",
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index dab378f..f3eab91 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -457,14 +457,14 @@ origin_circuit_init(uint8_t purpose, int flags)
* it's not open already.
*/
origin_circuit_t *
-circuit_establish_circuit(uint8_t purpose, extend_info_t *exit, int flags)
+circuit_establish_circuit(uint8_t purpose, extend_info_t *exit_ei, int flags)
{
origin_circuit_t *circ;
int err_reason = 0;
circ = origin_circuit_init(purpose, flags);
- if (onion_pick_cpath_exit(circ, exit) < 0 ||
+ if (onion_pick_cpath_exit(circ, exit_ei) < 0 ||
onion_populate_cpath(circ) < 0) {
circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_NOPATH);
return NULL;
@@ -1433,7 +1433,7 @@ onionskin_answer(or_circuit_t *circ,
* to handle the desired path length, return -1.
*/
static int
-new_route_len(uint8_t purpose, extend_info_t *exit, smartlist_t *nodes)
+new_route_len(uint8_t purpose, extend_info_t *exit_ei, smartlist_t *nodes)
{
int num_acceptable_routers;
int routelen;
@@ -1441,7 +1441,7 @@ new_route_len(uint8_t purpose, extend_info_t *exit, smartlist_t *nodes)
tor_assert(nodes);
routelen = DEFAULT_ROUTE_LEN;
- if (exit &&
+ if (exit_ei &&
purpose != CIRCUIT_PURPOSE_TESTING &&
purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO)
routelen++;
@@ -1957,7 +1957,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
* router (or use <b>exit</b> if provided). Store these in the
* cpath. Return 0 if ok, -1 if circuit should be closed. */
static int
-onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
+onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
{
cpath_build_state_t *state = circ->build_state;
@@ -1965,17 +1965,17 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
log_debug(LD_CIRC, "Launching a one-hop circuit for dir tunnel.");
state->desired_path_len = 1;
} else {
- int r = new_route_len(circ->base_.purpose, exit, nodelist_get_list());
+ int r = new_route_len(circ->base_.purpose, exit_ei, nodelist_get_list());
if (r < 1) /* must be at least 1 */
return -1;
state->desired_path_len = r;
}
- if (exit) { /* the circuit-builder pre-requested one */
- warn_if_last_router_excluded(circ, exit);
+ if (exit_ei) { /* the circuit-builder pre-requested one */
+ warn_if_last_router_excluded(circ, exit_ei);
log_info(LD_CIRC,"Using requested exit node '%s'",
- extend_info_describe(exit));
- exit = extend_info_dup(exit);
+ extend_info_describe(exit_ei));
+ exit_ei = extend_info_dup(exit_ei);
} else { /* we have to decide one */
const node_t *node =
choose_good_exit_server(circ->base_.purpose, state->need_uptime,
@@ -1984,10 +1984,10 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
log_warn(LD_CIRC,"Failed to choose an exit server");
return -1;
}
- exit = extend_info_from_node(node, 0);
- tor_assert(exit);
+ exit_ei = extend_info_from_node(node, 0);
+ tor_assert(exit_ei);
}
- state->chosen_exit = exit;
+ state->chosen_exit = exit_ei;
return 0;
}
@@ -1996,19 +1996,19 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
* the caller will do this if it wants to.
*/
int
-circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit)
+circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
{
cpath_build_state_t *state;
- tor_assert(exit);
+ tor_assert(exit_ei);
tor_assert(circ);
state = circ->build_state;
tor_assert(state);
extend_info_free(state->chosen_exit);
- state->chosen_exit = extend_info_dup(exit);
+ state->chosen_exit = extend_info_dup(exit_ei);
++circ->build_state->desired_path_len;
- onion_append_hop(&circ->cpath, exit);
+ onion_append_hop(&circ->cpath, exit_ei);
return 0;
}
@@ -2017,18 +2017,18 @@ circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit)
* send the next extend cell to begin connecting to that hop.
*/
int
-circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit)
+circuit_extend_to_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
{
int err_reason = 0;
- warn_if_last_router_excluded(circ, exit);
+ warn_if_last_router_excluded(circ, exit_ei);
tor_gettimeofday(&circ->base_.timestamp_began);
- circuit_append_new_exit(circ, exit);
+ circuit_append_new_exit(circ, exit_ei);
circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
if ((err_reason = circuit_send_next_onion_skin(circ))<0) {
log_warn(LD_CIRC, "Couldn't extend circuit to new point %s.",
- extend_info_describe(exit));
+ extend_info_describe(exit_ei));
circuit_mark_for_close(TO_CIRCUIT(circ), -err_reason);
return -1;
}
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index 9ac2d56..f4db64e 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -578,18 +578,18 @@ circuit_build_times_rewind_history(circuit_build_times_t *cbt, int n)
* array is full.
*/
int
-circuit_build_times_add_time(circuit_build_times_t *cbt, build_time_t time)
+circuit_build_times_add_time(circuit_build_times_t *cbt, build_time_t btime)
{
- if (time <= 0 || time > CBT_BUILD_TIME_MAX) {
+ if (btime <= 0 || btime > CBT_BUILD_TIME_MAX) {
log_warn(LD_BUG, "Circuit build time is too large (%u)."
- "This is probably a bug.", time);
+ "This is probably a bug.", btime);
tor_fragile_assert();
return -1;
}
- log_debug(LD_CIRC, "Adding circuit build time %u", time);
+ log_debug(LD_CIRC, "Adding circuit build time %u", btime);
- cbt->circuit_build_times[cbt->build_times_idx] = time;
+ cbt->circuit_build_times[cbt->build_times_idx] = btime;
cbt->build_times_idx = (cbt->build_times_idx + 1) % CBT_NCIRCUITS_TO_OBSERVE;
if (cbt->total_build_times < CBT_NCIRCUITS_TO_OBSERVE)
cbt->total_build_times++;
diff --git a/src/or/config.c b/src/or/config.c
index fb2ab5a..64c9796 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5073,7 +5073,7 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
config_line_t *opt;
int ok;
smartlist_t *elts;
- int daemon =
+ int run_as_daemon =
#ifdef _WIN32
0;
#else
@@ -5134,7 +5134,7 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
int err = smartlist_len(elts) &&
!strcasecmp(smartlist_get(elts,0), "stderr");
if (!validate_only) {
- if (daemon) {
+ if (run_as_daemon) {
log_warn(LD_CONFIG,
"Can't log to %s with RunAsDaemon set; skipping stdout",
err?"stderr":"stdout");
@@ -5163,19 +5163,19 @@ options_init_logs(const or_options_t *old_options, or_options_t *options,
char *fname = expand_filename(smartlist_get(elts, 1));
/* Truncate if TruncateLogFile is set and we haven't seen this option
line before. */
- int truncate = 0;
+ int truncate_log = 0;
if (options->TruncateLogFile) {
- truncate = 1;
+ truncate_log = 1;
if (old_options) {
config_line_t *opt2;
for (opt2 = old_options->Logs; opt2; opt2 = opt2->next)
if (!strcmp(opt->value, opt2->value)) {
- truncate = 0;
+ truncate_log = 0;
break;
}
}
}
- if (add_file_log(severity, fname, truncate) < 0) {
+ if (add_file_log(severity, fname, truncate_log) < 0) {
log_warn(LD_CONFIG, "Couldn't open file for 'Log %s': %s",
opt->value, strerror(errno));
ok = 0;
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index cb79de6..0ef5310 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -3333,19 +3333,20 @@ connection_edge_is_rendezvous_stream(edge_connection_t *conn)
return 0;
}
-/** Return 1 if router <b>exit</b> is likely to allow stream <b>conn</b>
+/** Return 1 if router <b>exit_node</b> is likely to allow stream <b>conn</b>
* to exit from it, or 0 if it probably will not allow it.
* (We might be uncertain if conn's destination address has not yet been
* resolved.)
*/
int
-connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
+connection_ap_can_use_exit(const entry_connection_t *conn,
+ const node_t *exit_node)
{
const or_options_t *options = get_options();
tor_assert(conn);
tor_assert(conn->socks_request);
- tor_assert(exit);
+ tor_assert(exit_node);
/* If a particular exit node has been requested for the new connection,
* make sure the exit node of the existing circuit matches exactly.
@@ -3354,7 +3355,7 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
const node_t *chosen_exit =
node_get_by_nickname(conn->chosen_exit_name, 1);
if (!chosen_exit || tor_memneq(chosen_exit->identity,
- exit->identity, DIGEST_LEN)) {
+ exit_node->identity, DIGEST_LEN)) {
/* doesn't match */
// log_debug(LD_APP,"Requested node '%s', considering node '%s'. No.",
// conn->chosen_exit_name, exit->nickname);
@@ -3379,7 +3380,8 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
tor_addr_make_null(&addr, AF_INET);
addrp = &addr;
}
- r = compare_tor_addr_to_node_policy(addrp, conn->socks_request->port,exit);
+ r = compare_tor_addr_to_node_policy(addrp, conn->socks_request->port,
+ exit_node);
if (r == ADDR_POLICY_REJECTED)
return 0; /* We know the address, and the exit policy rejects it. */
if (r == ADDR_POLICY_PROBABLY_REJECTED && !conn->chosen_exit_name)
@@ -3388,10 +3390,10 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
* this node, err on the side of caution. */
} else if (SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command)) {
/* Don't send DNS requests to non-exit servers by default. */
- if (!conn->chosen_exit_name && node_exit_policy_rejects_all(exit))
+ if (!conn->chosen_exit_name && node_exit_policy_rejects_all(exit_node))
return 0;
}
- if (routerset_contains_node(options->ExcludeExitNodesUnion_, exit)) {
+ if (routerset_contains_node(options->ExcludeExitNodesUnion_, exit_node)) {
/* Not a suitable exit. Refuse it. */
return 0;
}
diff --git a/src/or/control.c b/src/or/control.c
index 0c4bcbd..ec76ecf 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -6084,14 +6084,14 @@ control_event_buildtimeout_set(buildtimeout_set_event_t type,
/** Called when a signal has been processed from signal_callback */
int
-control_event_signal(uintptr_t signal)
+control_event_signal(uintptr_t signal_num)
{
const char *signal_string = NULL;
if (!control_event_is_interesting(EVENT_GOT_SIGNAL))
return 0;
- switch (signal) {
+ switch (signal_num) {
case SIGHUP:
signal_string = "RELOAD";
break;
@@ -6112,7 +6112,7 @@ control_event_signal(uintptr_t signal)
break;
default:
log_warn(LD_BUG, "Unrecognized signal %lu in control_event_signal",
- (unsigned long)signal);
+ (unsigned long)signal_num);
return -1;
}
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 2db8731..94a13e3 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -1431,7 +1431,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* Add the actual router entries. */
{
- int *index; /* index[j] is the current index into votes[j]. */
int *size; /* size[j] is the number of routerstatuses in votes[j]. */
int *flag_counts; /* The number of voters that list flag[j] for the
* currently considered router. */
@@ -1466,7 +1465,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
memset(conflict, 0, sizeof(conflict));
memset(unknown, 0xff, sizeof(conflict));
- index = tor_calloc(smartlist_len(votes), sizeof(int));
size = tor_calloc(smartlist_len(votes), sizeof(int));
n_voter_flags = tor_calloc(smartlist_len(votes), sizeof(int));
n_flag_voters = tor_calloc(smartlist_len(flags), sizeof(int));
@@ -1932,7 +1930,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* And the loop is over and we move on to the next router */
}
- tor_free(index);
tor_free(size);
tor_free(n_voter_flags);
tor_free(n_flag_voters);
diff --git a/src/or/policies.c b/src/or/policies.c
index 0b8f335..07f256f 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -2669,7 +2669,7 @@ compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port,
{
int i;
int found_match = 0;
- int accept;
+ int accept_;
tor_assert(port != 0);
@@ -2689,9 +2689,9 @@ compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port,
}
if (found_match)
- accept = policy->is_accept;
+ accept_ = policy->is_accept;
else
- accept = ! policy->is_accept;
+ accept_ = ! policy->is_accept;
/* ???? are these right? -NM */
/* We should be sure not to return ADDR_POLICY_ACCEPTED in the accept
@@ -2704,7 +2704,7 @@ compare_tor_addr_to_short_policy(const tor_addr_t *addr, uint16_t port,
*
* Once microdescriptors can handle addresses in special cases (e.g. if
* we ever solve ticket 1774), we can provide certainty here. -RD */
- if (accept)
+ if (accept_)
return ADDR_POLICY_PROBABLY_ACCEPTED;
else
return ADDR_POLICY_REJECTED;
diff --git a/src/or/relay.c b/src/or/relay.c
index 51b33cc..309bb40 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -255,12 +255,12 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
if (! CIRCUIT_IS_ORIGIN(circ) &&
TO_OR_CIRCUIT(circ)->rend_splice &&
cell_direction == CELL_DIRECTION_OUT) {
- or_circuit_t *splice = TO_OR_CIRCUIT(circ)->rend_splice;
+ or_circuit_t *splice_ = TO_OR_CIRCUIT(circ)->rend_splice;
tor_assert(circ->purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
- tor_assert(splice->base_.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
- cell->circ_id = splice->p_circ_id;
+ tor_assert(splice_->base_.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
+ cell->circ_id = splice_->p_circ_id;
cell->command = CELL_RELAY; /* can't be relay_early anyway */
- if ((reason = circuit_receive_relay_cell(cell, TO_CIRCUIT(splice),
+ if ((reason = circuit_receive_relay_cell(cell, TO_CIRCUIT(splice_),
CELL_DIRECTION_IN)) < 0) {
log_warn(LD_REND, "Error relaying cell across rendezvous; closing "
"circuits");
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 2d47e12..3468b07 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -830,9 +830,9 @@ fetch_v2_desc_by_addr(rend_data_t *query, smartlist_t *hsdirs)
tries_left = REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS;
while (tries_left > 0) {
- int rand = crypto_rand_int(tries_left);
- int chosen_replica = replicas_left_to_try[rand];
- replicas_left_to_try[rand] = replicas_left_to_try[--tries_left];
+ int rand_val = crypto_rand_int(tries_left);
+ int chosen_replica = replicas_left_to_try[rand_val];
+ replicas_left_to_try[rand_val] = replicas_left_to_try[--tries_left];
ret = rend_compute_v2_desc_id(descriptor_id, query->onion_address,
query->auth_type == REND_STEALTH_AUTH ?
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 929e95d..0eab5e0 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -743,14 +743,15 @@ rep_history_clean(time_t before)
orhist_it = digestmap_iter_init(history_map);
while (!digestmap_iter_done(orhist_it)) {
- int remove;
+ int should_remove;
digestmap_iter_get(orhist_it, &d1, &or_history_p);
or_history = or_history_p;
- remove = authority ? (or_history->total_run_weights < STABILITY_EPSILON &&
+ should_remove = authority ?
+ (or_history->total_run_weights < STABILITY_EPSILON &&
!or_history->start_of_run)
: (or_history->changed < before);
- if (remove) {
+ if (should_remove) {
orhist_it = digestmap_iter_next_rmv(history_map, orhist_it);
free_or_history(or_history);
continue;
@@ -2294,16 +2295,16 @@ void
rep_hist_add_buffer_stats(double mean_num_cells_in_queue,
double mean_time_cells_in_queue, uint32_t processed_cells)
{
- circ_buffer_stats_t *stat;
+ circ_buffer_stats_t *stats;
if (!start_of_buffer_stats_interval)
return; /* Not initialized. */
- stat = tor_malloc_zero(sizeof(circ_buffer_stats_t));
- stat->mean_num_cells_in_queue = mean_num_cells_in_queue;
- stat->mean_time_cells_in_queue = mean_time_cells_in_queue;
- stat->processed_cells = processed_cells;
+ stats = tor_malloc_zero(sizeof(circ_buffer_stats_t));
+ stats->mean_num_cells_in_queue = mean_num_cells_in_queue;
+ stats->mean_time_cells_in_queue = mean_time_cells_in_queue;
+ stats->processed_cells = processed_cells;
if (!circuits_for_buffer_stats)
circuits_for_buffer_stats = smartlist_new();
- smartlist_add(circuits_for_buffer_stats, stat);
+ smartlist_add(circuits_for_buffer_stats, stats);
}
/** Remember cell statistics for circuit <b>circ</b> at time
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 27a19f5..060ffd8 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -931,15 +931,15 @@ load_ed_keys(const or_options_t *options, time_t now)
int
generate_ed_link_cert(const or_options_t *options, time_t now)
{
- const tor_x509_cert_t *link = NULL, *id = NULL;
+ const tor_x509_cert_t *link_ = NULL, *id = NULL;
tor_cert_t *link_cert = NULL;
- if (tor_tls_get_my_certs(1, &link, &id) < 0 || link == NULL) {
+ if (tor_tls_get_my_certs(1, &link_, &id) < 0 || link_ == NULL) {
log_warn(LD_OR, "Can't get my x509 link cert.");
return -1;
}
- const common_digests_t *digests = tor_x509_cert_get_cert_digests(link);
+ const common_digests_t *digests = tor_x509_cert_get_cert_digests(link_);
if (link_cert_cert &&
! EXPIRES_SOON(link_cert_cert, options->TestingLinkKeySlop) &&
@@ -979,12 +979,12 @@ should_make_new_ed_keys(const or_options_t *options, const time_t now)
EXPIRES_SOON(link_cert_cert, options->TestingLinkKeySlop))
return 1;
- const tor_x509_cert_t *link = NULL, *id = NULL;
+ const tor_x509_cert_t *link_ = NULL, *id = NULL;
- if (tor_tls_get_my_certs(1, &link, &id) < 0 || link == NULL)
+ if (tor_tls_get_my_certs(1, &link_, &id) < 0 || link_ == NULL)
return 1;
- const common_digests_t *digests = tor_x509_cert_get_cert_digests(link);
+ const common_digests_t *digests = tor_x509_cert_get_cert_digests(link_);
if (!fast_memeq(digests->d[DIGEST_SHA256],
link_cert_cert->signed_key.pubkey,
diff --git a/src/or/shared_random.c b/src/or/shared_random.c
index c9886d9..0a1f24a 100644
--- a/src/or/shared_random.c
+++ b/src/or/shared_random.c
@@ -115,16 +115,16 @@ static int32_t num_srv_agreements_from_vote;
STATIC sr_srv_t *
srv_dup(const sr_srv_t *orig)
{
- sr_srv_t *dup = NULL;
+ sr_srv_t *duplicate = NULL;
if (!orig) {
return NULL;
}
- dup = tor_malloc_zero(sizeof(sr_srv_t));
- dup->num_reveals = orig->num_reveals;
- memcpy(dup->value, orig->value, sizeof(dup->value));
- return dup;
+ duplicate = tor_malloc_zero(sizeof(sr_srv_t));
+ duplicate->num_reveals = orig->num_reveals;
+ memcpy(duplicate->value, orig->value, sizeof(duplicate->value));
+ return duplicate;
}
/* Allocate a new commit object and initializing it with <b>rsa_identity</b>
diff --git a/src/test/test_address.c b/src/test/test_address.c
index 82d6bc7..b4638f0 100644
--- a/src/test/test_address.c
+++ b/src/test/test_address.c
@@ -562,13 +562,13 @@ static int last_connected_socket_fd = 0;
static int connect_retval = 0;
static tor_socket_t
-pretend_to_connect(tor_socket_t socket, const struct sockaddr *address,
+pretend_to_connect(tor_socket_t sock, const struct sockaddr *address,
socklen_t address_len)
{
(void)address;
(void)address_len;
- last_connected_socket_fd = socket;
+ last_connected_socket_fd = sock;
return connect_retval;
}
@@ -576,11 +576,11 @@ pretend_to_connect(tor_socket_t socket, const struct sockaddr *address,
static struct sockaddr *mock_addr = NULL;
static int
-fake_getsockname(tor_socket_t socket, struct sockaddr *address,
+fake_getsockname(tor_socket_t sock, struct sockaddr *address,
socklen_t *address_len)
{
socklen_t bytes_to_copy = 0;
- (void) socket;
+ (void) sock;
if (!mock_addr)
return -1;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 843a57a..5432b2c 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -5240,12 +5240,12 @@ test_util_pwdb(void *arg)
tt_assert(dir != NULL);
/* Try failing cases. First find a user that doesn't exist by name */
- char rand[4];
+ char randbytes[4];
char badname[9];
int i, found=0;
for (i = 0; i < 100; ++i) {
- crypto_rand(rand, sizeof(rand));
- base16_encode(badname, sizeof(badname), rand, sizeof(rand));
+ crypto_rand(randbytes, sizeof(randbytes));
+ base16_encode(badname, sizeof(badname), randbytes, sizeof(randbytes));
if (tor_getpwnam(badname) == NULL) {
found = 1;
break;
1
0

28 Jul '16
commit 1135405c8c6ea315cd035171770a6701edae57f0
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Tue Jul 5 13:43:58 2016 -0400
Fix a variable-shadowing bug in check_private_dir
We introduded a shadowed variable, thereby causing a log message to
be wrong. Fixes 19578. I believe the bug was introduced by
54d7d31cba84232 in 0.2.2.29-beta.
---
changes/bug19578 | 3 +++
src/common/util.c | 9 +++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/changes/bug19578 b/changes/bug19578
new file mode 100644
index 0000000..8b3355b
--- /dev/null
+++ b/changes/bug19578
@@ -0,0 +1,3 @@
+ o Minor bugfixes (logging):
+ - When logging a directory ownership mismatch, log the owning username
+ correctly. Fixes bug 19578; bugfix on 0.2.2.29-beta.
diff --git a/src/common/util.c b/src/common/util.c
index 538aeb1..d61985e 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -2291,13 +2291,14 @@ check_private_dir,(const char *dirname, cpd_check_t check,
running_gid = getgid();
}
if (st.st_uid != running_uid) {
- const struct passwd *pw = NULL;
+ const struct passwd *pw_uid = NULL;
char *process_ownername = NULL;
- pw = tor_getpwuid(running_uid);
- process_ownername = pw ? tor_strdup(pw->pw_name) : tor_strdup("<unknown>");
+ pw_uid = tor_getpwuid(running_uid);
+ process_ownername = pw_uid ? tor_strdup(pw_uid->pw_name) :
+ tor_strdup("<unknown>");
- pw = tor_getpwuid(st.st_uid);
+ pw_uid = tor_getpwuid(st.st_uid);
log_warn(LD_FS, "%s is not owned by this user (%s, %d) but by "
"%s (%d). Perhaps you are running Tor as the wrong user?",
1
0
commit 47573038736b96e2a353a25ed3c788dcb77d8fcb
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Tue Jul 5 14:19:31 2016 -0400
Fix all -Wshadow warnings on Linux
This is a partial fix for 18902.
---
configure.ac | 1 +
src/common/util.c | 4 ++--
src/or/channeltls.c | 4 ++--
src/or/circuitbuild.c | 14 +++++++-------
src/or/config.c | 30 ++++++++++++++----------------
src/or/connection.h | 14 +++++++-------
src/or/connection_edge.c | 8 ++++----
src/or/connection_or.c | 7 +++----
src/or/control.c | 30 ++++++++++++++++--------------
src/or/dirvote.c | 12 ++++++------
src/or/entrynodes.c | 1 -
src/or/geoip.c | 17 ++++++++---------
src/or/nodelist.c | 6 ++++--
src/or/rendservice.c | 3 +--
src/or/rephist.c | 14 +++++++-------
src/or/router.c | 12 ++++++------
src/or/routerkeys.c | 10 +++++-----
src/or/routerlist.c | 6 +++---
src/or/routerparse.c | 40 ++++++++++++++++++++++------------------
src/or/scheduler.c | 8 ++++----
src/or/transports.c | 12 ++++++------
src/test/bench.c | 9 ++++-----
src/test/test_addr.c | 6 +++---
src/test/test_buffers.c | 6 +++---
src/test/test_cell_formats.c | 4 ++--
src/test/test_containers.c | 24 ++++++++++++------------
src/test/test_dir.c | 10 +++++-----
src/test/test_dns.c | 8 ++++----
src/test/test_microdesc.c | 2 +-
src/test/test_policy.c | 9 ++++-----
src/test/test_pt.c | 12 ++++++------
src/test/test_scheduler.c | 6 ++++--
src/test/test_util.c | 6 +++---
33 files changed, 179 insertions(+), 176 deletions(-)
diff --git a/configure.ac b/configure.ac
index 81438fc..c8c82aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1821,6 +1821,7 @@ if test "x$enable_gcc_warnings_advisory" != "xno"; then
-Wselector-type-mismatch
-Wsentinel
-Wserialized-diagnostics
+ -Wshadow
-Wshift-count-negative
-Wshift-count-overflow
-Wshift-negative-value
diff --git a/src/common/util.c b/src/common/util.c
index d61985e..3eb4005 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3812,9 +3812,9 @@ format_win_cmdline_argument(const char *arg)
formatted_arg[i++] = '"';
/* Add characters */
- SMARTLIST_FOREACH(arg_chars, char*, c,
+ SMARTLIST_FOREACH(arg_chars, char*, ch,
{
- formatted_arg[i++] = *c;
+ formatted_arg[i++] = *ch;
});
/* Add trailing quote */
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 2bb88dd..fb0e7c5 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -1901,8 +1901,8 @@ channel_tls_process_certs_cell(var_cell_t *cell, channel_tls_t *chan)
}
err:
- for (unsigned i = 0; i < ARRAY_LENGTH(certs); ++i) {
- tor_x509_cert_free(certs[i]);
+ for (unsigned u = 0; u < ARRAY_LENGTH(certs); ++u) {
+ tor_x509_cert_free(certs[u]);
}
certs_cell_free(cc);
#undef ERR
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 13cc166..dab378f 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1565,7 +1565,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
int n_best_support=0;
const or_options_t *options = get_options();
const smartlist_t *the_nodes;
- const node_t *node=NULL;
+ const node_t *selected_node=NULL;
connections = get_connection_array();
@@ -1692,7 +1692,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
smartlist_add(supporting, (void*)node);
});
- node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
+ selected_node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
smartlist_free(supporting);
} else {
/* Either there are no pending connections, or no routers even seem to
@@ -1730,8 +1730,8 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
}
} SMARTLIST_FOREACH_END(node);
- node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
- if (node)
+ selected_node = node_sl_choose_by_bandwidth(supporting, WEIGHT_FOR_EXIT);
+ if (selected_node)
break;
smartlist_clear(supporting);
/* If we reach this point, we can't actually support any unhandled
@@ -1745,9 +1745,9 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
}
tor_free(n_supported);
- if (node) {
- log_info(LD_CIRC, "Chose exit server '%s'", node_describe(node));
- return node;
+ if (selected_node) {
+ log_info(LD_CIRC, "Chose exit server '%s'", node_describe(selected_node));
+ return selected_node;
}
if (options->ExitNodes) {
log_warn(LD_CIRC,
diff --git a/src/or/config.c b/src/or/config.c
index a677f21..8b471f6 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3488,10 +3488,10 @@ options_validate(or_options_t *old_options, or_options_t *options,
}
if (server_mode(options)) {
- char *msg = NULL;
- if (have_enough_mem_for_dircache(options, 0, &msg)) {
- log_warn(LD_CONFIG, "%s", msg);
- tor_free(msg);
+ char *dircache_msg = NULL;
+ if (have_enough_mem_for_dircache(options, 0, &dircache_msg)) {
+ log_warn(LD_CONFIG, "%s", dircache_msg);
+ tor_free(dircache_msg);
}
}
@@ -4820,7 +4820,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
{
or_options_t *oldoptions, *newoptions, *newdefaultoptions=NULL;
config_line_t *cl;
- int retval, i;
+ int retval;
setopt_err_t err = SETOPT_ERR_MISC;
tor_assert(msg);
@@ -4833,7 +4833,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
newoptions->command = command;
newoptions->command_arg = command_arg ? tor_strdup(command_arg) : NULL;
- for (i = 0; i < 2; ++i) {
+ for (int i = 0; i < 2; ++i) {
const char *body = i==0 ? cf_defaults : cf;
if (!body)
continue;
@@ -4877,8 +4877,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
* let's clean it up. -NM */
/* Change defaults. */
- int i;
- for (i = 0; testing_tor_network_defaults[i].name; ++i) {
+ for (int i = 0; testing_tor_network_defaults[i].name; ++i) {
const config_var_t *new_var = &testing_tor_network_defaults[i];
config_var_t *old_var =
config_find_option_mutable(&options_format, new_var->name);
@@ -4898,7 +4897,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
newoptions->command_arg = command_arg ? tor_strdup(command_arg) : NULL;
/* Assign all options a second time. */
- for (i = 0; i < 2; ++i) {
+ for (int i = 0; i < 2; ++i) {
const char *body = i==0 ? cf_defaults : cf;
if (!body)
continue;
@@ -5914,10 +5913,10 @@ parse_dir_fallback_line(const char *line,
ipv6_addrport_ptr = &ipv6_addrport;
}
} else if (!strcmpstart(cp, "weight=")) {
- int ok;
+ int num_ok;
const char *wstring = cp + strlen("weight=");
- weight = tor_parse_double(wstring, 0, (double)UINT64_MAX, &ok, NULL);
- if (!ok) {
+ weight = tor_parse_double(wstring, 0, (double)UINT64_MAX, &num_ok, NULL);
+ if (!num_ok) {
log_warn(LD_CONFIG, "Invalid weight '%s' on FallbackDir line.", cp);
weight=1.0;
}
@@ -7409,8 +7408,8 @@ getinfo_helper_config(control_connection_t *conn,
smartlist_free(sl);
} else if (!strcmp(question, "config/defaults")) {
smartlist_t *sl = smartlist_new();
- int i, dirauth_lines_seen = 0, fallback_lines_seen = 0;
- for (i = 0; option_vars_[i].name; ++i) {
+ int dirauth_lines_seen = 0, fallback_lines_seen = 0;
+ for (int i = 0; option_vars_[i].name; ++i) {
const config_var_t *var = &option_vars_[i];
if (var->initvalue != NULL) {
if (strcmp(option_vars_[i].name, "DirAuthority") == 0) {
@@ -7438,14 +7437,13 @@ getinfo_helper_config(control_connection_t *conn,
* We didn't see any directory authorities with default values,
* so add the list of default authorities manually.
*/
- const char **i;
/*
* default_authorities is defined earlier in this file and
* is a const char ** NULL-terminated array of dirauth config
* lines.
*/
- for (i = default_authorities; *i != NULL; ++i) {
+ for (const char **i = default_authorities; *i != NULL; ++i) {
char *val = esc_for_log(*i);
smartlist_add_asprintf(sl, "DirAuthority %s\n", val);
tor_free(val);
diff --git a/src/or/connection.h b/src/or/connection.h
index 4835235..4417b89 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -52,13 +52,13 @@ void connection_mark_for_close_internal_(connection_t *conn,
* For all other cases, use connection_mark_and_flush() instead, which
* checks for or_connection_t properly, instead. See below.
*/
-#define connection_mark_and_flush_internal_(c,line,file) \
- do { \
- connection_t *tmp_conn_ = (c); \
- connection_mark_for_close_internal_(tmp_conn_, (line), (file)); \
- tmp_conn_->hold_open_until_flushed = 1; \
- IF_HAS_BUFFEREVENT(tmp_conn_, \
- connection_start_writing(tmp_conn_)); \
+#define connection_mark_and_flush_internal_(c,line,file) \
+ do { \
+ connection_t *tmp_conn__ = (c); \
+ connection_mark_for_close_internal_(tmp_conn__, (line), (file)); \
+ tmp_conn__->hold_open_until_flushed = 1; \
+ IF_HAS_BUFFEREVENT(tmp_conn__, \
+ connection_start_writing(tmp_conn__)); \
} while (0)
#define connection_mark_and_flush_internal(c) \
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 799baa2..cb79de6 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2881,7 +2881,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
or_circuit_t *or_circ = NULL;
const or_options_t *options = get_options();
begin_cell_t bcell;
- int r;
+ int rv;
uint8_t end_reason=0;
assert_circuit_ok(circ);
@@ -2906,10 +2906,10 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
return 0;
}
- r = begin_cell_parse(cell, &bcell, &end_reason);
- if (r < -1) {
+ rv = begin_cell_parse(cell, &bcell, &end_reason);
+ if (rv < -1) {
return -END_CIRC_REASON_TORPROTOCOL;
- } else if (r == -1) {
+ } else if (rv == -1) {
tor_free(bcell.address);
relay_send_end_cell_from_edge(rh.stream_id, circ, end_reason, NULL);
return 0;
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index c69a2ad..4f71a29 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -2275,14 +2275,13 @@ connection_or_send_certs_cell(or_connection_t *conn)
var_cell_t *cell;
size_t cell_len;
ssize_t pos;
- int server_mode;
tor_assert(conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3);
if (! conn->handshake_state)
return -1;
- server_mode = ! conn->handshake_state->started_here;
- if (tor_tls_get_my_certs(server_mode, &link_cert, &id_cert) < 0)
+ const int conn_in_server_mode = ! conn->handshake_state->started_here;
+ if (tor_tls_get_my_certs(conn_in_server_mode, &link_cert, &id_cert) < 0)
return -1;
tor_x509_cert_get_der(link_cert, &link_encoded, &link_len);
tor_x509_cert_get_der(id_cert, &id_encoded, &id_len);
@@ -2295,7 +2294,7 @@ connection_or_send_certs_cell(or_connection_t *conn)
cell->payload[0] = 2;
pos = 1;
- if (server_mode)
+ if (conn_in_server_mode)
cell->payload[pos] = OR_CERT_TYPE_TLS_LINK; /* Link cert */
else
cell->payload[pos] = OR_CERT_TYPE_AUTH_1024; /* client authentication */
diff --git a/src/or/control.c b/src/or/control.c
index d3613d8..82adc95 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -598,7 +598,7 @@ typedef struct queued_event_s {
/** Pointer to int. If this is greater than 0, we don't allow new events to be
* queued. */
-static tor_threadlocal_t block_event_queue;
+static tor_threadlocal_t block_event_queue_flag;
/** Holds a smartlist of queued_event_t objects that may need to be sent
* to one or more controllers */
@@ -633,17 +633,17 @@ control_initialize_event_queue(void)
if (queued_control_events_lock == NULL) {
queued_control_events_lock = tor_mutex_new();
- tor_threadlocal_init(&block_event_queue);
+ tor_threadlocal_init(&block_event_queue_flag);
}
}
static int *
get_block_event_queue(void)
{
- int *val = tor_threadlocal_get(&block_event_queue);
+ int *val = tor_threadlocal_get(&block_event_queue_flag);
if (PREDICT_UNLIKELY(val == NULL)) {
val = tor_malloc_zero(sizeof(int));
- tor_threadlocal_set(&block_event_queue, val);
+ tor_threadlocal_set(&block_event_queue_flag, val);
}
return val;
}
@@ -1374,7 +1374,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
goto err;
}
bad_password = 1;
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
sl = NULL;
} else {
@@ -1386,7 +1386,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
received, DIGEST_LEN))
goto ok;
});
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
sl = NULL;
@@ -1414,7 +1414,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
connection_printf_to_buf(conn, "515 Authentication failed: %s\r\n", errstr);
connection_mark_for_close(TO_CONN(conn));
if (sl) { /* clean up */
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
}
return 0;
@@ -1425,7 +1425,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
conn->base_.state = CONTROL_CONN_STATE_OPEN;
tor_free(password);
if (sl) { /* clean up */
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
}
return 0;
@@ -1854,11 +1854,10 @@ getinfo_helper_dir(control_connection_t *control_conn,
const char *question, char **answer,
const char **errmsg)
{
- const node_t *node;
- const routerinfo_t *ri = NULL;
(void) control_conn;
if (!strcmpstart(question, "desc/id/")) {
- node = node_get_by_hex_id(question+strlen("desc/id/"));
+ const routerinfo_t *ri = NULL;
+ const node_t *node = node_get_by_hex_id(question+strlen("desc/id/"));
if (node)
ri = node->ri;
if (ri) {
@@ -1867,9 +1866,10 @@ getinfo_helper_dir(control_connection_t *control_conn,
*answer = tor_strndup(body, ri->cache_info.signed_descriptor_len);
}
} else if (!strcmpstart(question, "desc/name/")) {
+ const routerinfo_t *ri = NULL;
/* XXX Setting 'warn_if_unnamed' here is a bit silly -- the
* warning goes to the user, not to the controller. */
- node = node_get_by_nickname(question+strlen("desc/name/"), 1);
+ const node_t *node = node_get_by_nickname(question+strlen("desc/name/"), 1);
if (node)
ri = node->ri;
if (ri) {
@@ -1963,7 +1963,9 @@ getinfo_helper_dir(control_connection_t *control_conn,
*answer = tor_strndup(md->body, md->bodylen);
}
} else if (!strcmpstart(question, "desc-annotations/id/")) {
- node = node_get_by_hex_id(question+strlen("desc-annotations/id/"));
+ const routerinfo_t *ri = NULL;
+ const node_t *node =
+ node_get_by_hex_id(question+strlen("desc-annotations/id/"));
if (node)
ri = node->ri;
if (ri) {
@@ -4641,7 +4643,7 @@ add_onion_helper_clientauth(const char *arg, int *created, char **err_msg)
ok = 1;
err:
- SMARTLIST_FOREACH(auth_args, char *, arg, tor_free(arg));
+ SMARTLIST_FOREACH(auth_args, char *, item, tor_free(item));
smartlist_free(auth_args);
if (!ok) {
rend_authorized_client_free(client);
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index c31894a..2db8731 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2422,15 +2422,15 @@ networkstatus_get_detached_signatures(smartlist_t *consensuses)
/* Now get all the sigs for non-FLAV_NS consensuses */
SMARTLIST_FOREACH_BEGIN(consensuses, networkstatus_t *, ns) {
- char *sigs;
+ char *sigs_on_this_consensus;
if (ns->flavor == FLAV_NS)
continue;
- sigs = networkstatus_format_signatures(ns, 1);
- if (!sigs) {
+ sigs_on_this_consensus = networkstatus_format_signatures(ns, 1);
+ if (!sigs_on_this_consensus) {
log_warn(LD_DIR, "Couldn't format signatures");
goto err;
}
- smartlist_add(elements, sigs);
+ smartlist_add(elements, sigs_on_this_consensus);
} SMARTLIST_FOREACH_END(ns);
/* Now add the FLAV_NS consensus signatrures. */
@@ -3101,12 +3101,12 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
/* Write the votes in <b>pending_vote_list</b> to disk. */
static void
-write_v3_votes_to_disk(const smartlist_t *pending_vote_list)
+write_v3_votes_to_disk(const smartlist_t *pending_votes)
{
smartlist_t *votestrings = smartlist_new();
char *votefile = NULL;
- SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v,
+ SMARTLIST_FOREACH(pending_votes, pending_vote_t *, v,
{
sized_chunk_t *c = tor_malloc(sizeof(sized_chunk_t));
c->bytes = v->vote_body->dir;
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 6990bcd..265b6dc 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1455,7 +1455,6 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
}
} else {
if (state_version) {
- time_t now = time(NULL);
e->chosen_on_date = crypto_rand_time_range(now - 3600*24*30, now);
e->chosen_by_version = tor_strdup(state_version);
}
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 8740524..6eb0ce7 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -824,7 +824,6 @@ geoip_get_transport_history(void)
static const char* no_transport_str = "<OR>";
clientmap_entry_t **ent;
- const char *transport_name = NULL;
smartlist_t *string_chunks = smartlist_new();
char *the_string = NULL;
@@ -850,7 +849,7 @@ geoip_get_transport_history(void)
HT_FOREACH(ent, clientmap, &client_history) {
uintptr_t val;
void *ptr;
- transport_name = (*ent)->transport_name;
+ const char *transport_name = (*ent)->transport_name;
if (!transport_name)
transport_name = no_transport_str;
@@ -916,13 +915,13 @@ geoip_get_dirreq_history(dirreq_type_t type)
smartlist_t *dirreq_completed = NULL;
uint32_t complete = 0, timeouts = 0, running = 0;
int bufsize = 1024, written;
- dirreq_map_entry_t **ptr, **next, *ent;
+ dirreq_map_entry_t **ptr, **next;
struct timeval now;
tor_gettimeofday(&now);
dirreq_completed = smartlist_new();
for (ptr = HT_START(dirreqmap, &dirreq_map); ptr; ptr = next) {
- ent = *ptr;
+ dirreq_map_entry_t *ent = *ptr;
if (ent->type != type) {
next = HT_NEXT(dirreqmap, &dirreq_map, ptr);
continue;
@@ -1024,7 +1023,7 @@ geoip_get_client_history(geoip_client_action_t action,
smartlist_t *entries = NULL;
int n_countries = geoip_get_n_countries();
int i;
- clientmap_entry_t **ent;
+ clientmap_entry_t **cm_ent;
unsigned *counts = NULL;
unsigned total = 0;
unsigned ipv4_count = 0, ipv6_count = 0;
@@ -1033,17 +1032,17 @@ geoip_get_client_history(geoip_client_action_t action,
return -1;
counts = tor_calloc(n_countries, sizeof(unsigned));
- HT_FOREACH(ent, clientmap, &client_history) {
+ HT_FOREACH(cm_ent, clientmap, &client_history) {
int country;
- if ((*ent)->action != (int)action)
+ if ((*cm_ent)->action != (int)action)
continue;
- country = geoip_get_country_by_addr(&(*ent)->addr);
+ country = geoip_get_country_by_addr(&(*cm_ent)->addr);
if (country < 0)
country = 0; /** unresolved requests are stored at index 0. */
tor_assert(0 <= country && country < n_countries);
++counts[country];
++total;
- switch (tor_addr_family(&(*ent)->addr)) {
+ switch (tor_addr_family(&(*cm_ent)->addr)) {
case AF_INET:
ipv4_count++;
break;
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index a49bf03..7b64caf 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -542,13 +542,15 @@ node_get_by_hex_id(const char *hex_id)
MOCK_IMPL(const node_t *,
node_get_by_nickname,(const char *nickname, int warn_if_unnamed))
{
- const node_t *node;
if (!the_nodelist)
return NULL;
/* Handle these cases: DIGEST, $DIGEST, $DIGEST=name, $DIGEST~name. */
- if ((node = node_get_by_hex_id(nickname)) != NULL)
+ {
+ const node_t *node;
+ if ((node = node_get_by_hex_id(nickname)) != NULL)
return node;
+ }
if (!strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME))
return NULL;
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index c50de83..4c88f1f 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -2701,7 +2701,6 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
char auth[DIGEST_LEN + 9];
char serviceid[REND_SERVICE_ID_LEN_BASE32+1];
int reason = END_CIRC_REASON_TORPROTOCOL;
- crypto_pk_t *intro_key;
tor_assert(circuit->base_.purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
#ifndef NON_ANONYMOUS_MODE_ENABLED
@@ -2775,7 +2774,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
(unsigned)circuit->base_.n_circ_id, serviceid);
/* Use the intro key instead of the service key in ESTABLISH_INTRO. */
- intro_key = circuit->intro_key;
+ crypto_pk_t *intro_key = circuit->intro_key;
/* Build the payload for a RELAY_ESTABLISH_INTRO cell. */
r = crypto_pk_asn1_encode(intro_key, buf+2,
RELAY_PAYLOAD_SIZE-2);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 8992571..929e95d 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -2948,22 +2948,22 @@ static hs_stats_t *hs_stats = NULL;
static hs_stats_t *
hs_stats_new(void)
{
- hs_stats_t * hs_stats = tor_malloc_zero(sizeof(hs_stats_t));
- hs_stats->onions_seen_this_period = digestmap_new();
+ hs_stats_t *new_hs_stats = tor_malloc_zero(sizeof(hs_stats_t));
+ new_hs_stats->onions_seen_this_period = digestmap_new();
- return hs_stats;
+ return new_hs_stats;
}
/** Free an hs_stats_t structure. */
static void
-hs_stats_free(hs_stats_t *hs_stats)
+hs_stats_free(hs_stats_t *victim_hs_stats)
{
- if (!hs_stats) {
+ if (!victim_hs_stats) {
return;
}
- digestmap_free(hs_stats->onions_seen_this_period, NULL);
- tor_free(hs_stats);
+ digestmap_free(victim_hs_stats->onions_seen_this_period, NULL);
+ tor_free(victim_hs_stats);
}
/** Initialize hidden service statistics. */
diff --git a/src/or/router.c b/src/or/router.c
index a671591..cc96513 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -3077,17 +3077,17 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
}
if (emit_ed_sigs) {
- char digest[DIGEST256_LEN];
+ char sha256_digest[DIGEST256_LEN];
smartlist_add(chunks, tor_strdup("router-sig-ed25519 "));
- crypto_digest_smartlist_prefix(digest, DIGEST256_LEN,
+ crypto_digest_smartlist_prefix(sha256_digest, DIGEST256_LEN,
ED_DESC_SIGNATURE_PREFIX,
chunks, "", DIGEST_SHA256);
- ed25519_signature_t sig;
+ ed25519_signature_t ed_sig;
char buf[ED25519_SIG_BASE64_LEN+1];
- if (ed25519_sign(&sig, (const uint8_t*)digest, DIGEST256_LEN,
+ if (ed25519_sign(&ed_sig, (const uint8_t*)sha256_digest, DIGEST256_LEN,
signing_keypair) < 0)
goto err;
- if (ed25519_signature_to_base64(buf, &sig) < 0)
+ if (ed25519_signature_to_base64(buf, &ed_sig) < 0)
goto err;
smartlist_add_asprintf(chunks, "%s\n", buf);
@@ -3161,7 +3161,7 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
done:
tor_free(s);
- SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(chunks, char *, chunk, tor_free(chunk));
smartlist_free(chunks);
tor_free(s_dup);
tor_free(ed_cert_line);
diff --git a/src/or/routerkeys.c b/src/or/routerkeys.c
index 12de8c5..27a19f5 100644
--- a/src/or/routerkeys.c
+++ b/src/or/routerkeys.c
@@ -121,14 +121,14 @@ read_encrypted_secret_key(ed25519_secret_key_t *out,
saved_errno = EINVAL;
goto done;
}
- const int r = crypto_unpwbox(&secret, &secret_len,
- encrypted_key, encrypted_len,
- pwbuf, pwlen);
- if (r == UNPWBOX_CORRUPTED) {
+ const int r_unbox = crypto_unpwbox(&secret, &secret_len,
+ encrypted_key, encrypted_len,
+ pwbuf, pwlen);
+ if (r_unbox == UNPWBOX_CORRUPTED) {
log_err(LD_OR, "%s is corrupted.", fname);
saved_errno = EINVAL;
goto done;
- } else if (r == UNPWBOX_OKAY) {
+ } else if (r_unbox == UNPWBOX_OKAY) {
break;
}
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 6ea9d8b..773f681 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -917,7 +917,6 @@ authority_certs_fetch_missing(networkstatus_t *status, time_t now,
*/
digestmap_t *pending_id;
fp_pair_map_t *pending_cert;
- authority_cert_t *cert;
/*
* The missing_id_digests smartlist will hold a list of id digests
* we want to fetch the newest cert for; the missing_cert_digests
@@ -1027,8 +1026,9 @@ authority_certs_fetch_missing(networkstatus_t *status, time_t now,
}
SMARTLIST_FOREACH_BEGIN(voter->sigs, document_signature_t *, sig) {
- cert = authority_cert_get_by_digests(voter->identity_digest,
- sig->signing_key_digest);
+ authority_cert_t *cert =
+ authority_cert_get_by_digests(voter->identity_digest,
+ sig->signing_key_digest);
if (cert) {
if (now < cert->expires)
download_status_reset_by_sk_in_cl(cl, sig->signing_key_digest);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 0f9b9f7..03f8f4e 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1779,11 +1779,11 @@ router_parse_entry_from_string(const char *s, const char *end,
if (cache_copy) {
size_t len = router->cache_info.signed_descriptor_len +
router->cache_info.annotations_len;
- char *cp =
+ char *signed_body =
router->cache_info.signed_descriptor_body = tor_malloc(len+1);
if (prepend_annotations) {
- memcpy(cp, prepend_annotations, prepend_len);
- cp += prepend_len;
+ memcpy(signed_body, prepend_annotations, prepend_len);
+ signed_body += prepend_len;
}
/* This assertion will always succeed.
* len == signed_desc_len + annotations_len
@@ -1791,9 +1791,9 @@ router_parse_entry_from_string(const char *s, const char *end,
* == end-start_of_annotations + prepend_len
* We already wrote prepend_len bytes into the buffer; now we're
* writing end-start_of_annotations -NM. */
- tor_assert(cp+(end-start_of_annotations) ==
+ tor_assert(signed_body+(end-start_of_annotations) ==
router->cache_info.signed_descriptor_body+len);
- memcpy(cp, start_of_annotations, end-start_of_annotations);
+ memcpy(signed_body, start_of_annotations, end-start_of_annotations);
router->cache_info.signed_descriptor_body[len] = '\0';
tor_assert(strlen(router->cache_info.signed_descriptor_body) == len);
}
@@ -3546,7 +3546,6 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
common_digests_t ns_digests;
const char *cert, *end_of_header, *end_of_footer, *s_dup = s;
directory_token_t *tok;
- int ok;
struct in_addr in;
int i, inorder, n_signatures = 0;
memarea_t *area = NULL, *rs_area = NULL;
@@ -3636,9 +3635,10 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
} else {
tok = find_opt_by_keyword(tokens, K_CONSENSUS_METHOD);
if (tok) {
+ int num_ok;
ns->consensus_method = (int)tor_parse_long(tok->args[0], 10, 1, INT_MAX,
- &ok, NULL);
- if (!ok)
+ &num_ok, NULL);
+ if (!num_ok)
goto err;
} else {
ns->consensus_method = 1;
@@ -3659,14 +3659,17 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
tok = find_by_keyword(tokens, K_VOTING_DELAY);
tor_assert(tok->n_args >= 2);
- ns->vote_seconds =
- (int) tor_parse_long(tok->args[0], 10, 0, INT_MAX, &ok, NULL);
- if (!ok)
- goto err;
- ns->dist_seconds =
- (int) tor_parse_long(tok->args[1], 10, 0, INT_MAX, &ok, NULL);
- if (!ok)
- goto err;
+ {
+ int ok;
+ ns->vote_seconds =
+ (int) tor_parse_long(tok->args[0], 10, 0, INT_MAX, &ok, NULL);
+ if (!ok)
+ goto err;
+ ns->dist_seconds =
+ (int) tor_parse_long(tok->args[1], 10, 0, INT_MAX, &ok, NULL);
+ if (!ok)
+ goto err;
+ }
if (ns->valid_after +
(get_options()->TestingTorNetwork ?
MIN_VOTE_INTERVAL_TESTING : MIN_VOTE_INTERVAL) > ns->fresh_until) {
@@ -3817,6 +3820,7 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
goto err;
}
voter->addr = ntohl(in.s_addr);
+ int ok;
voter->dir_port = (uint16_t)
tor_parse_long(tok->args[4], 10, 0, 65535, &ok, NULL);
if (!ok)
@@ -3864,8 +3868,8 @@ networkstatus_parse_vote_from_string(const char *s, const char **eos_out,
(tok = find_opt_by_keyword(tokens, K_LEGACY_DIR_KEY))) {
int bad = 1;
if (strlen(tok->args[0]) == HEX_DIGEST_LEN) {
- networkstatus_voter_info_t *voter = smartlist_get(ns->voters, 0);
- if (base16_decode(voter->legacy_id_digest, DIGEST_LEN,
+ networkstatus_voter_info_t *voter_0 = smartlist_get(ns->voters, 0);
+ if (base16_decode(voter_0->legacy_id_digest, DIGEST_LEN,
tok->args[0], HEX_DIGEST_LEN) != DIGEST_LEN)
bad = 1;
else
diff --git a/src/or/scheduler.c b/src/or/scheduler.c
index 8e4810b..fd27504 100644
--- a/src/or/scheduler.c
+++ b/src/or/scheduler.c
@@ -500,13 +500,13 @@ scheduler_run, (void))
/* Readd any channels we need to */
if (to_readd) {
- SMARTLIST_FOREACH_BEGIN(to_readd, channel_t *, chan) {
- chan->scheduler_state = SCHED_CHAN_PENDING;
+ SMARTLIST_FOREACH_BEGIN(to_readd, channel_t *, readd_chan) {
+ readd_chan->scheduler_state = SCHED_CHAN_PENDING;
smartlist_pqueue_add(channels_pending,
scheduler_compare_channels,
STRUCT_OFFSET(channel_t, sched_heap_idx),
- chan);
- } SMARTLIST_FOREACH_END(chan);
+ readd_chan);
+ } SMARTLIST_FOREACH_END(readd_chan);
smartlist_free(to_readd);
}
diff --git a/src/or/transports.c b/src/or/transports.c
index c99ff17..be77c87 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -1425,7 +1425,7 @@ create_managed_proxy_environment(const managed_proxy_t *mp)
*
* Requires that proxy_argv have at least one element. */
STATIC managed_proxy_t *
-managed_proxy_create(const smartlist_t *transport_list,
+managed_proxy_create(const smartlist_t *with_transport_list,
char **proxy_argv, int is_server)
{
managed_proxy_t *mp = tor_malloc_zero(sizeof(managed_proxy_t));
@@ -1436,7 +1436,7 @@ managed_proxy_create(const smartlist_t *transport_list,
mp->proxy_uri = get_pt_proxy_uri();
mp->transports_to_launch = smartlist_new();
- SMARTLIST_FOREACH(transport_list, const char *, transport,
+ SMARTLIST_FOREACH(with_transport_list, const char *, transport,
add_transport_to_proxy(transport, mp));
/* register the managed proxy */
@@ -1460,7 +1460,7 @@ managed_proxy_create(const smartlist_t *transport_list,
* elements, containing at least one element.
**/
MOCK_IMPL(void,
-pt_kickstart_proxy, (const smartlist_t *transport_list,
+pt_kickstart_proxy, (const smartlist_t *with_transport_list,
char **proxy_argv, int is_server))
{
managed_proxy_t *mp=NULL;
@@ -1473,7 +1473,7 @@ pt_kickstart_proxy, (const smartlist_t *transport_list,
mp = get_managed_proxy_by_argv_and_type(proxy_argv, is_server);
if (!mp) { /* we haven't seen this proxy before */
- managed_proxy_create(transport_list, proxy_argv, is_server);
+ managed_proxy_create(with_transport_list, proxy_argv, is_server);
} else { /* known proxy. add its transport to its transport list */
if (mp->was_around_before_config_read) {
@@ -1490,14 +1490,14 @@ pt_kickstart_proxy, (const smartlist_t *transport_list,
/* For each new transport, check if the managed proxy used to
support it before the SIGHUP. If that was the case, make sure
it doesn't get removed because we might reuse it. */
- SMARTLIST_FOREACH_BEGIN(transport_list, const char *, transport) {
+ SMARTLIST_FOREACH_BEGIN(with_transport_list, const char *, transport) {
old_transport = transport_get_by_name(transport);
if (old_transport)
old_transport->marked_for_removal = 0;
} SMARTLIST_FOREACH_END(transport);
}
- SMARTLIST_FOREACH(transport_list, const char *, transport,
+ SMARTLIST_FOREACH(with_transport_list, const char *, transport,
add_transport_to_proxy(transport, mp));
free_execve_args(proxy_argv);
}
diff --git a/src/test/bench.c b/src/test/bench.c
index 5595988..f1cf715 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -662,7 +662,6 @@ main(int argc, const char **argv)
{
int i;
int list=0, n_enabled=0;
- benchmark_t *b;
char *errmsg;
or_options_t *options;
@@ -672,10 +671,10 @@ main(int argc, const char **argv)
if (!strcmp(argv[i], "--list")) {
list = 1;
} else {
- benchmark_t *b = find_benchmark(argv[i]);
+ benchmark_t *benchmark = find_benchmark(argv[i]);
++n_enabled;
- if (b) {
- b->enabled = 1;
+ if (benchmark) {
+ benchmark->enabled = 1;
} else {
printf("No such benchmark as %s\n", argv[i]);
}
@@ -700,7 +699,7 @@ main(int argc, const char **argv)
return 1;
}
- for (b = benchmarks; b->name; ++b) {
+ for (benchmark_t *b = benchmarks; b->name; ++b) {
if (b->enabled || n_enabled == 0) {
printf("===== %s =====\n", b->name);
if (!list)
diff --git a/src/test/test_addr.c b/src/test/test_addr.c
index 337bdda..dcecb0b 100644
--- a/src/test/test_addr.c
+++ b/src/test/test_addr.c
@@ -83,12 +83,12 @@ test_addr_basic(void *arg)
tt_assert_test_fmt_type(a,b,e1" "#op" "e2,struct in6_addr*, \
(memcmp(val1_->s6_addr, val2_->s6_addr, 16) op 0), \
char *, "%s", \
- { int i; char *cp; \
+ { char *cp; \
cp = print_ = tor_malloc(64); \
- for (i=0;i<16;++i) { \
+ for (int ii_=0;i<16;++i) { \
tor_snprintf(cp, 3,"%02x", (unsigned)value_->s6_addr[i]);\
cp += 2; \
- if (i != 15) *cp++ = ':'; \
+ if (ii_ != 15) *cp++ = ':'; \
} \
}, \
{ tor_free(print_); }, \
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index 95584d5..91db62c 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -178,10 +178,10 @@ test_buffers_basic(void *arg)
/* Try adding a string too long for any freelist. */
{
- char *cp = tor_malloc_zero(65536);
+ char *mem = tor_malloc_zero(65536);
buf = buf_new();
- write_to_buf(cp, 65536, buf);
- tor_free(cp);
+ write_to_buf(mem, 65536, buf);
+ tor_free(mem);
tt_int_op(buf_datalen(buf), OP_EQ, 65536);
buf_free(buf);
diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c
index 499a637..f839a5b 100644
--- a/src/test/test_cell_formats.c
+++ b/src/test/test_cell_formats.c
@@ -882,8 +882,8 @@ test_cfmt_resolved_cells(void *arg)
memset(&rh, 0, sizeof(rh)); \
} while (0)
#define CLEAR_ADDRS() do { \
- SMARTLIST_FOREACH(addrs, address_ttl_t *, a, \
- address_ttl_free(a); ); \
+ SMARTLIST_FOREACH(addrs, address_ttl_t *, aa_, \
+ address_ttl_free(aa_); ); \
smartlist_clear(addrs); \
} while (0)
#define SET_CELL(s) do { \
diff --git a/src/test/test_containers.c b/src/test/test_containers.c
index fd89676..d8b82e0 100644
--- a/src/test/test_containers.c
+++ b/src/test/test_containers.c
@@ -132,7 +132,7 @@ test_container_smartlist_strings(void *arg)
tt_str_op("def",OP_EQ, smartlist_get(sl, 5));
tt_str_op(" ",OP_EQ, smartlist_get(sl, 6));
tt_str_op("ghijk",OP_EQ, smartlist_get(sl, 7));
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
smartlist_split_string(sl, "a,bbd,cdef", ",", SPLIT_SKIP_SPACE, 0);
@@ -149,7 +149,7 @@ test_container_smartlist_strings(void *arg)
tt_str_op("bnud",OP_EQ, smartlist_get(sl,6));
tt_str_op("",OP_EQ, smartlist_get(sl,7));
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
smartlist_split_string(sl, " ab\tc \td ef ", NULL,
@@ -165,7 +165,7 @@ test_container_smartlist_strings(void *arg)
tt_str_op("ghi",OP_EQ, smartlist_get(sl,4));
tt_str_op("j",OP_EQ, smartlist_get(sl,5));
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
cp_alloc = smartlist_join_strings(sl, "XY", 0, NULL);
@@ -186,7 +186,7 @@ test_container_smartlist_strings(void *arg)
tt_int_op(5,OP_EQ, smartlist_len(sl));
tt_str_op("z",OP_EQ, smartlist_get(sl, 3));
tt_str_op("zhasd <> <> bnud<>",OP_EQ, smartlist_get(sl, 4));
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
smartlist_split_string(sl, "abcd\n", "\n",
@@ -198,7 +198,7 @@ test_container_smartlist_strings(void *arg)
tt_int_op(2,OP_EQ, smartlist_len(sl));
tt_str_op("efgh",OP_EQ, smartlist_get(sl, 1));
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
/* Test swapping, shuffling, and sorting. */
@@ -286,7 +286,7 @@ test_container_smartlist_strings(void *arg)
tt_str_op(cp_alloc,OP_EQ, "and");
tor_free(cp_alloc);
tt_int_op(smartlist_len(sl),OP_EQ, 6);
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
cp_alloc = smartlist_pop_last(sl);
tt_ptr_op(cp_alloc,OP_EQ, NULL);
@@ -326,7 +326,7 @@ test_container_smartlist_strings(void *arg)
tt_assert(!allsame);
tt_assert(allin);
}
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_clear(sl);
/* Test string_remove and remove and join_strings2 */
@@ -348,7 +348,7 @@ test_container_smartlist_strings(void *arg)
done:
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
tor_free(cp_alloc);
}
@@ -437,7 +437,7 @@ test_container_smartlist_digests(void *arg)
tt_mem_op(smartlist_get(sl, 1),OP_EQ, "AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN);
done:
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
}
@@ -490,7 +490,7 @@ test_container_smartlist_join(void *arg)
smartlist_free(sl3);
SMARTLIST_FOREACH(sl2, char *, cp, tor_free(cp));
smartlist_free(sl2);
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
tor_free(joined);
}
@@ -528,7 +528,7 @@ test_container_smartlist_pos(void *arg)
tt_int_op(smartlist_pos(sl, smartlist_get(sl,6)), ==, 6);
done:
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
}
@@ -1140,7 +1140,7 @@ test_container_smartlist_most_frequent(void *arg)
tt_str_op(cp, ==, "def"); /* No tie */
done:
- SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(sl, char *, str, tor_free(str));
smartlist_free(sl);
}
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 8889ccc..51a5eca 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -704,8 +704,8 @@ test_dir_parse_router_list(void *arg)
"9a651ee03b64325959e8f1b46f2b689b30750b4c");
/* Now tidy up */
- SMARTLIST_FOREACH(dest, routerinfo_t *, ri, routerinfo_free(ri));
- SMARTLIST_FOREACH(invalid, uint8_t *, d, tor_free(d));
+ SMARTLIST_FOREACH(dest, routerinfo_t *, rinfo, routerinfo_free(rinfo));
+ SMARTLIST_FOREACH(invalid, uint8_t *, dig, tor_free(dig));
smartlist_clear(dest);
smartlist_clear(invalid);
@@ -741,9 +741,9 @@ test_dir_parse_router_list(void *arg)
else
SMARTLIST_FOREACH(dest, extrainfo_t *, ei, extrainfo_free(ei));
smartlist_free(dest);
- SMARTLIST_FOREACH(invalid, uint8_t *, d, tor_free(d));
+ SMARTLIST_FOREACH(invalid, uint8_t *, dig, tor_free(dig));
smartlist_free(invalid);
- SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ SMARTLIST_FOREACH(chunks, char *, chunk, tor_free(chunk));
smartlist_free(chunks);
routerinfo_free(ri);
if (map) {
@@ -1169,7 +1169,7 @@ test_dir_fp_pairs(void *arg)
tt_mem_op(pair->second,OP_EQ, "Use AES-256 instead.", DIGEST_LEN);
done:
- SMARTLIST_FOREACH(sl, fp_pair_t *, pair, tor_free(pair));
+ SMARTLIST_FOREACH(sl, fp_pair_t *, pair_to_free, tor_free(pair_to_free));
smartlist_free(sl);
}
diff --git a/src/test/test_dns.c b/src/test/test_dns.c
index 5289ca5..8346c0a 100644
--- a/src/test/test_dns.c
+++ b/src/test/test_dns.c
@@ -52,7 +52,7 @@ NS(test_main)(void *arg)
static int resolve_retval = 0;
static int resolve_made_conn_pending = 0;
static char *resolved_name = NULL;
-static cached_resolve_t *cache_entry = NULL;
+static cached_resolve_t *cache_entry_mock = NULL;
static int n_fake_impl = 0;
@@ -85,8 +85,8 @@ NS(dns_resolve_impl)(edge_connection_t *exitconn, int is_resolve,
if (hostname_out && resolved_name)
*hostname_out = tor_strdup(resolved_name);
- if (resolve_out && cache_entry)
- *resolve_out = cache_entry;
+ if (resolve_out && cache_entry_mock)
+ *resolve_out = cache_entry_mock;
n_fake_impl++;
@@ -213,7 +213,7 @@ NS(test_main)(void *arg)
exitconn->on_circuit = &(on_circuit->base_);
- cache_entry = fake_resolved;
+ cache_entry_mock = fake_resolved;
prev_n_send_resolved_cell_replacement =
n_send_resolved_cell_replacement;
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 2afbdde..2ae605b 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -716,7 +716,7 @@ test_md_parse(void *arg)
tt_int_op(md->ipv6_orport, OP_EQ, 9090);
done:
- SMARTLIST_FOREACH(mds, microdesc_t *, md, microdesc_free(md));
+ SMARTLIST_FOREACH(mds, microdesc_t *, mdsc, microdesc_free(mdsc));
smartlist_free(mds);
SMARTLIST_FOREACH(invalid, char *, cp, tor_free(cp));
smartlist_free(invalid);
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index 14182af..58102ea 100644
--- a/src/test/test_policy.c
+++ b/src/test/test_policy.c
@@ -523,18 +523,17 @@ test_policies_general(void *arg)
/* Test a too-long policy. */
{
- int i;
- char *policy = NULL;
+ char *policy_strng = NULL;
smartlist_t *chunks = smartlist_new();
smartlist_add(chunks, tor_strdup("accept "));
for (i=1; i<10000; ++i)
smartlist_add_asprintf(chunks, "%d,", i);
smartlist_add(chunks, tor_strdup("20000"));
- policy = smartlist_join_strings(chunks, "", 0, NULL);
+ policy_strng = smartlist_join_strings(chunks, "", 0, NULL);
SMARTLIST_FOREACH(chunks, char *, ch, tor_free(ch));
smartlist_free(chunks);
- short_parsed = parse_short_policy(policy);/* shouldn't be accepted */
- tor_free(policy);
+ short_parsed = parse_short_policy(policy_strng);/* shouldn't be accepted */
+ tor_free(policy_strng);
tt_ptr_op(NULL, OP_EQ, short_parsed);
}
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index ab8447d..e5cdc5f 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -107,12 +107,12 @@ test_pt_parsing(void *arg)
tt_assert(parse_smethod_line(line, mp) == 0);
tt_int_op(1, OP_EQ, smartlist_len(mp->transports));
{
- const transport_t *transport = smartlist_get(mp->transports, 0);
- tt_assert(transport);
- tt_str_op(transport->name, OP_EQ, "trebuchet");
- tt_int_op(transport->port, OP_EQ, 9999);
- tt_str_op(fmt_addr(&transport->addr), OP_EQ, "127.0.0.1");
- tt_str_op(transport->extra_info_args, OP_EQ,
+ const transport_t *transport_ = smartlist_get(mp->transports, 0);
+ tt_assert(transport_);
+ tt_str_op(transport_->name, OP_EQ, "trebuchet");
+ tt_int_op(transport_->port, OP_EQ, 9999);
+ tt_str_op(fmt_addr(&transport_->addr), OP_EQ, "127.0.0.1");
+ tt_str_op(transport_->extra_info_args, OP_EQ,
"counterweight=3,sling=snappy");
}
reset_mp(mp);
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c
index 15fbb2d..f8b5046 100644
--- a/src/test/test_scheduler.c
+++ b/src/test/test_scheduler.c
@@ -150,7 +150,7 @@ channel_flush_some_cells_mock_free_all(void)
static void
channel_flush_some_cells_mock_set(channel_t *chan, ssize_t num_cells)
{
- flush_mock_channel_t *flush_mock_ch = NULL;
+ int found = 0;
if (!chan) return;
if (num_cells <= 0) return;
@@ -166,6 +166,7 @@ channel_flush_some_cells_mock_set(channel_t *chan, ssize_t num_cells)
if (flush_mock_ch->chan == chan) {
/* Found it */
flush_mock_ch->cells = num_cells;
+ found = 1;
break;
}
} else {
@@ -175,8 +176,9 @@ channel_flush_some_cells_mock_set(channel_t *chan, ssize_t num_cells)
}
} SMARTLIST_FOREACH_END(flush_mock_ch);
- if (!flush_mock_ch) {
+ if (! found) {
/* The loop didn't find it */
+ flush_mock_channel_t *flush_mock_ch;
flush_mock_ch = tor_malloc_zero(sizeof(*flush_mock_ch));
flush_mock_ch->chan = chan;
flush_mock_ch->cells = num_cells;
diff --git a/src/test/test_util.c b/src/test/test_util.c
index c331a66..7cb9311 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2007,9 +2007,9 @@ test_util_strmisc(void *arg)
/* Test hex_str */
{
char binary_data[68];
- size_t i;
- for (i = 0; i < sizeof(binary_data); ++i)
- binary_data[i] = i;
+ size_t idx;
+ for (idx = 0; idx < sizeof(binary_data); ++idx)
+ binary_data[idx] = idx;
tt_str_op(hex_str(binary_data, 0),OP_EQ, "");
tt_str_op(hex_str(binary_data, 1),OP_EQ, "00");
tt_str_op(hex_str(binary_data, 17),OP_EQ,
1
0