[Intel-gfx] [PATCH] drm/i915: Explicitly convert some macros to boolean values

Chris Wilson chris at chris-wilson.co.uk
Mon Jul 4 15:06:42 UTC 2016


On Mon, Jul 04, 2016 at 03:50:23PM +0100, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
> 
> Some IS_ and HAS_ macros can return any non-zero value for true.
> 
> One potential problem with that is that someone could assign
> them to integers and be surprised with the result. Therefore it
> is probably safer to do the conversion to 0/1 in the macros
> themselves.
> 
> Luckily this does not seem to have an effect on code size.

Indeed, gcc is quite happy to remove the !! and combine
e.g. IS_GEN6() || IS_GEN7() into a single testb.

With that,
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list