]> git.sesse.net Git - vlc/commitdiff
gestures: avoid undefined negative shift
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 1 Sep 2014 15:50:38 +0000 (18:50 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 1 Sep 2014 15:54:41 +0000 (18:54 +0300)
modules/control/gestures.c

index e04dd2f3c9e4939a8802765d2f53c0a259fa3479..3c72e8a6ed07578f6152a97adb7bde9e0ad1060a 100644 (file)
@@ -48,7 +48,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;
 };
@@ -147,7 +147,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;
 }
@@ -380,7 +380,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;
@@ -410,7 +410,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 );