summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug14001-clang-warning6
-rw-r--r--src/common/address.c3
-rw-r--r--src/common/log.c2
-rw-r--r--src/or/connection_edge.c11
4 files changed, 19 insertions, 3 deletions
diff --git a/changes/bug14001-clang-warning b/changes/bug14001-clang-warning
new file mode 100644
index 0000000000..b932af6ab7
--- /dev/null
+++ b/changes/bug14001-clang-warning
@@ -0,0 +1,6 @@
+ o Minor bugfixes:
+ - The address of an array in the middle of a structure will
+ always be non-NULL. clang recognises this and complains.
+ Disable the tautologous and redundant check to silence
+ this warning.
+ Fixes bug 14001.
diff --git a/src/common/address.c b/src/common/address.c
index a3b5df66bc..0b475fc9fd 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1119,7 +1119,8 @@ fmt_addr32(uint32_t addr)
int
tor_addr_parse(tor_addr_t *addr, const char *src)
{
- char *tmp = NULL; /* Holds substring if we got a dotted quad. */
+ /* Holds substring of IPv6 address after removing square brackets */
+ char *tmp = NULL;
int result;
struct in_addr in_tmp;
struct in6_addr in6_tmp;
diff --git a/src/common/log.c b/src/common/log.c
index ad0da7da6b..0a21ffbd44 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -451,7 +451,7 @@ MOCK_IMPL(STATIC void,
logv,(int severity, log_domain_mask_t domain, const char *funcname,
const char *suffix, const char *format, va_list ap))
{
- char buf[10024];
+ char buf[10240];
size_t msg_len = 0;
int formatted = 0;
logfile_t *lf;
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 9ace375d74..9859cc26ea 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -744,8 +744,17 @@ connection_ap_fail_onehop(const char *failed_digest,
/* we don't know the digest; have to compare addr:port */
tor_addr_t addr;
if (!build_state || !build_state->chosen_exit ||
- !entry_conn->socks_request || !entry_conn->socks_request->address)
+ !entry_conn->socks_request) {
+ /* clang thinks that an array midway through a structure
+ * will never have a NULL address, under either:
+ * -Wpointer-bool-conversion if using !, or
+ * -Wtautological-pointer-compare if using == or !=
+ * It's probably right (unless pointers overflow and wrap),
+ * so we just skip this check
+ || !entry_conn->socks_request->address
+ */
continue;
+ }
if (tor_addr_parse(&addr, entry_conn->socks_request->address)<0 ||
!tor_addr_eq(&build_state->chosen_exit->addr, &addr) ||
build_state->chosen_exit->port != entry_conn->socks_request->port)