XkbControlsEnabledMask integer overflow

Alan Coopersmith Alan.Coopersmith at Sun.COM
Tue Oct 12 16:35:39 PDT 2004


One of the GNOME accessibility developers noted that the current definition
of XkbControlsEnabledMask causes the compiler to issue warnings about integer
overflow since it's shifting into the sign bit of 32-bit ints.   The fix seems
simple enough, change the definition in <X11/extensions/XKB.h> from:
    #define XkbControlsEnabledMask   (1L << 31)
to:
    #define XkbControlsEnabledMask   (1UL << 31)

At least on Solaris, with the Sun compilers in 32-bit & 64-bit mode, the same
value seems to be passed through, it just removes the warning.   Is there any
reason this fix shouldn't be applied to the tree?   Any compilers/architectures
where it would change the value of XkbControlsEnabledMask?

(The only time I can make it return different values is if I pass it to a
  function as an argument declared as type signed long long in 32-bit mode,
  so sign extension rules bite you, but I believe the functions that this is
  passed to in the Xlib API all take unsigned long, so this shouldn't be an
  issue.)

-- 
	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering



More information about the xorg mailing list