[Intel-gfx] drivers/gpu/drm/i915/i915_reg.h:90:shift-overflow problem ?

Chris Wilson chris at chris-wilson.co.uk
Mon May 30 14:15:15 UTC 2016


On Mon, May 30, 2016 at 11:32:59AM +0100, David Binderman wrote:
> Hello there,
> 
> drivers/gpu/drm/i915/i915_reg.h:90:28: warning: result of β€˜65535 <<
> 20’ requires 37 bits to represent, but β€˜int’ only has 32 bits
> [-Wshift-overflow=]
> 
> Source code is
> 
> #define   BSM_MASK (0xFFFF << 20)
> 
> Maybe better code
> 
> #define   BSM_MASK (((unsigned long) 0xFFFF) << 20)

#define BSM_MASK (~0u << 20)

It should be a 32bit mask. The current (with the exception of undefined
behaviour of shifting into the signbit, fortunately gcc does what we
expect) code is functionally current as the mask will be truncated to
32bits.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list