Page MenuHomeFreeBSD

Allow RB_NEXT and RB_PREV to accept either 2 or 3 arguments.
AbandonedPublic

Authored by jhb on Apr 8 2022, 6:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 22, 4:01 AM
Unknown Object (File)
Oct 19 2025, 1:56 PM
Unknown Object (File)
Oct 19 2025, 1:56 PM
Unknown Object (File)
Oct 18 2025, 11:21 PM
Unknown Object (File)
Oct 7 2025, 12:30 AM
Unknown Object (File)
Sep 9 2025, 10:16 AM
Unknown Object (File)
Sep 7 2025, 1:59 PM
Unknown Object (File)
Sep 4 2025, 10:25 AM

Details

Reviewers
kp
emaste
imp
Group Reviewers
manpages
Summary

The middle argument to RB_NEXT (specifying the head) has not been used
for several years and has never been used for RB_PREV. Use a trick
with VA_ARGS to permit macro overloading to add a 2 argument
version of these macros that omits the unused argument.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 45081
Build 41969: arc lint + arc unit

Event Timeline

jhb requested review of this revision.Apr 8 2022, 6:02 PM

This lets me adjust D34833 to drop the unused argument entirely instead.

If we aren't completely revolted by this approach, I have other Plans (tm) such as a CTR() wrapper for KTR traces that takes a variable number of arguments (already written, not yet tested), but a bigger fish I want to fry: making the mostly useless 'devclass' argument to DRIVER_MODULE optional.

Some consensus on IRC is that this might be a bit overkill compared to just working around the warning in pf(4).

Will this trick make it possible to collapse TAILQ_LAST and TAILQ_LAST_FAST into single macro that runs fast if has all 3 arguments?

It would perhaps let you have TAILQ_LAST take either 2 or 3 arguments and call the fast variant when given 3 arguments. However, that particular use case seems a bit more odd as the 3 arguments aren't just an additional argument to the 2, but different arguments, so overloading TAILQ_LAST in that way may be a bit less obvious.