From e3122e411c560b71cf4b3d9f9efcdfd97f3eda85 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Wed, 3 Sep 2025 15:57:34 +0200 Subject: [PATCH] xfree86: dga: simplify DGAClientStateChange() Simply do the action on matched screen inside the loop instead of saving the found client and acting on it later (if found). Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xfree86/common/xf86DGA.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c index 29a4e1486c..978196c41a 100644 --- a/hw/xfree86/common/xf86DGA.c +++ b/hw/xfree86/common/xf86DGA.c @@ -1306,29 +1306,26 @@ static void DGAClientStateChange(CallbackListPtr *pcbl, void *nulldata, void *calldata) { NewClientInfoRec *pci = (NewClientInfoRec *) calldata; - ClientPtr client = NULL; int i; for (i = 0; i < screenInfo.numScreens; i++) { - if (DGA_GETCLIENT(i) == pci->client) { - client = pci->client; + if (pci->client && (DGA_GETCLIENT(i) == pci->client)) { + if ((pci->client->clientState == ClientStateGone) || + (pci->client->clientState == ClientStateRetained)) + { + XDGAModeRec mode; + PixmapPtr pPix; + + DGA_SETCLIENT(i, NULL); + DGASelectInput(i, NULL, 0); + DGASetMode(i, 0, &mode, &pPix); + + if (--DGACallbackRefCount == 0) + DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); + } break; } } - - if (client && - ((client->clientState == ClientStateGone) || - (client->clientState == ClientStateRetained))) { - XDGAModeRec mode; - PixmapPtr pPix; - - DGA_SETCLIENT(i, NULL); - DGASelectInput(i, NULL, 0); - DGASetMode(i, 0, &mode, &pPix); - - if (--DGACallbackRefCount == 0) - DeleteCallback(&ClientStateCallback, DGAClientStateChange, NULL); - } } static int