summaryrefslogtreecommitdiffstats
path: root/include/drm/drm_mm.h
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2015-11-24 21:21:56 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-11-25 09:29:32 +0100
commit95150bdf78f330788f97364702920ad0602f92f3 (patch)
treee4466a356b70d9ef2a41e6cd8e78dc1427324ab6 /include/drm/drm_mm.h
parent373701b1fc7d7c0013ae4fffd8103615c150751e (diff)
downloadlinux-95150bdf78f330788f97364702920ad0602f92f3.tar.bz2
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 <daniel.vetter@ffwll.ch> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1448392916-2281-2-git-send-email-jani.nikula@intel.com Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'include/drm/drm_mm.h')
0 files changed, 0 insertions, 0 deletions