From cc02876d6c8af831651b9d85ba3f592d01a1efab Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 11 Oct 2012 16:45:30 +0200 Subject: [PATCH] shl: misc: fix XKB modifier collector to check for errors The XKB functions actually return <0 if the modifier is invalid. This cannot happen for the hard-coded modifiers that we use, but it is still safer to check correctly whether the returned value is >0. Reported-by: Ran Benita Signed-off-by: David Herrmann --- src/shl_misc.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/shl_misc.h b/src/shl_misc.h index bf955d5..faaf74f 100644 --- a/src/shl_misc.h +++ b/src/shl_misc.h @@ -93,19 +93,19 @@ static inline unsigned int shl_get_xkb_mods(struct xkb_state *state) unsigned int mods = 0; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_SHIFT, - XKB_STATE_EFFECTIVE)) + XKB_STATE_EFFECTIVE) > 0) mods |= SHL_SHIFT_MASK; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CAPS, - XKB_STATE_EFFECTIVE)) + XKB_STATE_EFFECTIVE) > 0) mods |= SHL_LOCK_MASK; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_CTRL, - XKB_STATE_EFFECTIVE)) + XKB_STATE_EFFECTIVE) > 0) mods |= SHL_CONTROL_MASK; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_ALT, - XKB_STATE_EFFECTIVE)) + XKB_STATE_EFFECTIVE) > 0) mods |= SHL_ALT_MASK; if (xkb_state_mod_name_is_active(state, XKB_MOD_NAME_LOGO, - XKB_STATE_EFFECTIVE)) + XKB_STATE_EFFECTIVE) > 0) mods |= SHL_LOGO_MASK; return mods;