qeueue.h: Add {SLIST,STAILQ,LIST,TAILQ}_END()

We provide these for compat with other queue.h headers since some software
assumes it exists (e.g. the libevent contrib code), but we are not
encouraging their use (NULL should be used instead).

This fixes the following warning (which should arguable be an error since
it results in a function call to an undefined function):

.../contrib/libevent/buffer.c:495:16: warning: implicit declaration of function 'LIST_END' is invalid in C99 [-Wimplicit-function-declaration]
             cbent != LIST_END(&buffer->callbacks);
                      ^
.../contrib/libevent/buffer.c:495:13: warning: comparison between pointer and integer ('struct evbuffer_cb_entry *' and 'int') [-Wpointer-integer-compare]
             cbent != LIST_END(&buffer->callbacks);
             ~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D27151
This commit is contained in:
Alex Richardson 2021-01-25 14:11:45 +00:00
parent 3454fa118c
commit 8d55837dc1
2 changed files with 12 additions and 0 deletions

View File

@ -880,9 +880,11 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *);
/*
* Some queue.h files don't have these dfined in them.
*/
#ifndef LIST_END
#define LIST_END(head) NULL
#define SLIST_END(head) NULL
#define TAILQ_END(head) NULL
#endif
/*
* This must be defined to be a global variable that increments once

View File

@ -91,6 +91,7 @@
* _CLASS_ENTRY + + + +
* _INIT + + + +
* _EMPTY + + + +
* _END + + + +
* _FIRST + + + +
* _NEXT + + + +
* _PREV - + - +
@ -305,6 +306,8 @@ struct { \
SLIST_FIRST(head2) = swap_first; \
} while (0)
#define SLIST_END(head) NULL
/*
* Singly-linked Tail queue declarations.
*/
@ -437,6 +440,9 @@ struct { \
(head2)->stqh_last = &STAILQ_FIRST(head2); \
} while (0)
#define STAILQ_END(head) NULL
/*
* List declarations.
*/
@ -611,6 +617,8 @@ struct { \
swap_tmp->field.le_prev = &LIST_FIRST((head2)); \
} while (0)
#define LIST_END(head) NULL
/*
* Tail queue declarations.
*/
@ -867,4 +875,6 @@ struct { \
(head2)->tqh_last = &(head2)->tqh_first; \
} while (0)
#define TAILQ_END(head) NULL
#endif /* !_SYS_QUEUE_H_ */