diff options
author | Jani Nikula <[email protected]> | 2015-11-24 21:21:56 +0200 |
---|---|---|
committer | Daniel Vetter <[email protected]> | 2015-11-25 09:29:32 +0100 |
commit | 95150bdf78f330788f97364702920ad0602f92f3 (patch) | |
tree | e4466a356b70d9ef2a41e6cd8e78dc1427324ab6 /tools/perf/scripts/python/export-to-postgresql.py | |
parent | 373701b1fc7d7c0013ae4fffd8103615c150751e (diff) |
drm/i915: fix potential dangling else problems in for_each_ macros
We have serious dangling else bugs waiting to happen in our for_each_
style macros with ifs. Consider, for example,
#define for_each_power_domain(domain, mask) \
for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++) \
if ((1 << (domain)) & (mask))
If this is used in context:
if (condition)
for_each_power_domain(domain, mask);
else
foo();
foo() will be called for each domain *not* in mask, if condition holds,
and not at all if condition doesn't hold.
Fix this by reversing the conditions in the macros, and adding an else
branch for the "for each" block, so that other if/else blocks can't
interfere. Provide a "for_each_if" helper macro to make it easier to get
this right.
v2: move for_each_if to drmP.h in a separate patch.
Reviewed-by: Daniel Vetter <[email protected]>
Signed-off-by: Jani Nikula <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
Signed-off-by: Daniel Vetter <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/export-to-postgresql.py')
0 files changed, 0 insertions, 0 deletions