[mutter/wip/carlosg/mode-switch-fix-40: 5/5] core: Be more careful around n_modes signedness




commit 58b606d71b18e945a9a3c987476b5446bdda026a
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jul 7 18:33:04 2021 +0200

    core: Be more careful around n_modes signedness
    
    This is returned as an integer, which we deal with as an unsigned
    integer. Deal with it as an integer all along, and skip safely
    negative values.
    
    (Cherry-picked from commit 44af2c0d37964997187b0295f15352b676f89840)

 src/core/meta-pad-action-mapper.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/core/meta-pad-action-mapper.c b/src/core/meta-pad-action-mapper.c
index e5331e1dd2..7c78c40148 100644
--- a/src/core/meta-pad-action-mapper.c
+++ b/src/core/meta-pad-action-mapper.c
@@ -517,7 +517,7 @@ meta_pad_action_mapper_handle_button (MetaPadActionMapper         *mapper,
                                       const ClutterPadButtonEvent *event)
 {
   GDesktopPadButtonAction action;
-  int button, group, mode;
+  int button, group, mode, n_modes = 0;
   gboolean is_press;
   GSettings *settings;
   char *accel;
@@ -531,9 +531,11 @@ meta_pad_action_mapper_handle_button (MetaPadActionMapper         *mapper,
   group = clutter_input_device_get_mode_switch_button_group (pad, button);
   is_press = event->type == CLUTTER_PAD_BUTTON_PRESS;
 
-  if (is_press && group >= 0)
+  if (group >= 0)
+    n_modes = clutter_input_device_get_group_n_modes (pad, group);
+
+  if (is_press && n_modes > 0)
     {
-      guint n_modes = clutter_input_device_get_group_n_modes (pad, group);
       const char *pretty_name = NULL;
       PadMappingInfo *info;
 #ifdef HAVE_LIBWACOM


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]