mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-25 13:00:13 +01:00
dix: do not use bit-wise operators on the boolean result of BitIsOn
Performing bit-wise operations on a boolean amounts to mixing types,
is confusing and basically incorrect; one should only perform
logical operations on booleans.
Performing such operations relies on the implementation detail
that a boolean is in fact an integer and that its value FALSE
is implemented as zero.
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
(cherry picked from commit b16964910d)
This commit is contained in:
parent
fb84f8b5c7
commit
d0157229e8
1 changed files with 6 additions and 6 deletions
|
|
@ -111,12 +111,12 @@ set_button_up(DeviceIntPtr pDev, int button, int type)
|
|||
Bool
|
||||
button_is_down(DeviceIntPtr pDev, int button, int type)
|
||||
{
|
||||
int ret = 0;
|
||||
Bool ret = FALSE;
|
||||
|
||||
if (type & BUTTON_PROCESSED)
|
||||
ret |= BitIsOn(pDev->button->down, button);
|
||||
ret = ret || BitIsOn(pDev->button->down, button);
|
||||
if (type & BUTTON_POSTED)
|
||||
ret |= BitIsOn(pDev->button->postdown, button);
|
||||
ret = ret || BitIsOn(pDev->button->postdown, button);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -142,12 +142,12 @@ set_key_up(DeviceIntPtr pDev, int key_code, int type)
|
|||
Bool
|
||||
key_is_down(DeviceIntPtr pDev, int key_code, int type)
|
||||
{
|
||||
int ret = 0;
|
||||
Bool ret = FALSE;
|
||||
|
||||
if (type & KEY_PROCESSED)
|
||||
ret |= BitIsOn(pDev->key->down, key_code);
|
||||
ret = ret || BitIsOn(pDev->key->down, key_code);
|
||||
if (type & KEY_POSTED)
|
||||
ret |= BitIsOn(pDev->key->postdown, key_code);
|
||||
ret = ret || BitIsOn(pDev->key->postdown, key_code);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue