Skip to content

Commit

Permalink
Fix nonstandard TAILQ_FOREACH_REVERSE() definition
Browse files Browse the repository at this point in the history
Every current BSD system providing TAILQ_* macros define
TAILQ_FOREACH_REVERSE in this order:

TAILQ_FOREACH_REVERSE(var, head, field, headname)

However, libevent defines it in another order:

TAILQ_FOREACH_REVERSE(var, head, headname, field)

Here's a trivial patch to have libevent compatible with stock queue.h headers.

-Frank.

[From sourceforge patch 2995179. codesearch.google.com confirms that
the only people defining TAILQ_FOREACH_REVERSE our way are people
using it in a compatibility header like us.  Did we copy this from
OpenSSH or something?]

-Nick
  • Loading branch information
Frank Denis authored and nmathewson committed May 3, 2010
1 parent 953e229 commit 71afc52
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compat/sys/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ struct { \
(var) != TAILQ_END(head); \
(var) = TAILQ_NEXT(var, field))

#define TAILQ_FOREACH_REVERSE(var, head, field, headname) \
#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \
for((var) = TAILQ_LAST(head, headname); \
(var) != TAILQ_END(head); \
(var) = TAILQ_PREV(var, headname, field))
Expand Down
2 changes: 1 addition & 1 deletion event.c
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ insert_common_timeout_inorder(struct common_timeout_list *ctl,
* the end of 'ev' to find the right insertion point.
*/
TAILQ_FOREACH_REVERSE(e, &ctl->events,
ev_timeout_pos.ev_next_with_common_timeout, event_list) {
event_list, ev_timeout_pos.ev_next_with_common_timeout) {
/* This timercmp is a little sneaky, since both ev and e have
* magic values in tv_usec. Fortunately, they ought to have
* the _same_ magic values in tv_usec. Let's assert for that.
Expand Down

0 comments on commit 71afc52

Please sign in to comment.