[tor-commits] [torsocks/master] Remove clang warnings
dgoulet at torproject.org
dgoulet at torproject.org
Fri Feb 24 16:59:08 UTC 2017
commit a495bf1ef231da351a7e7430380699492a4ccd7c
Author: David Goulet <dgoulet at ev0ke.net>
Date: Fri Feb 24 11:57:03 2017 -0500
Remove clang warnings
The ht.h generated functions are now flagged with ATTR_UNUSED so the
compiler knows to ignore the warnings if unused.
Remove -fno-strict-overflow as well. Not needed for gcc and clang
doesn't have it.
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
configure.ac | 3 ---
src/common/ht.h | 27 ++++++++++++++-------------
src/common/macros.h | 4 ++++
3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index f5dd992..f6fdb0e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,9 +252,6 @@ AX_CHECK_COMPILE_FLAG([--param ssp-buffer-size=1],
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],
[CFLAGS="$CFLAGS -fstack-protector-all"],[],[]
)
-AX_CHECK_COMPILE_FLAG([-fno-strict-overflow],
- [CFLAGS="$CFLAGS -fno-strict-overflow"],[],[]
-)
dnl Add hardening linker flags
AX_CHECK_LINK_FLAG([-pie],[LDFLAGS="$LDFLAGS -pie"],[],[])
diff --git a/src/common/ht.h b/src/common/ht.h
index e2fb809..b3d858e 100644
--- a/src/common/ht.h
+++ b/src/common/ht.h
@@ -133,7 +133,7 @@ ht_string_hash(const char *s)
int name##_HT_GROW(struct name *ht, unsigned min_capacity); \
void name##_HT_CLEAR(struct name *ht); \
int name##_HT_REP_IS_BAD_(const struct name *ht); \
- static inline void \
+ ATTR_UNUSED static inline void \
name##_HT_INIT(struct name *head) { \
head->hth_table_length = 0; \
head->hth_table = NULL; \
@@ -143,7 +143,7 @@ ht_string_hash(const char *s)
} \
/* Helper: returns a pointer to the right location in the table \
* 'head' to find or insert the element 'elm'. */ \
- static inline struct type ** \
+ ATTR_UNUSED static inline struct type ** \
name##_HT_FIND_P_(struct name *head, struct type *elm) \
{ \
struct type **p; \
@@ -157,9 +157,9 @@ ht_string_hash(const char *s)
} \
return p; \
} \
- /* Return a pointer to the element in the table 'head' matching 'elm', \
- * or NULL if no such element exists */ \
- static inline struct type * \
+ /* Return a pointer to the element in the table 'head' matching \
+ * 'elm', or NULL if no such element exists */ \
+ ATTR_UNUSED static inline struct type * \
name##_HT_FIND(const struct name *head, struct type *elm) \
{ \
struct type **p; \
@@ -170,11 +170,12 @@ ht_string_hash(const char *s)
} \
/* Insert the element 'elm' into the table 'head'. Do not call this \
* function if the table might already contain a matching element. */ \
- static inline void \
+ ATTR_UNUSED static inline void \
name##_HT_INSERT(struct name *head, struct type *elm) \
{ \
struct type **p; \
- if (!head->hth_table || head->hth_n_entries >= head->hth_load_limit) \
+ if (!head->hth_table || \
+ head->hth_n_entries >= head->hth_load_limit) \
name##_HT_GROW(head, head->hth_n_entries+1); \
++head->hth_n_entries; \
HT_SET_HASH_(elm, field, hashfn); \
@@ -185,7 +186,7 @@ ht_string_hash(const char *s)
/* Insert the element 'elm' into the table 'head'. If there already \
* a matching element in the table, replace that element and return \
* it. */ \
- static inline struct type * \
+ ATTR_UNUSED static inline struct type * \
name##_HT_REPLACE(struct name *head, struct type *elm) \
{ \
struct type **p, *r; \
@@ -206,7 +207,7 @@ ht_string_hash(const char *s)
} \
/* Remove any element matching 'elm' from the table 'head'. If such \
* an element is found, return it; otherwise return NULL. */ \
- static inline struct type * \
+ ATTR_UNUSED static inline struct type * \
name##_HT_REMOVE(struct name *head, struct type *elm) \
{ \
struct type **p, *r; \
@@ -224,7 +225,7 @@ ht_string_hash(const char *s)
* using 'data' as its second argument. If the function returns \
* nonzero, remove the most recently examined element before invoking \
* the function again. */ \
- static inline void \
+ ATTR_UNUSED static inline void \
name##_HT_FOREACH_FN(struct name *head, \
int (*fn)(struct type *, void *), \
void *data) \
@@ -250,7 +251,7 @@ ht_string_hash(const char *s)
/* Return a pointer to the first element in the table 'head', under \
* an arbitrary order. This order is stable under remove operations, \
* but not under others. If the table is empty, return NULL. */ \
- static inline struct type ** \
+ ATTR_UNUSED static inline struct type ** \
name##_HT_START(struct name *head) \
{ \
unsigned b = 0; \
@@ -266,7 +267,7 @@ ht_string_hash(const char *s)
* NULL. If 'elm' is to be removed from the table, you must call \
* this function for the next value before you remove it. \
*/ \
- static inline struct type ** \
+ ATTR_UNUSED static inline struct type ** \
name##_HT_NEXT(struct name *head, struct type **elm) \
{ \
if ((*elm)->field.hte_next) { \
@@ -282,7 +283,7 @@ ht_string_hash(const char *s)
return NULL; \
} \
} \
- static inline struct type ** \
+ ATTR_UNUSED static inline struct type ** \
name##_HT_NEXT_RMV(struct name *head, struct type **elm) \
{ \
unsigned h = HT_ELT_HASH_(*elm, field, hashfn); \
diff --git a/src/common/macros.h b/src/common/macros.h
index 8b52814..92ede22 100644
--- a/src/common/macros.h
+++ b/src/common/macros.h
@@ -41,6 +41,10 @@
#define ATTR_HIDDEN __attribute__((visibility("hidden")))
#endif
+#ifndef ATTR_UNUSED
+#define ATTR_UNUSED __attribute__ ((unused))
+#endif
+
#ifndef min
#define min(a, b) ((a) < (b) ? (a) : (b))
#endif
More information about the tor-commits
mailing list