summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2025-02-26xkb: move _XKB_RF_NAMES_PROP_ATOM define into xkbInit.cEnrico Weigelt, metux IT consult2-4/+2
It's only used there, nowhere else, so no need to keep it in a public API header. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>
2025-02-26xkb: drop unused XkbRF_Invalid define from xkbrules.hEnrico Weigelt, metux IT consult1-1/+0
Not used anywhere, so no need to keep it in public interface. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>
2025-02-26xkb: drop unused _XKB_RF_NAMES_PROP_MAXLEN defineEnrico Weigelt, metux IT consult1-1/+0
Not used anywhere, so no need to keep it in public header. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>
2025-02-26xkb: drop unused XkbRF_LoadRulesByName()Enrico Weigelt, metux IT consult2-38/+0
Not used anywhere, so no need to keep it around any longer. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>
2025-02-26Xext: drop disable flag for GE extensionEnrico Weigelt, metux IT consult3-4/+1
There's really no practical use for disabling GEEext, would just cause the Xserver misbehaviour (eg. missing byte swapping) Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1812>
2025-02-26dix: add prefix to grab state value definesEnrico Weigelt, metux IT consult4-56/+56
make it a bit easier to diffenciate from other symbols by adding a prefix to their names. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1837>
2025-02-26dix: unexport defines for device grab statesEnrico Weigelt, metux IT consult3-12/+14
These aren't used anywhere in modules or outside DIX & XI, so no need to keep them in public API any longer. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1837>
2025-02-26xkb: Add tbGetBufferString helper functionAlan Coopersmith1-21/+22
Handles common case of allocating & copying string to temporary buffer (cherry picked from xorg/lib/libxkbfile@8a91517ca6ea77633476595b0eb5b213357c60e5) Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
2025-02-26xkb: correcting mathematical nonsense in XkbGeomFPTextMartin Burggraf1-4/+12
Fixes formatting of negative numbers, so they don't show minus sign after the decimal point. (cherry picked from xorg/lib/libxkbfile@d2ec504fec2550f4fd046e801b34317ef4a4bab9) Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
2025-02-26xkb: Convert more sprintf calls to snprintf in xkbtext.cAlan Coopersmith1-19/+28
Based on xorg/lib/libxkbfile@390acfe5bb88cdab509b5eaae4041f265e969d2b Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
2025-02-26xkb: Check that needed is > 0 in XkbResizeKeyActionsJosé Expósito1-1/+1
Passing a negative value in `needed` to the `XkbResizeKeyActions()` function can create a `newActs` array of an unespected size. Check the value and return if it is invalid. This error has been found by a static analysis tool. This is the report: Error: OVERRUN (CWE-119): libX11-1.8.7/src/xkb/XKBMAlloc.c:811: cond_const: Checking "xkb->server->size_acts == 0" implies that "xkb->server->size_acts" is 0 on the true branch. libX11-1.8.7/src/xkb/XKBMAlloc.c:811: buffer_alloc: "calloc" allocates 8 bytes dictated by parameters "(size_t)((xkb->server->size_acts == 0) ? 1 : xkb->server->size_acts)" and "8UL". libX11-1.8.7/src/xkb/XKBMAlloc.c:811: var_assign: Assigning: "newActs" = "calloc((size_t)((xkb->server->size_acts == 0) ? 1 : xkb->server->size_acts), 8UL)". libX11-1.8.7/src/xkb/XKBMAlloc.c:815: assignment: Assigning: "nActs" = "1". libX11-1.8.7/src/xkb/XKBMAlloc.c:829: cond_at_least: Checking "nCopy > 0" implies that "nCopy" is at least 1 on the true branch. libX11-1.8.7/src/xkb/XKBMAlloc.c:830: overrun-buffer-arg: Overrunning buffer pointed to by "&newActs[nActs]" of 8 bytes by passing it to a function which accesses it at byte offset 15 using argument "nCopy * 8UL" (which evaluates to 8). # 828| # 829| if (nCopy > 0) # 830|-> memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i), # 831| nCopy * sizeof(XkbAction)); # 832| if (nCopy < nKeyActs) (cherry picked from xorg/lib/libx11@af1312d2873d2ce49b18708a5029895aed477392) Signed-off-by: José Expósito <jexposit@redhat.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
2025-02-26xkb: ensure XkbAllocNames sets num_rg to 0 on allocation failureAlan Coopersmith1-1/+3
If there was a previous radio_groups array which we failed to realloc and freed instead, clear the array size in the XkbNamesRec. Taken from xorg/lib/libx11@258a8ced681dc1bc50396be7439fce23f9807e2a Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1821>
2025-02-26ci: Install XCB dependencies for meson testsMichel Dänzer2-1/+4
The lack of these prevented some of the tests from running in CI.
2025-02-26mi: guard miPointer functions against NULL dereferencesPeter Hutterer1-0/+16
Already in place for some functions, let's add it to most others. The only function missing is miPointerSetPosition() which needs to return the ScreenPtr and that one is unclear if we don't have a screen - returning NULL will crash the caller(s) so let's wait for something to trigger this bug before we try to fix it wrongly. Related to #1782 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1771>
2025-02-26mi: don't crash on miPointerGetPosition for disabled devicesPeter Hutterer1-2/+9
If a device is disabled, its master device is forcibly reset to NULL but unlike a floating device it doesn't have a sprite allocated. Calling miPointerGetPosition for a disabled device thus crashes. Avoid this by returning 0/0 for any device without a miPointer. This is a quick fix only, a proper fix for this issue is rather more involved. Closes #1782 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1771>
2025-02-25test: Fix xsync testOlivier Fourdan1-2/+6
The xsync test is relying on the values being changed even in the case of a BadMatch value. Typically, it updates the delta but does not update the test type comparison, so when passing a negative value, it generates a BadMatch. That's actually not correct, and that will fail with the new fixes that check the validity of the values prior to apply the changes. Fix the test by updating the test type as needed. Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1835>
2025-02-25sync: Apply changes last in SyncChangeAlarmAttributes()Olivier Fourdan1-15/+27
SyncChangeAlarmAttributes() would apply the various changes while checking for errors. If one of the changes triggers an error, the changes for the trigger, counter or delta value would remain, possibly leading to inconsistent changes. Postpone the actual changes until we're sure nothing else can go wrong. Related to CVE-2025-26601, ZDI-CAN-25870 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25sync: Do not fail SyncAddTriggerToSyncObject()Olivier Fourdan1-4/+3
We do not want to return a failure at the very last step in SyncInitTrigger() after having all changes applied. SyncAddTriggerToSyncObject() must not fail on memory allocation, if the allocation of the SyncTriggerList fails, trigger a FatalError() instead. Related to CVE-2025-26601, ZDI-CAN-25870 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25sync: Check values before applying changesOlivier Fourdan1-18/+18
In SyncInitTrigger(), we would set the CheckTrigger function before validating the counter value. As a result, if the counter value overflowed, we would leave the function SyncInitTrigger() with the CheckTrigger applied but without updating the trigger object. To avoid that issue, move the portion of code checking for the trigger check value before updating the CheckTrigger function. Related to CVE-2025-26601, ZDI-CAN-25870 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25sync: Do not let sync objects uninitializedOlivier Fourdan1-5/+8
When changing an alarm, the change mask values are evaluated one after the other, changing the trigger values as requested and eventually, SyncInitTrigger() is called. SyncInitTrigger() will evaluate the XSyncCACounter first and may free the existing sync object. Other changes are then evaluated and may trigger an error and an early return, not adding the new sync object. This can be used to cause a use after free when the alarm eventually triggers. To avoid the issue, delete the existing sync object as late as possible only once we are sure that no further error will cause an early exit. CVE-2025-26601, ZDI-CAN-25870 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25dix: Dequeue pending events on frozen device on removalOlivier Fourdan1-0/+18
When a device is removed while still frozen, the events queued for that device remain while the device itself is freed. As a result, replaying the events will cause a use after free. To avoid the issue, make sure to dequeue and free any pending events on a frozen device when removed. CVE-2025-26600, ZDI-CAN-25871 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25composite: initialize border clip even when pixmap alloc failsOlivier Fourdan1-3/+8
If it fails to allocate the pixmap, the function compAllocPixmap() would return early and leave the borderClip region uninitialized, which may lead to the use of uninitialized value as reported by valgrind: Conditional jump or move depends on uninitialised value(s) at 0x4F9B33: compClipNotify (compwindow.c:317) by 0x484FC9: miComputeClips (mivaltree.c:476) by 0x48559A: miValidateTree (mivaltree.c:679) by 0x4F0685: MapWindow (window.c:2693) by 0x4A344A: ProcMapWindow (dispatch.c:922) by 0x4A25B5: Dispatch (dispatch.c:560) by 0x4B082A: dix_main (main.c:282) by 0x429233: main (stubmain.c:34) Uninitialised value was created by a heap allocation at 0x4841866: malloc (vg_replace_malloc.c:446) by 0x4F47BC: compRedirectWindow (compalloc.c:171) by 0x4FA8AD: compCreateWindow (compwindow.c:592) by 0x4EBB89: CreateWindow (window.c:925) by 0x4A2E6E: ProcCreateWindow (dispatch.c:768) by 0x4A25B5: Dispatch (dispatch.c:560) by 0x4B082A: dix_main (main.c:282) by 0x429233: main (stubmain.c:34) Conditional jump or move depends on uninitialised value(s) at 0x48EEDBC: pixman_region_translate (pixman-region.c:2233) by 0x4F9255: RegionTranslate (regionstr.h:312) by 0x4F9B7E: compClipNotify (compwindow.c:319) by 0x484FC9: miComputeClips (mivaltree.c:476) by 0x48559A: miValidateTree (mivaltree.c:679) by 0x4F0685: MapWindow (window.c:2693) by 0x4A344A: ProcMapWindow (dispatch.c:922) by 0x4A25B5: Dispatch (dispatch.c:560) by 0x4B082A: dix_main (main.c:282) by 0x429233: main (stubmain.c:34) Uninitialised value was created by a heap allocation at 0x4841866: malloc (vg_replace_malloc.c:446) by 0x4F47BC: compRedirectWindow (compalloc.c:171) by 0x4FA8AD: compCreateWindow (compwindow.c:592) by 0x4EBB89: CreateWindow (window.c:925) by 0x4A2E6E: ProcCreateWindow (dispatch.c:768) by 0x4A25B5: Dispatch (dispatch.c:560) by 0x4B082A: dix_main (main.c:282) by 0x429233: main (stubmain.c:34) Conditional jump or move depends on uninitialised value(s) at 0x48EEE33: UnknownInlinedFun (pixman-region.c:2241) by 0x48EEE33: pixman_region_translate (pixman-region.c:2225) by 0x4F9255: RegionTranslate (regionstr.h:312) by 0x4F9B7E: compClipNotify (compwindow.c:319) by 0x484FC9: miComputeClips (mivaltree.c:476) by 0x48559A: miValidateTree (mivaltree.c:679) by 0x4F0685: MapWindow (window.c:2693) by 0x4A344A: ProcMapWindow (dispatch.c:922) by 0x4A25B5: Dispatch (dispatch.c:560) by 0x4B082A: dix_main (main.c:282) by 0x429233: main (stubmain.c:34) Uninitialised value was created by a heap allocation at 0x4841866: malloc (vg_replace_malloc.c:446) by 0x4F47BC: compRedirectWindow (compalloc.c:171) by 0x4FA8AD: compCreateWindow (compwindow.c:592) by 0x4EBB89: CreateWindow (window.c:925) by 0x4A2E6E: ProcCreateWindow (dispatch.c:768) by 0x4A25B5: Dispatch (dispatch.c:560) by 0x4B082A: dix_main (main.c:282) by 0x429233: main (stubmain.c:34) Fix compAllocPixmap() to initialize the border clip even if the creation of the backing pixmap has failed, to avoid depending later on uninitialized border clip values. Related to CVE-2025-26599, ZDI-CAN-25851 Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25composite: Handle failure to redirect in compRedirectWindow()Olivier Fourdan1-2/+3
The function compCheckRedirect() may fail if it cannot allocate the backing pixmap. In that case, compRedirectWindow() will return a BadAlloc error. However that failure code path will shortcut the validation of the window tree marked just before, which leaves the validate data partly initialized. That causes a use of uninitialized pointer later. The fix is to not shortcut the call to compHandleMarkedWindows() even in the case of compCheckRedirect() returning an error. CVE-2025-26599, ZDI-CAN-25851 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Acked-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25Xi: Fix barrier device searchOlivier Fourdan1-4/+23
The function GetBarrierDevice() would search for the pointer device based on its device id and return the matching value, or supposedly NULL if no match was found. Unfortunately, as written, it would return the last element of the list if no matching device id was found which can lead to out of bounds memory access. Fix the search function to return NULL if not matching device is found, and adjust the callers to handle the case where the device cannot be found. CVE-2025-26598, ZDI-CAN-25740 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25xkb: Fix buffer overflow in XkbChangeTypesOfKey()Olivier Fourdan1-0/+1
If XkbChangeTypesOfKey() is called with nGroups == 0, it will resize the key syms to 0 but leave the key actions unchanged. If later, the same function is called with a non-zero value for nGroups, this will cause a buffer overflow because the key actions are of the wrong size. To avoid the issue, make sure to resize both the key syms and key actions when nGroups is 0. CVE-2025-26597, ZDI-CAN-25683 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25xkb: Fix computation of XkbSizeKeySymsOlivier Fourdan1-4/+4
The computation of the length in XkbSizeKeySyms() differs from what is actually written in XkbWriteKeySyms(), leading to a heap overflow. Fix the calculation in XkbSizeKeySyms() to match what kbWriteKeySyms() does. CVE-2025-26596, ZDI-CAN-25543 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25xkb: Fix buffer overflow in XkbVModMaskText()Olivier Fourdan1-8/+8
The code in XkbVModMaskText() allocates a fixed sized buffer on the stack and copies the virtual mod name. There's actually two issues in the code that can lead to a buffer overflow. First, the bound check mixes pointers and integers using misplaced parenthesis, defeating the bound check. But even though, if the check fails, the data is still copied, so the stack overflow will occur regardless. Change the logic to skip the copy entirely if the bound check fails. CVE-2025-26595, ZDI-CAN-25545 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25dix: keep a ref to the rootCursorPeter Hutterer1-0/+4
CreateCursor returns a cursor with refcount 1 - that refcount is used by the resource system, any caller needs to call RefCursor to get their own reference. That happens correctly for normal cursors but for our rootCursor we keep a variable to the cursor despite not having a ref for ourselves. Fix this by reffing/unreffing the rootCursor to ensure our pointer is valid. Related to CVE-2025-26594, ZDI-CAN-25544 Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-25Cursor: Refuse to free the root cursorOlivier Fourdan1-0/+4
If a cursor reference count drops to 0, the cursor is freed. The root cursor however is referenced with a specific global variable, and when the root cursor is freed, the global variable may still point to freed memory. Make sure to prevent the rootCursor from being explicitly freed by a client. CVE-2025-26594, ZDI-CAN-25544 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative v2: Explicitly forbid XFreeCursor() on the root cursor (Peter Hutterer <peter.hutterer@who-t.net>) v3: Return BadCursor instead of BadValue (Michel Dänzer <michel@daenzer.net>) Signed-off-by: Olivier Fourdan <ofourdan@redhat.com> Suggested-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1828>
2025-02-24glamor: explicitly draw endpoints of line segmentsJan Engelhardt1-0/+1
The OpenGL 4.6 specification §14.5.1 "Basic Line Rasterization" figure 14.2 says: """A diamond shaped region of height 1 is placed around each fragment center; those regions that the line segment **exits** cause rasterization to produce corresponding fragments.""" As the line does not necessarily exit the last diamond, it is necessary to explicitly paint a pixel at line ends. Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1434 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1755>
2025-02-24randr: RRScreenInit(): drop unnecessary zero'ingEnrico Weigelt, metux IT consult1-15/+0
The whole struct is already allocated by calloc(), so no need to explicitly zero-out individual fields. Fixes: 479b2be4ba - Clear allocated RandR screen private structure Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRQueryOutputProperty(): use SwapShort()/SwapLong()Enrico Weigelt, metux IT consult1-5/+7
Simplify reply payload preparation and sendout by using SwapShort() and SwapLong() instead of WriteToClientSwapped() and callbacks. This also allows even further simplifications by using generic macros for the request send path. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRListOutputProperties(): use SwapShort()/SwapLong()Enrico Weigelt, metux IT consult1-8/+11
Simplify reply payload preparation and sendout by using SwapShort() and SwapLong() instead of WriteToClientSwapped() and callbacks. This also allows even further simplifications by using generic macros for the request send path. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetCrtcGamma(): use SwapShort()/SwapLong()Enrico Weigelt, metux IT consult1-4/+7
Simplify reply payload preparation and sendout by using SwapShort() and SwapLong() instead of WriteToClientSwapped() and callbacks. This also allows even further simplifications by using generic macros for the request send path. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetProviderProperty(): use SwapShort()/SwapLong()Enrico Weigelt, metux IT consult1-6/+8
Simplify reply payload preparation and sendout by using SwapShort() and SwapLong() instead of WriteToClientSwapped() and callbacks. This also allows even further simplifications by using generic macros for the request send path. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetOutputProperty(): use SwapShort()/SwapLong()Enrico Weigelt, metux IT consult1-6/+8
Simplify reply payload preparation and sendout by using SwapShort() and SwapLong() instead of WriteToClientSwapped() and callbacks. This also allows even further simplifications by using generic macros for the request send path. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetOutputProperty(): rename reply struct to "rep"Enrico Weigelt, metux IT consult1-24/+24
Harmonize it with all the other reply struct fields, so we can later use generic macros for final preparation and writeout. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: RRCreateProviderProperty(): use calloc()Enrico Weigelt, metux IT consult1-7/+1
We can rely on everything being cleared. And usually even faster, as the compiler can emit optimized instructions for clearing a whole block at once. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: RROutputCreate(): use calloc()Enrico Weigelt, metux IT consult1-17/+1
We can rely on everything being cleared. And usually even faster, as the compiler can emit optimized instructions for clearing a whole block at once. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetMonitors(): collect reply payload in temporary bufferEnrico Weigelt, metux IT consult1-16/+28
Instead of arbitrary count of individual WriteToClient() calls on small chunks, collect the whole payload in a buffer and write it out all at once. This also makes possible to use generic macros for reply sending, as well as further simplifications in the write-out path. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetMonitors() use SwapLongs instead of callbacksEnrico Weigelt, metux IT consult1-3/+7
WriteSwappedDataToClient() calls a callback on each single field. We can have it easier and more efficient by just using SwapLongs() Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetCrtcTransform(): split reply header and payloadEnrico Weigelt, metux IT consult1-21/+20
Using struct initializer for the reply header and only allocating the payload on heap. This allows using generic macros for reply preparation and send-out later. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: ProcRRGetCrtcInfo(): use locally scoped variablesEnrico Weigelt, metux IT consult1-21/+15
Improve readability by moving the variables into local scopes. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: use struct initializer for reply structsEnrico Weigelt, metux IT consult12-197/+88
Improve readability, move the declarations to where they're needed first and get rid of extra individual assignments. In some cases this should also allow the compiler to produce a bit more efficient code. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: RRCrtcCreate(): drop unnecessary zero assigmentsEnrico Weigelt, metux IT consult1-8/+0
The struct is already zero'ed out by calloc(), so no need to additionally clear individual fields. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: use explicit case statement instead of SProcRandrVector tableEnrico Weigelt, metux IT consult3-71/+68
No need to go indirectly through a vector table, since everything's fixed anyways. It's not a pretty robust programming style: any changes need great care, in order to not mix up things. Replacing this by direct switch/case statement, which is using the defines from the xrandr protocol headers. Also adding a little bit more protection against subtle programming errors and reducing cognitive load (source size) on understanding the code by using a tiny macro for deducing define name and function name from the request's name. This approach actually uncovered some subtle bug that had been waiting in the dark for over 15 years. As collateral benefit, getting a tiny bit better performance. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: use explicit case statement instead of ProcRandrVector tableEnrico Weigelt, metux IT consult3-69/+68
No need to go indirectly through a vector table, since everything's fixed anyways. It's not a pretty robust programming style: any changes need great care, in order to not mix up things. Replacing this by direct switch/case statement, which is using the defines from the xrandr protocol headers. Also adding a little bit more protection against subtle programming errors and reducing cognitive load (source size) on understanding the code by using a tiny macro for deducing define name and function name from the request's name. This approach actually uncovered some subtle bug that had been waiting in the dark for over 15 years (see commit b87314c8766a6f3e4bbc74758f9b0c53d2c4e044) As collateral benefit, getting a tiny bit better performance. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24randr: let SProc*'s call their Proc*'s directlyEnrico Weigelt, metux IT consult3-47/+51
No need to go indirectly through an vector table. It's much clearer and easier to understand when calling them directly. And a tiny bit performance improvement as collateral benefit. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1794>
2025-02-24drop not needed includes of geext.hEnrico Weigelt, metux IT consult5-5/+0
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1810>
2025-02-24Xext: dpms: need to include geext.hEnrico Weigelt, metux IT consult1-0/+1
It's calling GERegisterExtension(), which is defined in geext.h Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1810>