> On 25 Sep 2016, at 01:32, Mark Kettenis <[email protected]> wrote: > > clang warns by default about static functions that are unused. It > does this even for static inline functions, except when those > functions are defined in a header file. The RBT code in <sys/tree.h> > has macros that define static inline functions. Unfortunately that > means that the inline functions generated by those macros trigger the > warning when they're not used. The diff below marks them as __unused, > to suppress this warning. With this change, both gcc and clang only > emit the functions that are actually used. > > ok?
ok.
>
>
> Index: sys/tree.h
> ===================================================================
> RCS file: /cvs/src/sys/sys/tree.h,v
> retrieving revision 1.24
> diff -u -p -r1.24 tree.h
> --- sys/tree.h 15 Sep 2016 06:07:22 -0000 1.24
> +++ sys/tree.h 24 Sep 2016 15:26:41 -0000
> @@ -823,97 +823,97 @@ int _rb_check(const struct rb_type *, v
> #define RBT_PROTOTYPE(_name, _type, _field, _cmp) \
> extern const struct rb_type *const _name##_RBT_TYPE; \
> \
> -static inline void \
> +__unused static inline void \
> _name##_RBT_INIT(struct _name *head) \
> { \
> _rb_init(&head->rbh_root); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_INSERT(struct _name *head, struct _type *elm) \
> { \
> return _rb_insert(_name##_RBT_TYPE, &head->rbh_root, elm); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_REMOVE(struct _name *head, struct _type *elm) \
> { \
> return _rb_remove(_name##_RBT_TYPE, &head->rbh_root, elm); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_FIND(struct _name *head, const struct _type *key) \
> { \
> return _rb_find(_name##_RBT_TYPE, &head->rbh_root, key); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_NFIND(struct _name *head, const struct _type *key)
> \
> { \
> return _rb_nfind(_name##_RBT_TYPE, &head->rbh_root, key); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_ROOT(struct _name *head) \
> { \
> return _rb_root(_name##_RBT_TYPE, &head->rbh_root); \
> } \
> \
> -static inline int \
> +__unused static inline int \
> _name##_RBT_EMPTY(struct _name *head) \
> { \
> return _rb_empty(&head->rbh_root); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_MIN(struct _name *head) \
> { \
> return _rb_min(_name##_RBT_TYPE, &head->rbh_root); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_MAX(struct _name *head) \
> { \
> return _rb_max(_name##_RBT_TYPE, &head->rbh_root); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_NEXT(struct _type *elm) \
> { \
> return _rb_next(_name##_RBT_TYPE, elm); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_PREV(struct _type *elm) \
> { \
> return _rb_prev(_name##_RBT_TYPE, elm); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_LEFT(struct _type *elm) \
> { \
> return _rb_left(_name##_RBT_TYPE, elm); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_RIGHT(struct _type *elm) \
> { \
> return _rb_right(_name##_RBT_TYPE, elm); \
> } \
> \
> -static inline struct _type * \
> +__unused static inline struct _type *
> \
> _name##_RBT_PARENT(struct _type *elm) \
> { \
> return _rb_parent(_name##_RBT_TYPE, elm); \
> } \
> \
> -static inline void \
> +__unused static inline void \
> _name##_RBT_POISON(struct _type *elm, unsigned long poison) \
> { \
> return _rb_poison(_name##_RBT_TYPE, elm, poison); \
> } \
> \
> -static inline int \
> +__unused static inline int \
> _name##_RBT_CHECK(struct _type *elm, unsigned long poison) \
> { \
> return _rb_check(_name##_RBT_TYPE, elm, poison); \
>
