Re: [dev] [PATCH] Fix match function bugs

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Sun, 23 Jun 2013 12:25:51 +0200

Uhmmm, the patch is not good because it breaks a lot of configurations (when
we use XK_ANY_MOD). I am going to send a new version of the patch.



On Sun, Jun 23, 2013 at 10:44:46AM +0200, Roberto E. Vargas Caballero wrote:
> From: "Roberto E. Vargas Caballero" <k0ga_AT_shike2.com>
>
> There were two problems with match denfinition.
>
> 1) There was a forward declaration in the form:
>
> static inline bool match(uint, uint);
>
> but later the function was defined as:
>
> inline bool
> match(uint mask, uint state) {
>
> This causes that there were two different functions in the code, one local
> and inline, and other inline but extern. All was working without problems
> due to we were using -Os, and the compiler was using the extern definition
> and it was no expanding the static declaration. If you removed the -Os flag,
> then you got linker errors due it was no able to find the static definition
> of the static declaration.
>
> 2) The mask checking was incorrect because we were doing the test:
>
> (state & mask) != state
>
> and this test only was saying that at least all the enabled bits of state
> were enabled also in mask, but no all the possible bits in mask. This was
> the origin of the bug reported by Xavier Cartron, where he said it was
> possible activated some shortcuts with some of the modifiers defined in the
> config.h file.
> ---
> st.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/st.c b/st.c
> index 4d8a4f9..7d823cd 100644
> --- a/st.c
> +++ b/st.c
> _AT_@ -3464,17 +3464,15 @@ focus(XEvent *ev) {
> }
> }
>
> -inline bool
> +static inline bool
> match(uint mask, uint state) {
> - state &= ~(ignoremod);
> + state &= ~ignoremod;
>
> if(mask == XK_NO_MOD && state)
> return false;
> if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state)
> return false;
> - if((state & mask) != state)
> - return false;
> - return true;
> + return (state & mask) == mask && (state & mask) == state;;
> }
>
> void
> --
> 1.7.10.4
>
Received on Sun Jun 23 2013 - 12:25:51 CEST

This archive was generated by hypermail 2.3.0 : Sun Jun 23 2013 - 12:36:04 CEST