core: Introduce list iteration helpers
authorChris Dickens <christopher.a.dickens@gmail.com>
Tue, 11 Aug 2020 02:01:42 +0000 (19:01 -0700)
committerChris Dickens <christopher.a.dickens@gmail.com>
Tue, 11 Aug 2020 02:01:42 +0000 (19:01 -0700)
commit9576ad4b8f94698aeba5218caf9e9e1f28a6f44d
tree77443a6323fd8518c6c98e8cff764e18d395b95d
parent96898a25ccfde6e87737991000a41695ed6b3812
core: Introduce list iteration helpers

The syntax for traversing over lists is somewhat cluttered. It could be
made much better with the use of the 'typeof' keyword, but unfortunately
this is not universally supported by all compilers. We can, however,
improve the situation by introducing some macros for the common cases.
To that end, this commit introduces a number of 'for_each' macros that
iterate over a specific linked list.

Current syntax:

  list_for_each_entry(itransfer, &ctx->flying_transfers, list, struct usbi_transfer)

New syntax:

  for_each_transfer(ctx, itransfer)

Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/core.c
libusb/hotplug.c
libusb/hotplug.h
libusb/io.c
libusb/libusbi.h
libusb/os/darwin_usb.c
libusb/os/haiku_pollfs.cpp
libusb/os/linux_usbfs.c
libusb/os/windows_common.c
libusb/version_nano.h