mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
gcc/clang: Mark macro-generated functions as possible unused
clang 3.4 introduced a new by-default warning about unused static functions, which we triggered heavily for the hashtable and map function generating macros. We can use __attribute__ ((unused)) (thanks nickm for the suggestion :-) ) to silence these warnings.
This commit is contained in:
parent
d6e6eaba60
commit
3f567f529f
@ -162,6 +162,7 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
|
|||||||
*
|
*
|
||||||
* #define ATTR_NONNULL(x) __attribute__((nonnull x)) */
|
* #define ATTR_NONNULL(x) __attribute__((nonnull x)) */
|
||||||
#define ATTR_NONNULL(x)
|
#define ATTR_NONNULL(x)
|
||||||
|
#define ATTR_UNUSED __attribute__ ((unused))
|
||||||
|
|
||||||
/** Macro: Evaluates to <b>exp</b> and hints the compiler that the value
|
/** Macro: Evaluates to <b>exp</b> and hints the compiler that the value
|
||||||
* of <b>exp</b> will probably be true.
|
* of <b>exp</b> will probably be true.
|
||||||
@ -185,6 +186,7 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
|
|||||||
#define ATTR_MALLOC
|
#define ATTR_MALLOC
|
||||||
#define ATTR_NORETURN
|
#define ATTR_NORETURN
|
||||||
#define ATTR_NONNULL(x)
|
#define ATTR_NONNULL(x)
|
||||||
|
#define ATTR_UNUSED
|
||||||
#define PREDICT_LIKELY(exp) (exp)
|
#define PREDICT_LIKELY(exp) (exp)
|
||||||
#define PREDICT_UNLIKELY(exp) (exp)
|
#define PREDICT_UNLIKELY(exp) (exp)
|
||||||
#endif
|
#endif
|
||||||
|
@ -471,56 +471,65 @@ void* strmap_remove_lc(strmap_t *map, const char *key);
|
|||||||
#define DECLARE_TYPED_DIGESTMAP_FNS(prefix, maptype, valtype) \
|
#define DECLARE_TYPED_DIGESTMAP_FNS(prefix, maptype, valtype) \
|
||||||
typedef struct maptype maptype; \
|
typedef struct maptype maptype; \
|
||||||
typedef struct prefix##iter_t prefix##iter_t; \
|
typedef struct prefix##iter_t prefix##iter_t; \
|
||||||
static INLINE maptype* prefix##new(void) \
|
ATTR_UNUSED static INLINE maptype* \
|
||||||
|
prefix##new(void) \
|
||||||
{ \
|
{ \
|
||||||
return (maptype*)digestmap_new(); \
|
return (maptype*)digestmap_new(); \
|
||||||
} \
|
} \
|
||||||
static INLINE digestmap_t* prefix##to_digestmap(maptype *map) \
|
ATTR_UNUSED static INLINE digestmap_t* \
|
||||||
|
prefix##to_digestmap(maptype *map) \
|
||||||
{ \
|
{ \
|
||||||
return (digestmap_t*)map; \
|
return (digestmap_t*)map; \
|
||||||
} \
|
} \
|
||||||
static INLINE valtype* prefix##get(maptype *map, const char *key) \
|
ATTR_UNUSED static INLINE valtype* \
|
||||||
|
prefix##get(maptype *map, const char *key) \
|
||||||
{ \
|
{ \
|
||||||
return (valtype*)digestmap_get((digestmap_t*)map, key); \
|
return (valtype*)digestmap_get((digestmap_t*)map, key); \
|
||||||
} \
|
} \
|
||||||
static INLINE valtype* prefix##set(maptype *map, const char *key, \
|
ATTR_UNUSED static INLINE valtype* \
|
||||||
valtype *val) \
|
prefix##set(maptype *map, const char *key, valtype *val) \
|
||||||
{ \
|
{ \
|
||||||
return (valtype*)digestmap_set((digestmap_t*)map, key, val); \
|
return (valtype*)digestmap_set((digestmap_t*)map, key, val); \
|
||||||
} \
|
} \
|
||||||
static INLINE valtype* prefix##remove(maptype *map, const char *key) \
|
ATTR_UNUSED static INLINE valtype* \
|
||||||
|
prefix##remove(maptype *map, const char *key) \
|
||||||
{ \
|
{ \
|
||||||
return (valtype*)digestmap_remove((digestmap_t*)map, key); \
|
return (valtype*)digestmap_remove((digestmap_t*)map, key); \
|
||||||
} \
|
} \
|
||||||
static INLINE void prefix##free(maptype *map, void (*free_val)(void*)) \
|
ATTR_UNUSED static INLINE void \
|
||||||
|
prefix##free(maptype *map, void (*free_val)(void*)) \
|
||||||
{ \
|
{ \
|
||||||
digestmap_free((digestmap_t*)map, free_val); \
|
digestmap_free((digestmap_t*)map, free_val); \
|
||||||
} \
|
} \
|
||||||
static INLINE int prefix##isempty(maptype *map) \
|
ATTR_UNUSED static INLINE int \
|
||||||
|
prefix##isempty(maptype *map) \
|
||||||
{ \
|
{ \
|
||||||
return digestmap_isempty((digestmap_t*)map); \
|
return digestmap_isempty((digestmap_t*)map); \
|
||||||
} \
|
} \
|
||||||
static INLINE int prefix##size(maptype *map) \
|
ATTR_UNUSED static INLINE int \
|
||||||
|
prefix##size(maptype *map) \
|
||||||
{ \
|
{ \
|
||||||
return digestmap_size((digestmap_t*)map); \
|
return digestmap_size((digestmap_t*)map); \
|
||||||
} \
|
} \
|
||||||
static INLINE prefix##iter_t *prefix##iter_init(maptype *map) \
|
ATTR_UNUSED static INLINE \
|
||||||
|
prefix##iter_t *prefix##iter_init(maptype *map) \
|
||||||
{ \
|
{ \
|
||||||
return (prefix##iter_t*) digestmap_iter_init((digestmap_t*)map); \
|
return (prefix##iter_t*) digestmap_iter_init((digestmap_t*)map); \
|
||||||
} \
|
} \
|
||||||
static INLINE prefix##iter_t *prefix##iter_next(maptype *map, \
|
ATTR_UNUSED static INLINE \
|
||||||
prefix##iter_t *iter) \
|
prefix##iter_t *prefix##iter_next(maptype *map, prefix##iter_t *iter) \
|
||||||
{ \
|
{ \
|
||||||
return (prefix##iter_t*) digestmap_iter_next( \
|
return (prefix##iter_t*) digestmap_iter_next( \
|
||||||
(digestmap_t*)map, (digestmap_iter_t*)iter); \
|
(digestmap_t*)map, (digestmap_iter_t*)iter); \
|
||||||
} \
|
} \
|
||||||
static INLINE prefix##iter_t *prefix##iter_next_rmv(maptype *map, \
|
ATTR_UNUSED static INLINE prefix##iter_t* \
|
||||||
prefix##iter_t *iter) \
|
prefix##iter_next_rmv(maptype *map, prefix##iter_t *iter) \
|
||||||
{ \
|
{ \
|
||||||
return (prefix##iter_t*) digestmap_iter_next_rmv( \
|
return (prefix##iter_t*) digestmap_iter_next_rmv( \
|
||||||
(digestmap_t*)map, (digestmap_iter_t*)iter); \
|
(digestmap_t*)map, (digestmap_iter_t*)iter); \
|
||||||
} \
|
} \
|
||||||
static INLINE void prefix##iter_get(prefix##iter_t *iter, \
|
ATTR_UNUSED static INLINE void \
|
||||||
|
prefix##iter_get(prefix##iter_t *iter, \
|
||||||
const char **keyp, \
|
const char **keyp, \
|
||||||
valtype **valp) \
|
valtype **valp) \
|
||||||
{ \
|
{ \
|
||||||
@ -528,7 +537,8 @@ void* strmap_remove_lc(strmap_t *map, const char *key);
|
|||||||
digestmap_iter_get((digestmap_iter_t*) iter, keyp, &v); \
|
digestmap_iter_get((digestmap_iter_t*) iter, keyp, &v); \
|
||||||
*valp = v; \
|
*valp = v; \
|
||||||
} \
|
} \
|
||||||
static INLINE int prefix##iter_done(prefix##iter_t *iter) \
|
ATTR_UNUSED static INLINE int \
|
||||||
|
prefix##iter_done(prefix##iter_t *iter) \
|
||||||
{ \
|
{ \
|
||||||
return digestmap_iter_done((digestmap_iter_t*)iter); \
|
return digestmap_iter_done((digestmap_iter_t*)iter); \
|
||||||
}
|
}
|
||||||
|
16
src/ext/ht.h
16
src/ext/ht.h
@ -168,7 +168,7 @@ ht_string_hash(const char *s)
|
|||||||
} \
|
} \
|
||||||
/* Insert the element 'elm' into the table 'head'. Do not call this \
|
/* Insert the element 'elm' into the table 'head'. Do not call this \
|
||||||
* function if the table might already contain a matching element. */ \
|
* 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) \
|
name##_HT_INSERT(struct name *head, struct type *elm) \
|
||||||
{ \
|
{ \
|
||||||
struct type **p; \
|
struct type **p; \
|
||||||
@ -183,7 +183,7 @@ ht_string_hash(const char *s)
|
|||||||
/* Insert the element 'elm' into the table 'head'. If there already \
|
/* Insert the element 'elm' into the table 'head'. If there already \
|
||||||
* a matching element in the table, replace that element and return \
|
* a matching element in the table, replace that element and return \
|
||||||
* it. */ \
|
* it. */ \
|
||||||
static INLINE struct type * \
|
ATTR_UNUSED static INLINE struct type * \
|
||||||
name##_HT_REPLACE(struct name *head, struct type *elm) \
|
name##_HT_REPLACE(struct name *head, struct type *elm) \
|
||||||
{ \
|
{ \
|
||||||
struct type **p, *r; \
|
struct type **p, *r; \
|
||||||
@ -204,7 +204,7 @@ ht_string_hash(const char *s)
|
|||||||
} \
|
} \
|
||||||
/* Remove any element matching 'elm' from the table 'head'. If such \
|
/* Remove any element matching 'elm' from the table 'head'. If such \
|
||||||
* an element is found, return it; otherwise return NULL. */ \
|
* 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) \
|
name##_HT_REMOVE(struct name *head, struct type *elm) \
|
||||||
{ \
|
{ \
|
||||||
struct type **p, *r; \
|
struct type **p, *r; \
|
||||||
@ -222,11 +222,11 @@ ht_string_hash(const char *s)
|
|||||||
* using 'data' as its second argument. If the function returns \
|
* using 'data' as its second argument. If the function returns \
|
||||||
* nonzero, remove the most recently examined element before invoking \
|
* nonzero, remove the most recently examined element before invoking \
|
||||||
* the function again. */ \
|
* the function again. */ \
|
||||||
static INLINE void \
|
ATTR_UNUSED static INLINE void \
|
||||||
name##_HT_FOREACH_FN(struct name *head, \
|
name##_HT_FOREACH_FN(struct name *head, \
|
||||||
int (*fn)(struct type *, void *), \
|
int (*fn)(struct type *, void *), \
|
||||||
void *data) \
|
void *data) \
|
||||||
{ \
|
{ \
|
||||||
unsigned idx; \
|
unsigned idx; \
|
||||||
struct type **p, **nextp, *next; \
|
struct type **p, **nextp, *next; \
|
||||||
if (!head->hth_table) \
|
if (!head->hth_table) \
|
||||||
@ -248,7 +248,7 @@ ht_string_hash(const char *s)
|
|||||||
/* Return a pointer to the first element in the table 'head', under \
|
/* Return a pointer to the first element in the table 'head', under \
|
||||||
* an arbitrary order. This order is stable under remove operations, \
|
* an arbitrary order. This order is stable under remove operations, \
|
||||||
* but not under others. If the table is empty, return NULL. */ \
|
* 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) \
|
name##_HT_START(struct name *head) \
|
||||||
{ \
|
{ \
|
||||||
unsigned b = 0; \
|
unsigned b = 0; \
|
||||||
@ -264,7 +264,7 @@ ht_string_hash(const char *s)
|
|||||||
* NULL. If 'elm' is to be removed from the table, you must call \
|
* NULL. If 'elm' is to be removed from the table, you must call \
|
||||||
* this function for the next value before you remove it. \
|
* 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) \
|
name##_HT_NEXT(struct name *head, struct type **elm) \
|
||||||
{ \
|
{ \
|
||||||
if ((*elm)->field.hte_next) { \
|
if ((*elm)->field.hte_next) { \
|
||||||
@ -280,7 +280,7 @@ ht_string_hash(const char *s)
|
|||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
static INLINE struct type ** \
|
ATTR_UNUSED static INLINE struct type ** \
|
||||||
name##_HT_NEXT_RMV(struct name *head, struct type **elm) \
|
name##_HT_NEXT_RMV(struct name *head, struct type **elm) \
|
||||||
{ \
|
{ \
|
||||||
unsigned h = HT_ELT_HASH_(*elm, field, hashfn); \
|
unsigned h = HT_ELT_HASH_(*elm, field, hashfn); \
|
||||||
|
Loading…
Reference in New Issue
Block a user