xserver: Branch 'master'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Aug 31 22:47:27 UTC 2024


 test/input.c |   25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

New commits:
commit 1bea5ddfce7e64ddf0ab5d4d250bc998c60e2cde
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Aug 28 15:05:34 2024 +0200

    test: dix_input_valuator_masks(): use fixed array instead of VLA
    
    The array size is determined on compile time, so no need to use a vla
    which always has the same size anyways.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1663>

diff --git a/test/input.c b/test/input.c
index 267d4b14e..7c18ae609 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1256,23 +1256,22 @@ static void
 dix_input_valuator_masks(void)
 {
     ValuatorMask *mask = NULL, *copy;
-    int nvaluators = MAX_VALUATORS;
-    double valuators[nvaluators];
-    int val_ranged[nvaluators];
+    double valuators[MAX_VALUATORS];
+    int val_ranged[MAX_VALUATORS];
     int i;
     int first_val, num_vals;
 
-    for (i = 0; i < nvaluators; i++) {
+    for (i = 0; i < MAX_VALUATORS; i++) {
         valuators[i] = i + 0.5;
         val_ranged[i] = i;
     }
 
-    mask = valuator_mask_new(nvaluators);
+    mask = valuator_mask_new(MAX_VALUATORS);
     assert(mask != NULL);
     assert(valuator_mask_size(mask) == 0);
     assert(valuator_mask_num_valuators(mask) == 0);
 
-    for (i = 0; i < nvaluators; i++) {
+    for (i = 0; i < MAX_VALUATORS; i++) {
         assert(!valuator_mask_isset(mask, i));
         valuator_mask_set_double(mask, i, valuators[i]);
         assert(valuator_mask_isset(mask, i));
@@ -1282,13 +1281,13 @@ dix_input_valuator_masks(void)
         assert(valuator_mask_num_valuators(mask) == i + 1);
     }
 
-    for (i = 0; i < nvaluators; i++) {
+    for (i = 0; i < MAX_VALUATORS; i++) {
         assert(valuator_mask_isset(mask, i));
         valuator_mask_unset(mask, i);
         /* we're removing valuators from the front, so size should stay the
          * same until the last bit is removed */
-        if (i < nvaluators - 1)
-            assert(valuator_mask_size(mask) == nvaluators);
+        if (i < MAX_VALUATORS - 1)
+            assert(valuator_mask_size(mask) == MAX_VALUATORS);
         assert(!valuator_mask_isset(mask, i));
     }
 
@@ -1296,7 +1295,7 @@ dix_input_valuator_masks(void)
     valuator_mask_zero(mask);
     assert(valuator_mask_size(mask) == 0);
     assert(valuator_mask_num_valuators(mask) == 0);
-    for (i = 0; i < nvaluators; i++)
+    for (i = 0; i < MAX_VALUATORS; i++)
         assert(!valuator_mask_isset(mask, i));
 
     first_val = 5;
@@ -1305,7 +1304,7 @@ dix_input_valuator_masks(void)
     valuator_mask_set_range(mask, first_val, num_vals, val_ranged);
     assert(valuator_mask_size(mask) == first_val + num_vals);
     assert(valuator_mask_num_valuators(mask) == num_vals);
-    for (i = 0; i < nvaluators; i++) {
+    for (i = 0; i < MAX_VALUATORS; i++) {
         double val;
 
         if (i < first_val || i >= first_val + num_vals) {
@@ -1322,14 +1321,14 @@ dix_input_valuator_masks(void)
         }
     }
 
-    copy = valuator_mask_new(nvaluators);
+    copy = valuator_mask_new(MAX_VALUATORS);
     valuator_mask_copy(copy, mask);
     assert(mask != copy);
     assert(valuator_mask_size(mask) == valuator_mask_size(copy));
     assert(valuator_mask_num_valuators(mask) ==
            valuator_mask_num_valuators(copy));
 
-    for (i = 0; i < nvaluators; i++) {
+    for (i = 0; i < MAX_VALUATORS; i++) {
         double a, b;
 
         assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i));


More information about the xorg-commit mailing list