chiark / gitweb /
macro: add a macro to test whether a value is in a specified list
authorLennart Poettering <lennart@poettering.net>
Mon, 2 Dec 2013 22:08:25 +0000 (23:08 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 2 Dec 2013 22:32:34 +0000 (23:32 +0100)
commitcabb78068899232c152f4585f19d023e373aa73d
tree7c4fa9684386a6b681ef0475315b0d30d6f12e18
parent1ae464e09376853c52075ec4d8a6bfc4b4036d0c
macro: add a macro to test whether a value is in a specified list

Introduce IN_SET() macro to nicely check whether a value a is one of a
few listed values.

This makes writing this:

        if (a == 1 || a == 7 || a == 8 || a == 9)

nicer, by allowing this:

        if (IN_SET(a, 1, 7, 8, 9))

This is particularly useful for state machine enums.
src/shared/macro.h
src/test/test-util.c