Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: add multi-variable loop iterator macros.
Multi-variable loop iterators avoid potential undefined behavior by using an internal iterator variable to perform the iteration and only referencing the containing object (via OBJECT_CONTAINING) if the iterator has been validated via the second expression of the for statement. That way, the user can easily implement a loop that never tries to obtain the object containing NULL or stack-allocated non-contained nodes. When the loop ends normally (not via "break;") the user-provided variable is set to NULL. Acked-by: Eelco Chaudron <[email protected]> Acked-by: Dumitru Ceara <[email protected]> Signed-off-by: Adrian Moreno <[email protected]> Signed-off-by: Ilya Maximets <[email protected]>
- Loading branch information