Commit Graph

19733 Commits

Author SHA1 Message Date
Enrico Weigelt, metux IT consult 36d533f830 (!1967) dix: extra NULL safety check in SetClipRects()
Even though it might never be actually hit, it's better to have an
(really cheap) extra check, just in case.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 9b76094c53 (!1967) dix: extra NULL protection in UnmapSubwindows()
Even though it probably won't be hit ever, it's still better to be
really sure instead of some remote chance for hard segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 34360efebc (!1967) dix: clear free()ed pointers on CloseDownExtensions()
As safety precaution, clear the pointers to extion records that just
have been free()ed.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult ed84f43274 (!1967) dix: NULL-protect AllocGlyphCursor()
Return error to the client if sourcefont turns out to be NULL for
whatever reason.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 709db0833e (!1967) dix: devices: refine NULL checks in GetMaster()
The checking / branchin isn't entirely trivial to understand, and the
analyzer also gets confused. So rewrite it in an simpler way that's
easier to understand both the human reader as well as the analyzer.
(and so get rid of yet another false alarm)

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 8c1b6212e1 (!1967) dix: region: turn xfreeData() into inline func and add checks
For type-safety turn xfreeData() macro into an inline function.
Also adding some checks against accidentially free()'ing global data.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult fe301f124a (!1967) dix: make DeviceEnterLeaveEvent() anaylzer-friendly
The analyzer giving a false alarm on potential NULL-pointer deref here.
Even though that case can't happen, it's also not immediately clear
to the human reader.

To make both the analyzer as well human reader happier, reformulating
this function to by using fast-return pattern.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 1014867436 (!1967) dix: protect ChangeWindowDeviceCursor() from allocation failure
On memory allocation failure, return BadAlloc instead of crashing.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult fdefa80256 (!1967) include: regionstr.h: protect RegionUninit() from free()ing on .data
There might be a chance that RegionUninit() is trying to free() some
struct that's actually coming from .data segment.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 83445aa080 (!1967) dix: dixfonts: explain analyzer false alarm on alleged free() of stack chunk
The analyzer is wrong here, because the free'd closure pointer really points
to some calloc()'d chunk, instead of the PolyText()'s stack frame.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 7dd92b77bc (!1967) dix: NULL-protection in GestureAddRegularListener()
protect against the (unlikely) case that inputMasks == NULL.

| ../dix/gestures.c: In function ‘GestureAddRegularListener’:
| ../include/list.h:376:21: warning: dereference of NULL ‘0’ [CWE-476] [-Wanalyzer-null-dereference]
|   376 |         for (_entry = _list; _entry; _entry = (_entry)->_member)
| ../dix/gestures.c:241:9: note: in expansion of macro ‘nt_list_for_each_entry’
|   241 |         nt_list_for_each_entry(iclients, inputMasks->inputClients, next) {
|       |         ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult be470cbf46 (!1967) dix: protect from pScreen->SetCursorPosition == NULL
It's safer not relying on all ScreenProc's actually filled.

../dix/events.c: In function ‘CheckPhysLimits’:
../dix/events.c:780:14: warning: dereference of NULL ‘pScreen’ [CWE-476] [-Wanalyzer-null-dereference]
  780 |             (*pScreen->SetCursorPosition)
      |             ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 6d22e94cb4 (!1967) dix: touch: NULL-protection in TouchAddRegularListener()
protect against the (unlikely) case that inputMasks == NULL.

| ../dix/touch.c: In function ‘TouchAddRegularListener’:
| ../include/list.h:376:21: warning: dereference of NULL ‘0’ [CWE-476] [-Wanalyzer-null-dereference]
|   376 |         for (_entry = _list; _entry; _entry = (_entry)->_member)
| ../dix/touch.c:766:9: note: in expansion of macro ‘nt_list_for_each_entry’
|   766 |         nt_list_for_each_entry(iclients, inputMasks->inputClients, next) {
|       |         ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 8ab10dd316 (!1967) dix: region: add comments on xfreeData()
Commenting a few aspects need to be considered when using this macro.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 830b37f863 (!1967) dix: protect against alloc failure in ‘DeviceFocusEvent()
Fixes analyzer warning:

| ../dix/enterleave.c: In function ‘DeviceFocusEvent’:
| ../dix/enterleave.c:788:20: warning: dereference of possibly-NULL ‘xi2event’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   788 |     xi2event->type = GenericEvent;
|   ‘DoFocusEvents’: events 1-4

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 709e8e04b5 (!1967) dix: move props into WindowRec and fix potential NULL deref
The pointer to the window properties is currently inside the WindowOptional
structure, which may or may not exist at any given time. Thus, before accessing
those fields, at least need to check whether it exists, potentially need to
create it first.

Since a pointer is small (in relation to WindowRec) and windows having properties
is a pretty common, we can make our life much simpler here by moving the pointer
directly into WindowRec, so we don't need extra WindowOptionalRec allocation.

This also fixes an analyzer warning on potential NULL dereference issue:

| ../dix/property.c: In function ‘dixChangeWindowProperty’:
|../dix/property.c:343:37: warning: dereference of NULL ‘*pWin.optional’ [CWE-476] [-Wanalyzer-null-dereference]
|  343 |         pProp->next = pWin->optional->userProps;
|      |                       ~~~~~~~~~~~~~~^~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult a74b264aa0 (!1967) dix: protect doPolyText() from potential NULL dereference
There's a (theoretical) chance that origGC might be NULL, so better
be cautious and check for this - doesn't cost us much, probably just
another JZ instruction.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult b6f7ede94b (!1969) xfree86: parser: fix possible use-after-free xf86freeOutputClassList()
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 8520dcf013 (!1969) xfree86: dri: extra safety checks for NULL pointers / disabled extension
Be more cautious on possible NULL pointers or not yet registered
devPrivates. Better a gracefully fail instead of hard segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 646b669ba1 (!1969) xfree86: ddc: safety check for NULL pointer
Even though it *should* never be actually hit, it's still safer
to check for NULL instead of letting us crash with segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 70a6634b6a (!1969) xfree86: common: extra safety checks for NULL pointers
Even though it's unlikely ever getting it, still safer to have some
extra checks / asserts than unexpected segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 9af37ca4db (!1969) xfree86: common: fix not-found check in xf86platformAddDevice()
Safer (and easier to understand) if we look at the result pointer
instead of the counter for testing whether device wasn't found.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult d542b2b21e (!1969) xfree86: common: gracefully handle allocation failure
Better try to handle memory allocation gracefully than just hard
crashing by segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 5806d06a80 (!1969) xfree86: utils: gracefully handle allocation failure.
Better failing gracefully instead of hard crash via segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 3a9cf89434 (!1969) xfree86: int10: extra NULL protection
Even though chances are really low it's ever getting hit, it's still safer
to have some sanity checks (which don't cost us much) than risking segfault.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult e4a0829a56 (!1969) xfree86: modes: fix uninitialized variables
| ../hw/xfree86/modes/xf86RandR12.c: In function ‘xf86ComputeCrtcPan’:
| ../hw/xfree86/modes/xf86RandR12.c:310:54: warning: use of uninitialized value ‘r[1]’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
|   310 |             q[i] = m->m[1][i] * r[0] - m->m[0][i] * r[1];
|       |                                                     ~^~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 80accc08cb (!1969) xfree86: loader: add assert() in LoadModule()
There's (remote) chance that the (internal) module name could become
NULL (eg. allocation failure). Even though chances to hit it are very
low, it's still better to have a check here (that doesn't cost us much),
just in case. Assert fail is still better than segfault, since we're
at least getting some hint what might have happened.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 873f4c36e9 (!1969) xfree86: parser: check for alloc failure and possible NULL pointers
Adding paranoid extra checks against allocation failure and NULL pointers.
Even though might not be actually hit in practise, it's still better to
be cautious, just in case. And reducing analyzer noise this way.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 0f7fb5e338 (!1969) xfree86: x86emu: add extra assert()'s
The analyzer warnings (possible NULL dereference) are probably just
false alarms. But for safety adding assert()'s, which don't cost us
anything in non-debug builds.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult f89cf0c03b (!1968) glx: fix warning on potentially uninitialized variable in xorgGlxMakeCurrent()
| ../glx/glxcmds.c: In function ‘xorgGlxMakeCurrent’:
| ../glx/glxcmds.c:621:24: warning: use of uninitialized value ‘status’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
|   621 |                 return status;
|       |                        ^~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 4c9312a8aa (!1968) glx: NULL-protect validGlxFBConfigForWindow()
If this ever happens, we clearly have a bug, so print out proper warning,
instead of silently crashing the Xserver.

| ../glx/glxcmds.c: In function ‘validGlxFBConfigForWindow’:
| ../glx/glxcmds.c:127:16: warning: dereference of NULL ‘pVisual’ [CWE-476] [-Wanalyzer-null-dereference]
|   127 |     if (pVisual->class != glxConvertToXVisualType(config->visualType) ||
|       |         ~~~~~~~^~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 2b54cada8e (!1968) glx: protect createModeFromConfig() from allocation failure
| ../glx/glxdricommon.c: In function ‘createModeFromConfig’:
| ../glx/glxdricommon.c:142:23: warning: dereference of possibly-NULL ‘config’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   142 |     config->driConfig = driConfig;

Consumers can already handle returning NULL, so this seems the best compromise.
It will look like we don't have any modes at all. Certainly not nice, but at
least better than completely crashing the Xserver.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 4a505a8a0e (!1968) glx: createcontext: silence analyzer warning and make code easier to understand
This warning is probably a false alarm, but it's trivial to fix.

| ../glx/createcontext.c: In function ‘__glXDisp_CreateContextAttribsARB’:
| ../glx/createcontext.c:172:24: warning: dereference of NULL ‘0’ [CWE-476] [-Wanalyzer-null-dereference]
|   172 |         switch (attribs[i * 2]) {
|       |                 ~~~~~~~^~~~~~~

The situation is too complex for the analyzer to handle:
(but also not immediately clear for the human reader)

* `attribs` is only NULL when req->numAttribs is 0
* in that case, the for loop is no-op, so `attribs` won't ever be deref'ed.

We can make it easier for both analyzer as well as human reader by just putting
the whole loop into an `if (req->numAttribs)` and assigning it inside there.
There shouldn't be any (practically measurable) extra cost.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 66b9c32fd5 (!1970) Xext: panoramix: extra safety checks
Even though risk of being actually hit is minimal, better having some extra
safety checks instead of segfaulting, just in case.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult f39873ed90 (!1970) Xext: panoramix: protect from allocation failures
Handle memory allocations gracefully, instead of just segfaulting.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult f956ea43c8 (!1970) Xext: panoramix: fix uninitialized variable
| ../Xext/panoramiXprocs.c: In function ‘PanoramiXCopyArea’:
| ../Xext/panoramiXprocs.c:1152:13: warning: use of uninitialized value ‘pGC’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
|  1152 |         if (pGC && pGC->graphicsExposures) {
|       |             ^~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 0df0f70436 (!1970) Xext: xtest: extra NULL checks
Even though these probably never happen, it's still better having some
(really cheap) extra checks, just in case.

| ../Xext/xtest.c: In function ‘ProcXTestFakeInput’:
| ../Xext/xtest.c:385:17: warning: dereference of NULL ‘dev’ [CWE-476] [-Wanalyzer-null-dereference]
|   385 |         if (!dev->key)
|       |              ~~~^~~~~

| ../Xext/xtest.c:442:12: warning: dereference of NULL ‘dev’ [CWE-476] [-Wanalyzer-null-dereference]
|   442 |     if (dev->sendEventsProc)
|       |         ~~~^~~~~~~~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 34ff1371e7 (!1970) Xext: shape: fix warning on possible NULL dereference
Try not to rely on deep black magic of calloc(), instead skip the whole
part of nrects is zero.

| ../Xext/shape.c: In function ‘ProcShapeGetRectangles’:
| ../Xext/shape.c:995:24: warning: dereference of possibly-NULL ‘rects’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|   995 |             rects[i].x = box->x1;
|       |             ~~~~~~~~~~~^~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult a7214d3462 (!1970) Xext: shm: protect against possible NULL dereference
| ../Xext/shm.c: In function ‘ShmExtensionInit’:
| ../Xext/shm.c:1534:29: warning: dereference of possibly-NULL ‘screen_priv’ [CWE-690] [-Wanalyzer-possible-null-dereference]
|  1534 |             if (!screen_priv->shmFuncs)
|       |                  ~~~~~~~~~~~^~~~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult ae0f6f02bd (!1970) Xext: vidmode: protect against alloc failures and NULL pointers
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult c9d14817cd (!1970) Xext: selinux: fix possible NULL dereference
> ../Xext/xselinux_ext.c: In function ‘SELinuxSendItemsToClient’:
> ../Xext/xselinux_ext.c:358:18: warning: dereference of possibly-NULL ‘buf’ [CWE-690] [-Wanalyzer-possible-null-dereference]
>   358 |         buf[pos] = items[k].id;
>       |         ~~~~~~~~~^~~~~~~~~~~~~

> ../Xext/xselinux_ext.c: In function ‘SELinuxFreeItems’:
> ../Xext/xselinux_ext.c:335:9: warning: dereference of possibly-NULL ‘items’ [CWE-690] [-Wanalyzer-possible-null-dereference]
>   335 |         freecon(items[k].octx);
>       |         ^~~~~~~~~~~~~~~~~~~~~~

> ../Xext/xselinux_ext.c: In function ‘SELinuxPopulateItem’:
> ../Xext/xselinux_ext.c:321:11: warning: dereference of possibly-NULL ‘i’ [CWE-690] [-Wanalyzer-possible-null-dereference]
>   321 |     i->id = id;
>       |     ~~~~~~^~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 1fff8fc432 (!1970) Xext: sync: protect from NULL pointer dereference
> ../Xext/sync.c: In function ‘IdleTimeQueryValue’:
> ../Xext/sync.c:2654:18: warning: dereference of NULL ‘priv’ [CWE-476] [-Wanalyzer-null-dereference]
>  2654 |         deviceid = priv->deviceid;
>       |         ~~~~~~~~~^~~~~~~~~~~~~~~~

> ../Xext/sync.c: In function ‘IdleTimeBlockHandler’:
> ../Xext/sync.c:2666:14: warning: dereference of NULL ‘priv’ [CWE-476] [-Wanalyzer-null-dereference]
>  2666 |     int64_t *less = priv->value_less;
>       |              ^~~~

> ../Xext/sync.c:2773:9: warning: dereference of NULL ‘priv’ [CWE-476] [-Wanalyzer-null-dereference]
>  2773 |     if (LastEventTimeWasReset(priv->deviceid)) {
>       |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> ../Xext/sync.c: In function ‘IdleTimeBracketValues’:
> ../Xext/sync.c:2791:14: warning: dereference of NULL ‘priv’ [CWE-476] [-Wanalyzer-null-dereference]
>  2791 |     int64_t *less = priv->value_less;
>       |              ^~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult ea2749496b (!1970) Xext: sync: protect init_system_idle_counter() from allocation failure
Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 4bb65785c2 (!1970) Xext: xres: protect against free()ing from non-heap
> ../Xext/xres.c: In function ‘DestroyFragments’:
> ../Xext/xres.c:124:9: warning: ‘free’ of ‘it’ which points to memory on the stack [CWE-590] [-Wanalyzer-free-of-non-heap]
>   124 |         free(it);
>      |         ^~~~~~~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult e9e11a595e (!1972) randr: add BUG_* checks for possible NULL pointer issue
The ‘RRCrtcNotify() and RRCrtcSet() functions are exported, so there's chance
that a buggy driver could call them with NULL parameter, leading to segfault.
Those are hard to trace, so it's better having a BUG_* check here.

| ../randr/rrcrtc.c: In function ‘RRCrtcNotify’:
| ../randr/rrcrtc.c:187:5: warning: use of NULL ‘outputs’ where non-null expected [CWE-476] [-Wanalyzer-null-argument]
|   187 |     memcpy(crtc->outputs, outputs, numOutputs * sizeof(RROutputPtr));
|       |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

| ../randr/rrcrtc.c: In function ‘RRCrtcSet’:
| ../randr/rrcrtc.c:742:20: warning: dereference of NULL ‘outputs’ [CWE-476] [-Wanalyzer-null-dereference]
|   742 |         if (outputs[o]) {
|       |             ~~~~~~~^~~

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 8044988fc7 (!1972) randr: skip payload assembly in ProcRRGetScreenInfo() no data to send
If there's no data to send, the whole reply payload can be skipped entirely.
This can also ease the whole code flow, and we don't need to rely on the
individual copy loops never trying to dereference a NULL pointer.
(what the analyzer can't proof). Also scoping several some variables that
are only used when there actually is data to send.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 2ac3cacf91 (!1972) randr: skip payload assembly in rrGetScreenResources() no data to send
If there's no data to send, the whole reply payload can be skipped entirely.
This can also ease the whole code flow, and we don't need to rely on the
individual copy loops never trying to dereference a NULL pointer.
(what the analyzer can't proof). Also scoping several some variables that
are only used when there actually is data to send.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 727da90141 (!1972) randr: simplify reply assembly in ProcRRListProviderProperties()
Moving payload buffer assembly right into the same branch where the buffer is
allocated, so making the whole code flow easier to understand. Also moving the
byteswap there (when the fields should still be in CPU cache), instead of having
some callback doing it much later, so even more simplication.

As a nice by-product, that's also reducing some analyzer noise.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult 2b5ad4a9ba (!1972) randr: no need to for local temp buffer in ProcRRQueryProviderProperty()
The code can be much simpler by just using CopySwap32Write().
And we also don't need the callback in WriteSwappedDataToClient(),
just call the corresponding write function directly.

This also makes some analyzer warnings go away.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00
Enrico Weigelt, metux IT consult b57d486d95 (!1972) randr: ProcRRGetOutputInfo() skip payload assembly when nothing to do
If there's no extra payload to send, we can skip the whole payload
assembly chain.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
2025-06-03 11:37:31 +02:00