[vlc-commits] gestures: avoid undefined negative shift

Rémi Denis-Courmont git at videolan.org
Mon Sep 1 18:00:12 CEST 2014


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Sep  1 18:50:38 2014 +0300| [3e2543837b2681e86d660f692fa62d429f958ca8] | committer: Rémi Denis-Courmont

gestures: avoid undefined negative shift

(cherry picked from commit 2051d837ea9066c4ddf388b7940652bb0c8d549c)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=3e2543837b2681e86d660f692fa62d429f958ca8
---

 modules/control/gestures.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/control/gestures.c b/modules/control/gestures.c
index 53e440c..2e50eec 100644
--- a/modules/control/gestures.c
+++ b/modules/control/gestures.c
@@ -47,7 +47,7 @@ struct intf_sys_t
     bool                b_button_pressed;
     int                 i_last_x, i_last_y;
     unsigned int        i_pattern;
-    int                 i_num_gestures;
+    unsigned int        i_num_gestures;
     int                 i_threshold;
     int                 i_button_mask;
 };
@@ -146,7 +146,7 @@ static int Open ( vlc_object_t *p_this )
 /*****************************************************************************
  * gesture: return a subpattern within a pattern
  *****************************************************************************/
-static int gesture( int i_pattern, int i_num )
+static inline unsigned gesture( unsigned i_pattern, unsigned i_num )
 {
     return ( i_pattern >> ( i_num * 4 ) ) & 0xF;
 }
@@ -382,7 +382,7 @@ static int MovedEvent( vlc_object_t *p_this, char const *psz_var,
     {
         int i_horizontal = newval.coords.x - p_sys->i_last_x;
         int i_vertical = newval.coords.y - p_sys->i_last_y;
-        int pattern = 0;
+        unsigned int pattern = 0;
 
         i_horizontal = i_horizontal / p_sys->i_threshold;
         i_vertical = i_vertical / p_sys->i_threshold;
@@ -412,7 +412,8 @@ static int MovedEvent( vlc_object_t *p_this, char const *psz_var,
         {
             p_sys->i_last_x = newval.coords.x;
             p_sys->i_last_y = newval.coords.y;
-            if( gesture( p_sys->i_pattern, p_sys->i_num_gestures - 1 )
+            if( p_sys->i_num_gestures > 0
+             && gesture( p_sys->i_pattern, p_sys->i_num_gestures - 1 )
                     != pattern )
             {
                 p_sys->i_pattern |= pattern << ( p_sys->i_num_gestures * 4 );



More information about the vlc-commits mailing list