xserver: Branch 'master' - 10 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 8 23:57:36 UTC 2024


 dix/devices.c                      |   68 ++++++++++------------
 include/input.h                    |    2 
 test/input.c                       |   17 +++++
 test/list.c                        |    4 +
 test/meson.build                   |   13 ++--
 test/signal-logging.c              |    5 +
 test/test_xkb.c                    |    8 ++
 test/touch.c                       |  110 ++++++++++++++++++++++---------------
 test/xfree86.c                     |    7 ++
 test/xi2/protocol-xiselectevents.c |    2 
 test/xtest.c                       |   58 ++++++++++---------
 11 files changed, 176 insertions(+), 118 deletions(-)

New commits:
commit 37ef3adaed3f36622d2e980439514cb177e5aa28
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Jan 9 09:46:24 2024 +1000

    test: drop the unncessary unit_defines from meson.build
    
    Let's set unit_c_args directly instead of having two variables for the
    same thing.

diff --git a/test/meson.build b/test/meson.build
index 28a32a035..afa08abb2 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -187,15 +187,14 @@ if build_xorg
      'xfree86.c',
      'xtest.c',
     ]
-    unit_defines = ['-DXORG_TESTS']
+    unit_c_args = ['-DXORG_TESTS']
     unit_includes = [inc, xorg_inc]
 
     if build_res
         unit_sources += ['hashtabletest.c']
-        unit_defines += ['-DRES_TESTS']
+        unit_c_args += ['-DRES_TESTS']
     endif
 
-    unit_c_args = unit_defines
     if meson.get_compiler('c').has_link_argument('-Wl,-wrap')
        # LTO breaks with -Wl,-wrap on certain configurations
        unit_c_args += ['-fno-lto']
commit 79e3d44558482eb58441bb7b438d2d8be8eb62e7
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jan 5 13:38:35 2024 +1000

    meson.build: re-enable the protocol unit tests
    
    Accidentally disabled when the meson variables shifted around.
    
    Fixes d231ce2d9ce9644e77e8dbe8c5a23eeb11e85b55

diff --git a/test/meson.build b/test/meson.build
index 9cbce78cf..28a32a035 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -214,7 +214,7 @@ if build_xorg
         'xi2/protocol-eventconvert.c',
         'xi2/xi2.c',
        ]
-       unit_defines += ['-DLDWRAP_TESTS']
+       unit_c_args += ['-DLDWRAP_TESTS']
        unit_includes += [include_directories('xi1', 'xi2')]
        ldwraps = [
         '-Wl,-wrap,dixLookupWindow',
commit 9f3b64f3e6f8a74b009912465d5d4815603402a0
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jan 5 14:41:45 2024 +1000

    test: speed up the XISelectEvents test
    
    It's fine to test up to 1000 masks but we don't need to test every
    single value. Let's increase by a "random" increment to make this test
    pass faster.

diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c
index 0a4da5bc4..41a370a3e 100644
--- a/test/xi2/protocol-xiselectevents.c
+++ b/test/xi2/protocol-xiselectevents.c
@@ -172,7 +172,7 @@ request_XISelectEvents_masks(xXISelectEventsReq * req)
     req->win = ROOT_WINDOW_ID;
 
     /* if a clients submits more than 100 masks, consider it insane and untested */
-    for (i = 1; i <= 1000; i++) {
+    for (i = 1; i <= 1000; i += 33) {
         req->num_masks = i;
         mask->deviceid = XIAllDevices;
 
commit d0b0137a95477f8964a7989425739020e96d46c8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jan 5 10:29:26 2024 +1000

    Two whitespace fixes

diff --git a/dix/devices.c b/dix/devices.c
index deeec2d9b..39cb42b0d 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1031,8 +1031,7 @@ CloseDevice(DeviceIntPtr dev)
 /**
  * Shut down all devices of one list and free all resources.
  */
-static
-    void
+static void
 CloseDeviceList(DeviceIntPtr *listHead)
 {
     /* Used to mark devices that we tried to free */
diff --git a/test/meson.build b/test/meson.build
index 7f4befa88..9cbce78cf 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -115,9 +115,9 @@ if get_option('xvfb')
             )
         endforeach
         test_parameters = [
-                [rendercheck_tests, '', piglit_env, '', false], 
-                [rendercheck_tests_gles2_success, '_gles2', gles20_env, '-gles2', false], 
-                [rendercheck_a8, '_gles2', gles20_env, '-gles2', true], 
+                [rendercheck_tests, '', piglit_env, '', false],
+                [rendercheck_tests_gles2_success, '_gles2', gles20_env, '-gles2', false],
+                [rendercheck_a8, '_gles2', gles20_env, '-gles2', true],
                 [rendercheck_tests_gles3, '_gles2', piglit_env, '-gles3', false]
             ]
 
commit 0a9f223eecdee10d7fff31d90e271a438d6ef873
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Jan 5 10:01:24 2024 +1000

    dix: factor out the duplicate the RemoveDevice code paths
    
    This is the same loop twice, once over inputInfo.devices and once over
    inputInfo.off_devices, let's make both the same.

diff --git a/dix/devices.c b/dix/devices.c
index 56b811fa2..deeec2d9b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1134,6 +1134,26 @@ UndisplayDevices(void)
         screen->DisplayCursor(dev, screen, NullCursor);
 }
 
+static int
+CloseOneDevice(const DeviceIntPtr dev, DeviceIntPtr *listHead)
+{
+    DeviceIntPtr tmp, next, prev = NULL;
+
+    for (tmp = *listHead; tmp; (prev = tmp), (tmp = next)) {
+        next = tmp->next;
+        if (tmp == dev) {
+            if (prev == NULL)
+                *listHead = next;
+            else
+                prev->next = next;
+
+            CloseDevice(tmp);
+            return Success;
+        }
+    }
+    return BadMatch;
+}
+
 /**
  * Remove a device from the device list, closes it and thus frees all
  * resources.
@@ -1150,12 +1170,12 @@ UndisplayDevices(void)
 int
 RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
 {
-    DeviceIntPtr prev, tmp, next;
     int ret = BadMatch;
     ScreenPtr screen = screenInfo.screens[0];
     int deviceid;
     int initialized;
     int flags[MAXDEVICES] = { 0 };
+    int flag;
 
     DebugF("(dix) removing device %d\n", dev->id);
 
@@ -1173,41 +1193,13 @@ RemoveDevice(DeviceIntPtr dev, BOOL sendevent)
         flags[dev->id] = XIDeviceDisabled;
     }
 
-    input_lock();
+    flag = IsMaster(dev) ? XIMasterRemoved : XISlaveRemoved;
 
-    prev = NULL;
-    for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
-        next = tmp->next;
-        if (tmp == dev) {
-
-            if (prev == NULL)
-                inputInfo.devices = next;
-            else
-                prev->next = next;
-
-            flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
-            CloseDevice(tmp);
-            ret = Success;
-            break;
-        }
-    }
-
-    prev = NULL;
-    for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
-        next = tmp->next;
-        if (tmp == dev) {
-            flags[tmp->id] = IsMaster(tmp) ? XIMasterRemoved : XISlaveRemoved;
-            CloseDevice(tmp);
-
-            if (prev == NULL)
-                inputInfo.off_devices = next;
-            else
-                prev->next = next;
+    input_lock();
 
-            ret = Success;
-            break;
-        }
-    }
+    if ((ret = CloseOneDevice(dev, &inputInfo.devices)) == Success ||
+        (ret = CloseOneDevice(dev, &inputInfo.off_devices)) == Success)
+        flags[deviceid] = flag;
 
     input_unlock();
 
commit e44e9262df8b50f76fec3cc371b785473090fb59
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jan 4 12:23:35 2024 +1000

    test: fix the touch tests to no longer leak
    
    Instead of hardcoded TouchRec/ValuatorRec init the devices with the
    matching functions and go from there. This allows us to clean them
    up later, removing the various leaks that stop asan from being happy.

diff --git a/test/touch.c b/test/touch.c
index 7b22ceddb..1f183a72a 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -35,27 +35,46 @@
 
 #include "tests-common.h"
 
+static void
+free_device(DeviceIntPtr dev)
+{
+    free(dev->name);
+    free(dev->last.scroll); /* sigh, allocated but not freed by the valuator functions */
+    for (int i = 0; i < dev->last.num_touches; i++)
+         valuator_mask_free(&dev->last.touches[i].valuators);
+
+    free(dev->last.touches); /* sigh, allocated but not freed by the valuator functions */
+    FreeDeviceClass(XIValuatorClass, (void**)&dev->valuator);
+    FreeDeviceClass(XITouchClass, (void**)&dev->touch);
+}
+
 static void
 touch_grow_queue(void)
 {
     DeviceIntRec dev;
-    ValuatorClassRec val;
-    TouchClassRec touch;
+    SpriteInfoRec sprite;
     size_t size, new_size;
     int i;
+    ScreenRec screen;
+    Atom labels[2] = { 0 };
+
+    screenInfo.screens[0] = &screen;
 
     memset(&dev, 0, sizeof(dev));
+    dev.type = MASTER_POINTER;  /* claim it's a master to stop ptracccel */
     dev.name = xnfstrdup("test device");
     dev.id = 2;
-    dev.valuator = &val;
-    val.numAxes = 5;
-    dev.touch = &touch;
+
+    InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+    InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+    memset(&sprite, 0, sizeof(sprite));
+    dev.spriteInfo = &sprite;
+
     inputInfo.devices = &dev;
 
     size = 5;
 
-    dev.last.num_touches = size;
-    dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches));
     assert(dev.last.touches);
     for (i = 0; i < size; i++) {
         dev.last.touches[i].active = TRUE;
@@ -91,27 +110,33 @@ touch_grow_queue(void)
         assert(t->ddx_id == 0);
     }
 
-    free(dev.name);
+    free_device(&dev);
 }
 
 static void
 touch_find_ddxid(void)
 {
     DeviceIntRec dev;
+    SpriteInfoRec sprite;
     DDXTouchPointInfoPtr ti, ti2;
-    ValuatorClassRec val;
-    TouchClassRec touch;
     int size = 5;
     int i;
+    Atom labels[2] = { 0 };
+    ScreenRec screen;
+
+    screenInfo.screens[0] = &screen;
 
     memset(&dev, 0, sizeof(dev));
+    dev.type = MASTER_POINTER;  /* claim it's a master to stop ptracccel */
     dev.name = xnfstrdup("test device");
     dev.id = 2;
-    dev.valuator = &val;
-    val.numAxes = 5;
-    dev.touch = &touch;
-    dev.last.num_touches = size;
-    dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches));
+
+    InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+    InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+    memset(&sprite, 0, sizeof(sprite));
+    dev.spriteInfo = &sprite;
+
     inputInfo.devices = &dev;
     assert(dev.last.touches);
 
@@ -159,32 +184,35 @@ touch_find_ddxid(void)
     ti = TouchFindByDDXID(&dev, 40, TRUE);
     assert(ti == &dev.last.touches[size+1]);
 
-    free(dev.name);
+    free_device(&dev);
 }
 
 static void
 touch_begin_ddxtouch(void)
 {
     DeviceIntRec dev;
+    SpriteInfoRec sprite;
     DDXTouchPointInfoPtr ti;
-    ValuatorClassRec val;
-    TouchClassRec touch;
     int ddx_id = 123;
     unsigned int last_client_id = 0;
-    int size = 5;
+    Atom labels[2] = { 0 };
+    ScreenRec screen;
+
+    screenInfo.screens[0] = &screen;
 
     memset(&dev, 0, sizeof(dev));
+    dev.type = MASTER_POINTER;  /* claim it's a master to stop ptracccel */
     dev.name = xnfstrdup("test device");
     dev.id = 2;
-    dev.valuator = &val;
-    val.numAxes = 5;
-    touch.mode = XIDirectTouch;
-    dev.touch = &touch;
-    dev.last.num_touches = size;
-    dev.last.touches = calloc(dev.last.num_touches, sizeof(*dev.last.touches));
     inputInfo.devices = &dev;
-    assert(dev.last.touches);
 
+    InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+    InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+    memset(&sprite, 0, sizeof(sprite));
+    dev.spriteInfo = &sprite;
+
+    assert(dev.last.touches);
     ti = TouchBeginDDXTouch(&dev, ddx_id);
     assert(ti);
     assert(ti->ddx_id == ddx_id);
@@ -206,41 +234,36 @@ touch_begin_ddxtouch(void)
     assert(!ti->emulate_pointer);
     last_client_id = ti->client_id;
 
-    free(dev.name);
+    free_device(&dev);
 }
 
 static void
 touch_begin_touch(void)
 {
     DeviceIntRec dev;
-    TouchClassRec touch;
-    ValuatorClassRec val;
     TouchPointInfoPtr ti;
     int touchid = 12434;
     int sourceid = 23;
     SpriteInfoRec sprite;
     ScreenRec screen;
+    Atom labels[2] = { 0 };
 
     screenInfo.screens[0] = &screen;
 
     memset(&dev, 0, sizeof(dev));
+    dev.type = MASTER_POINTER;  /* claim it's a master to stop ptracccel */
     dev.name = xnfstrdup("test device");
     dev.id = 2;
 
-    memset(&sprite, 0, sizeof(sprite));
-    dev.spriteInfo = &sprite;
-
-    memset(&touch, 0, sizeof(touch));
-    touch.num_touches = 0;
-
-    memset(&val, 0, sizeof(val));
-    dev.valuator = &val;
-    val.numAxes = 2;
-
     ti = TouchBeginTouch(&dev, sourceid, touchid, TRUE);
     assert(!ti);
 
-    dev.touch = &touch;
+    InitValuatorClassDeviceStruct(&dev, 2, labels, 10, Absolute);
+    InitTouchClassDeviceStruct(&dev, 5, XIDirectTouch, 2);
+
+    memset(&sprite, 0, sizeof(sprite));
+    dev.spriteInfo = &sprite;
+
     ti = TouchBeginTouch(&dev, sourceid, touchid, TRUE);
     assert(ti);
     assert(ti->client_id == touchid);
@@ -248,9 +271,9 @@ touch_begin_touch(void)
     assert(ti->sourceid == sourceid);
     assert(ti->emulate_pointer);
 
-    assert(touch.num_touches == 1);
+    assert(dev.touch->num_touches == 5);
 
-    free(dev.name);
+    free_device(&dev);
 }
 
 static void
@@ -265,6 +288,7 @@ touch_init(void)
     screenInfo.screens[0] = &screen;
 
     memset(&dev, 0, sizeof(dev));
+    dev.type = MASTER_POINTER;  /* claim it's a master to stop ptracccel */
     dev.name = xnfstrdup("test device");
 
     memset(&sprite, 0, sizeof(sprite));
@@ -279,7 +303,7 @@ touch_init(void)
     assert(rc == TRUE);
     assert(dev.touch);
 
-    free(dev.name);
+    free_device(&dev);
 }
 
 int
commit b6931f2f5fab52dbb0c09e02ebb8315b3516e01b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jan 4 12:30:20 2024 +1000

    test: fix the xtest device test to show the dependency
    
    These two tests were dependent on each other, the second test relied on
    the xtest devices created in the first test. Let's move the bits that
    are shared out into the main function instead to illustrate this better.
    
    This lets us add a call to CloseDownDevices() that will remove the leaks
    in this set of tests.

diff --git a/test/xtest.c b/test/xtest.c
index 12433afc4..171f285f6 100644
--- a/test/xtest.c
+++ b/test/xtest.c
@@ -62,34 +62,6 @@ device_cursor_cleanup(DeviceIntPtr dev, ScreenPtr screen)
 static void
 xtest_init_devices(void)
 {
-    ScreenRec screen = {0};
-    ClientRec server_client = {0};
-    WindowRec root = {{0}};
-    WindowOptRec optional = {0};
-
-    /* random stuff that needs initialization */
-    root.drawable.id = 0xab;
-    root.optional = &optional;
-    screen.root = &root;
-    screenInfo.numScreens = 1;
-    screenInfo.screens[0] = &screen;
-    screen.myNum = 0;
-    screen.id = 100;
-    screen.width = 640;
-    screen.height = 480;
-    screen.DeviceCursorInitialize = device_cursor_init;
-    screen.DeviceCursorCleanup = device_cursor_cleanup;
-    dixResetPrivates();
-    serverClient = &server_client;
-    InitClient(serverClient, 0, (void *) NULL);
-    if (!InitClientResources(serverClient)) /* for root resources */
-        FatalError("couldn't init server resources");
-    InitAtoms();
-    SyncExtensionInit();
-
-    /* this also inits the xtest devices */
-    InitCoreDevices();
-
     assert(xtestpointer);
     assert(xtestkeyboard);
     assert(IsXTestDevice(xtestpointer, NULL));
@@ -135,8 +107,38 @@ xtest_properties(void)
 int
 xtest_test(void)
 {
+    ScreenRec screen = {0};
+    ClientRec server_client = {0};
+    WindowRec root = {{0}};
+    WindowOptRec optional = {0};
+
+    /* random stuff that needs initialization */
+    root.drawable.id = 0xab;
+    root.optional = &optional;
+    screen.root = &root;
+    screenInfo.numScreens = 1;
+    screenInfo.screens[0] = &screen;
+    screen.myNum = 0;
+    screen.id = 100;
+    screen.width = 640;
+    screen.height = 480;
+    screen.DeviceCursorInitialize = device_cursor_init;
+    screen.DeviceCursorCleanup = device_cursor_cleanup;
+    dixResetPrivates();
+    serverClient = &server_client;
+    InitClient(serverClient, 0, (void *) NULL);
+    if (!InitClientResources(serverClient)) /* for root resources */
+        FatalError("couldn't init server resources");
+    InitAtoms();
+    SyncExtensionInit();
+
+    /* this also inits the xtest devices */
+    InitCoreDevices();
+
     xtest_init_devices();
     xtest_properties();
 
+    CloseDownDevices();
+
     return 0;
 }
commit 2cee5fb36cdf98488422d6c85f0076e3a70a3ca4
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jan 4 10:15:26 2024 +1000

    test: fix various leaks in the tests

diff --git a/dix/devices.c b/dix/devices.c
index d58f96b47..56b811fa2 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -778,7 +778,7 @@ InitAndStartDevices(void)
 /**
  * Free the given device class and reset the pointer to NULL.
  */
-static void
+void
 FreeDeviceClass(int type, void **class)
 {
     if (!(*class))
diff --git a/include/input.h b/include/input.h
index 75c7c2df6..fd5b7c4df 100644
--- a/include/input.h
+++ b/include/input.h
@@ -331,6 +331,8 @@ extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ ,
 
 extern _X_INTERNAL ValuatorClassPtr AllocValuatorClass(ValuatorClassPtr src,
                                                        int numAxes);
+extern _X_INTERNAL void FreeDeviceClass(int type, void **class);
+
 
 extern _X_EXPORT Bool InitValuatorClassDeviceStruct(DeviceIntPtr /*device */ ,
                                                     int /*numAxes */ ,
diff --git a/test/input.c b/test/input.c
index e27374db3..34a75fd7f 100644
--- a/test/input.c
+++ b/test/input.c
@@ -154,6 +154,9 @@ dix_init_valuators(void)
     assert(axis->scroll.type == SCROLL_TYPE_VERTICAL);
     assert(axis->scroll.increment == 3.0);
     assert(axis->scroll.flags == SCROLL_FLAG_NONE);
+
+    FreeDeviceClass(ValuatorClass, (void**)&val);
+    free(dev.last.scroll); /* sigh, allocated but not freed by the valuator functions */
 }
 
 /* just check the known success cases, and that error cases set the client's
@@ -282,6 +285,7 @@ dix_event_to_core(int type)
     ev.detail.key = 0;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     x = 1;
     y = 2;
@@ -289,6 +293,7 @@ dix_event_to_core(int type)
     ev.root_y = y;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     x = 0x7FFF;
     y = 0x7FFF;
@@ -296,6 +301,7 @@ dix_event_to_core(int type)
     ev.root_y = y;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     x = 0x8000;                 /* too high */
     y = 0x8000;                 /* too high */
@@ -307,6 +313,7 @@ dix_event_to_core(int type)
     assert(count == 1);
     assert(core->u.keyButtonPointer.rootX != x);
     assert(core->u.keyButtonPointer.rootY != y);
+    free(core);
 
     x = 0x7FFF;
     y = 0x7FFF;
@@ -316,16 +323,19 @@ dix_event_to_core(int type)
     ev.time = time;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     detail = 1;
     ev.detail.key = detail;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     detail = 0xFF;              /* highest value */
     ev.detail.key = detail;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     detail = 0xFFF;             /* too big */
     ev.detail.key = detail;
@@ -338,6 +348,7 @@ dix_event_to_core(int type)
     ev.corestate = state;
     rc = EventToCore((InternalEvent *) &ev, &core, &count);
     test_event();
+    free(core);
 
     state = 0x10000;            /* too big */
     ev.corestate = state;
@@ -347,6 +358,7 @@ dix_event_to_core(int type)
     assert(count == 1);
     assert(core->u.keyButtonPointer.state != state);
     assert(core->u.keyButtonPointer.state == (state & 0xFFFF));
+    free(core);
 
 #undef test_event
 }
@@ -1197,6 +1209,7 @@ dix_input_attributes(void)
 
     new = DuplicateInputAttributes(orig);
     assert(memcmp(orig, new, sizeof(InputAttributes)) == 0);
+    FreeInputAttributes(new);
 
     orig->product = xnfstrdup("product name");
     new = DuplicateInputAttributes(orig);
@@ -1330,6 +1343,7 @@ dix_input_valuator_masks(void)
     }
 
     valuator_mask_free(&mask);
+    valuator_mask_free(&copy);
     assert(mask == NULL);
 }
 
@@ -1361,6 +1375,9 @@ dix_valuator_mode(void)
     valuator_set_mode(&dev, VALUATOR_MODE_ALL_AXES, Relative);
     for (i = 0; i < num_axes; i++)
         assert(valuator_get_mode(&dev, i) == Relative);
+
+    FreeDeviceClass(ValuatorClass, (void**)&dev.valuator);
+    free(dev.last.scroll); /* sigh, allocated but not freed by the valuator functions */
 }
 
 static void
diff --git a/test/list.c b/test/list.c
index d51817c21..fee41a538 100644
--- a/test/list.c
+++ b/test/list.c
@@ -266,6 +266,8 @@ test_nt_list_append(void)
         i++;
     }
     assert(i == 11);
+
+    free(foo);
 }
 
 static void
@@ -300,6 +302,8 @@ test_nt_list_insert(void)
         i++;
     }
     assert(i == 11);
+
+    free(foo);
 }
 
 static void
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 4ba8485fc..97477dcee 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -176,13 +176,16 @@ static void logging_format(void)
     char read_buf[2048];
     char *logmsg;
     uintptr_t ptr;
+    char *fname = NULL;
 
     /* set up buf to contain ".....end" */
     memset(buf, '.', sizeof(buf));
     strcpy(&buf[sizeof(buf) - 4], "end");
 
-    LogInit(log_file_path, NULL);
+    fname = (char*)LogInit(log_file_path, NULL);
+    assert(fname != NULL);
     assert((f = fopen(log_file_path, "r")));
+    free(fname);
 
 #define read_log_msg(msg) do {                                  \
         msg = fgets(read_buf, sizeof(read_buf), f);             \
diff --git a/test/test_xkb.c b/test/test_xkb.c
index a13107390..18e37e408 100644
--- a/test/test_xkb.c
+++ b/test/test_xkb.c
@@ -75,6 +75,8 @@ xkb_get_rules_test(void)
     assert(strcmp(rmlvo.layout, XKB_DFLT_LAYOUT) == 0);
     assert(strcmp(rmlvo.variant, XKB_DFLT_VARIANT) == 0);
     assert(strcmp(rmlvo.options, XKB_DFLT_OPTIONS) == 0);
+
+    XkbFreeRMLVOSet(&rmlvo, FALSE);
 }
 
 /**
@@ -114,6 +116,7 @@ xkb_set_rules_test(void)
     assert(strcmp(rmlvo.options, rmlvo_new.options) == 0);
 
     XkbFreeRMLVOSet(&rmlvo, FALSE);
+    XkbFreeRMLVOSet(&rmlvo_new, FALSE);
 }
 
 /**
@@ -139,6 +142,7 @@ xkb_set_get_rules_test(void)
 
     /* pass 1 */
     XkbSetRulesDflts(&rmlvo);
+    XkbFreeRMLVOSet(&rmlvo, FALSE);
     XkbGetRulesDflts(&rmlvo);
 
     /* Make a backup copy */
@@ -159,12 +163,16 @@ xkb_set_get_rules_test(void)
     assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
     assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
 
+    XkbFreeRMLVOSet(&rmlvo, FALSE);
     XkbGetRulesDflts(&rmlvo);
     assert(strcmp(rmlvo.rules, rmlvo_backup.rules) == 0);
     assert(strcmp(rmlvo.model, rmlvo_backup.model) == 0);
     assert(strcmp(rmlvo.layout, rmlvo_backup.layout) == 0);
     assert(strcmp(rmlvo.variant, rmlvo_backup.variant) == 0);
     assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0);
+
+    XkbFreeRMLVOSet(&rmlvo, FALSE);
+    XkbFreeRMLVOSet(&rmlvo_backup, FALSE);
 }
 
 int
diff --git a/test/xfree86.c b/test/xfree86.c
index 59e371633..76837d57e 100644
--- a/test/xfree86.c
+++ b/test/xfree86.c
@@ -63,17 +63,24 @@ xfree86_option_list_duplicate(void)
 
     assert(strcmp(val1, v1) == 0);
     assert(strcmp(val1, val2) == 0);
+    free(val1);
+    free(val2);
 
     val1 = xf86CheckStrOption(options, o2, "1");
     val2 = xf86CheckStrOption(duplicate, o2, "2");
 
     assert(strcmp(val1, v2) == 0);
     assert(strcmp(val1, val2) == 0);
+    free(val1);
+    free(val2);
 
     a = xf86FindOption(options, o_null);
     b = xf86FindOption(duplicate, o_null);
     assert(a);
     assert(b);
+
+    xf86OptionListFree(duplicate);
+    xf86OptionListFree(options);
 }
 
 static void
commit 373cd80081cedaa942b42d26d0fecad466ebf7c8
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jan 4 11:12:28 2024 +1000

    dix: use valuator_mask_free() to free the last touches vmask
    
    No functional effect since that one is just a free() call anyway.

diff --git a/dix/devices.c b/dix/devices.c
index bdbe2dc73..d58f96b47 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1021,7 +1021,7 @@ CloseDevice(DeviceIntPtr dev)
     free(dev->config_info);     /* Allocated in xf86ActivateDevice. */
     free(dev->last.scroll);
     for (j = 0; j < dev->last.num_touches; j++)
-        free(dev->last.touches[j].valuators);
+        valuator_mask_free(&dev->last.touches[j].valuators);
     free(dev->last.touches);
     dev->config_info = NULL;
     dixFreePrivates(dev->devPrivates, PRIVATE_DEVICE);
commit 7aba2514b28de455ee3daef5f84424f4376a5d37
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Jan 4 10:31:51 2024 +1000

    dix: don't allow for devices with 0 axes
    
    This just makes the existing behavior explicit, previously we relied on
    a malloc(numAxes * ...) to return NULL to error out.

diff --git a/dix/devices.c b/dix/devices.c
index 3f3224d62..bdbe2dc73 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1335,6 +1335,7 @@ InitValuatorClassDeviceStruct(DeviceIntPtr dev, int numAxes, Atom *labels,
     ValuatorClassPtr valc;
 
     BUG_RETURN_VAL(dev == NULL, FALSE);
+    BUG_RETURN_VAL(numAxes == 0, FALSE);
 
     if (numAxes > MAX_VALUATORS) {
         LogMessage(X_WARNING,


More information about the xorg-commit mailing list