mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 10:42:49 +00:00
IS_ONE_OF macro to make long chains of conditions more concise and easy to follow (#4860)
* Is one of macro * Moar * Whoops * Trunk * isOneOf function backed macro
This commit is contained in:
@@ -80,4 +80,19 @@ bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool isOneOf(int item, int count, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, count);
|
||||
bool found = false;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (item == va_arg(args, int)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end(args);
|
||||
return found;
|
||||
}
|
||||
Reference in New Issue
Block a user