diff options
author | teor <teor2345@gmail.com> | 2014-10-26 14:43:55 +1100 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2014-10-30 22:34:46 +1100 |
commit | 13298d90a90dc62d21d38f910171c9b57a8f0273 (patch) | |
tree | df91745009bef0a26901438d361036f039e9b00f /src/ext | |
parent | acc392856d255059949bb22d2daf56c61f3fd76d (diff) | |
download | tor-13298d90a90dc62d21d38f910171c9b57a8f0273.tar.gz tor-13298d90a90dc62d21d38f910171c9b57a8f0273.zip |
Silence spurious clang warnings
Silence clang warnings under --enable-expensive-hardening, including:
+ implicit truncation of 64 bit values to 32 bit;
+ const char assignment to self;
+ tautological compare; and
+ additional parentheses around equality tests. (gcc uses these to
silence assignment, so clang warns when they're present in an
equality test. But we need to use extra parentheses in macros to
isolate them from other code).
Diffstat (limited to 'src/ext')
-rw-r--r-- | src/ext/ht.h | 3 | ||||
-rw-r--r-- | src/ext/tor_queue.h | 23 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/ext/ht.h b/src/ext/ht.h index 1cca28ef4d..09f5dcccd5 100644 --- a/src/ext/ht.h +++ b/src/ext/ht.h @@ -38,8 +38,9 @@ } #endif +/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ #define HT_EMPTY(head) \ - ((head)->hth_n_entries == 0) + (((head)->hth_n_entries == 0) || 0) /* How many elements in 'head'? */ #define HT_SIZE(head) \ diff --git a/src/ext/tor_queue.h b/src/ext/tor_queue.h index f05e48c18e..a6530c2b9b 100644 --- a/src/ext/tor_queue.h +++ b/src/ext/tor_queue.h @@ -109,7 +109,8 @@ struct { \ */ #define TOR_SLIST_FIRST(head) ((head)->slh_first) #define TOR_SLIST_END(head) NULL -#define TOR_SLIST_EMPTY(head) (SLIST_FIRST(head) == TOR_SLIST_END(head)) +/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ +#define TOR_SLIST_EMPTY(head) ((SLIST_FIRST(head) == TOR_SLIST_END(head)) || 0) #define TOR_SLIST_NEXT(elm, field) ((elm)->field.sle_next) #define TOR_SLIST_FOREACH(var, head, field) \ @@ -181,9 +182,11 @@ struct { \ /* * List access methods */ -#define TOR_LIST_FIRST(head) ((head)->lh_first) -#define TOR_LIST_END(head) NULL -#define TOR_LIST_EMPTY(head) (TOR_LIST_FIRST(head) == TOR_LIST_END(head)) +#define TOR_LIST_FIRST(head) ((head)->lh_first) +#define TOR_LIST_END(head) NULL +/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ +#define TOR_LIST_EMPTY(head) \ + ((TOR_LIST_FIRST(head) == TOR_LIST_END(head)) || 0) #define TOR_LIST_NEXT(elm, field) ((elm)->field.le_next) #define TOR_LIST_FOREACH(var, head, field) \ @@ -265,8 +268,10 @@ struct { \ * Simple queue access methods. */ #define TOR_SIMPLEQ_FIRST(head) ((head)->sqh_first) -#define TOR_SIMPLEQ_END(head) NULL -#define TOR_SIMPLEQ_EMPTY(head) (TOR_SIMPLEQ_FIRST(head) == TOR_SIMPLEQ_END(head)) +#define TOR_SIMPLEQ_END(head) NULL +/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ +#define TOR_SIMPLEQ_EMPTY(head) \ + ((TOR_SIMPLEQ_FIRST(head) == TOR_SIMPLEQ_END(head)) || 0) #define TOR_SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next) #define TOR_SIMPLEQ_FOREACH(var, head, field) \ @@ -345,8 +350,9 @@ struct { \ /* XXX */ #define TOR_TAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) +/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ #define TOR_TAILQ_EMPTY(head) \ - (TOR_TAILQ_FIRST(head) == TOR_TAILQ_END(head)) + ((TOR_TAILQ_FIRST(head) == TOR_TAILQ_END(head)) || 0) #define TOR_TAILQ_FOREACH(var, head, field) \ for((var) = TOR_TAILQ_FIRST(head); \ @@ -462,8 +468,9 @@ struct { \ #define TOR_CIRCLEQ_END(head) ((void *)(head)) #define TOR_CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) #define TOR_CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) +/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */ #define TOR_CIRCLEQ_EMPTY(head) \ - (TOR_CIRCLEQ_FIRST(head) == TOR_CIRCLEQ_END(head)) + ((TOR_CIRCLEQ_FIRST(head) == TOR_CIRCLEQ_END(head)) || 0) #define TOR_CIRCLEQ_FOREACH(var, head, field) \ for((var) = TOR_CIRCLEQ_FIRST(head); \ |