From a765857aaa450862f6a3dc5de811671fbc82ca61 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 1 Jun 2019 00:52:06 +0200 Subject: Remove the Must_have_memory hack. We are not using any alloc function that respects that variable, so lets drop it. Backport of this commit: commit 0ce61e21d6d7dcca0090e319bbcdb678570f2c3f Author: Adam Jackson Date: Fri Oct 3 16:05:19 2008 -0400 Remove the Must_have_memory hack. Also remove an astonishing amount of misunderstanding of how casts work. --- nx-X11/programs/Xserver/Xi/chgkbd.c | 2 -- nx-X11/programs/Xserver/dix/events.c | 25 ++++++++----------------- nx-X11/programs/Xserver/hw/nxagent/NXevents.c | 4 +--- nx-X11/programs/Xserver/include/globals.h | 1 - nx-X11/programs/Xserver/mi/micursor.c | 12 ++++-------- nx-X11/programs/Xserver/mi/migc.c | 6 ++---- nx-X11/programs/Xserver/os/utils.c | 2 -- 7 files changed, 15 insertions(+), 37 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/Xi/chgkbd.c b/nx-X11/programs/Xserver/Xi/chgkbd.c index 8f4e35773..2ca631e2d 100644 --- a/nx-X11/programs/Xserver/Xi/chgkbd.c +++ b/nx-X11/programs/Xserver/Xi/chgkbd.c @@ -153,11 +153,9 @@ ProcXChangeKeyboardDevice(register ClientPtr client) df->time = xf->time; df->traceGood = xf->traceGood; if (df->traceSize != xf->traceSize) { - Must_have_memory = TRUE; /* XXX */ df->trace = (WindowPtr *) realloc(df->trace, xf->traceSize * sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ } df->traceSize = xf->traceSize; for (i = 0; i < df->traceSize; i++) diff --git a/nx-X11/programs/Xserver/dix/events.c b/nx-X11/programs/Xserver/dix/events.c index 745932af3..70224c3b8 100644 --- a/nx-X11/programs/Xserver/dix/events.c +++ b/nx-X11/programs/Xserver/dix/events.c @@ -1938,10 +1938,8 @@ XYToWindow(int x, int y) if (spriteTraceGood >= spriteTraceSize) { spriteTraceSize += 10; - Must_have_memory = TRUE; /* XXX */ - spriteTrace = (WindowPtr *)realloc( + spriteTrace = realloc( spriteTrace, spriteTraceSize*sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ } spriteTrace[spriteTraceGood++] = pWin; pWin = pWin->firstChild; @@ -2455,11 +2453,9 @@ CheckPassiveGrabsOnWindow( { if (device->sync.evcount < count) { - Must_have_memory = TRUE; /* XXX */ - device->sync.event = (xEvent *)realloc(device->sync.event, - count* - sizeof(xEvent)); - Must_have_memory = FALSE; /* XXX */ + device->sync.event = realloc(device->sync.event, + count* + sizeof(xEvent)); } device->sync.evcount = count; for (dxE = device->sync.event; --count >= 0; dxE++, xE++) @@ -2627,10 +2623,8 @@ DeliverGrabbedEvent(register xEvent *xE, register DeviceIntPtr thisDev, FreezeThaw(thisDev, TRUE); if (thisDev->sync.evcount < count) { - Must_have_memory = TRUE; /* XXX */ - thisDev->sync.event = (xEvent *)realloc(thisDev->sync.event, - count*sizeof(xEvent)); - Must_have_memory = FALSE; /* XXX */ + thisDev->sync.event = realloc(thisDev->sync.event, + count*sizeof(xEvent)); } thisDev->sync.evcount = count; for (dxE = thisDev->sync.event; --count >= 0; dxE++, xE++) @@ -3505,11 +3499,8 @@ SetInputFocus( if (depth > focus->traceSize) { focus->traceSize = depth+1; - Must_have_memory = TRUE; /* XXX */ - focus->trace = (WindowPtr *)realloc(focus->trace, - focus->traceSize * - sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ + focus->trace = realloc(focus->trace, + focus->traceSize * sizeof(WindowPtr)); } focus->traceGood = depth; for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c index 43dfe8613..78d74a0d5 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXevents.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXevents.c @@ -367,10 +367,8 @@ XYToWindow(int x, int y) if (spriteTraceGood >= spriteTraceSize) { spriteTraceSize += 10; - Must_have_memory = TRUE; /* XXX */ - spriteTrace = (WindowPtr *)realloc( + spriteTrace = realloc( spriteTrace, spriteTraceSize*sizeof(WindowPtr)); - Must_have_memory = FALSE; /* XXX */ } spriteTrace[spriteTraceGood++] = pWin; pWin = pWin->firstChild; diff --git a/nx-X11/programs/Xserver/include/globals.h b/nx-X11/programs/Xserver/include/globals.h index d5b9c4407..50aaaa2bf 100644 --- a/nx-X11/programs/Xserver/include/globals.h +++ b/nx-X11/programs/Xserver/include/globals.h @@ -20,7 +20,6 @@ extern int monitorResolution; extern Bool loadableFonts; extern int defaultColorVisualClass; -extern Bool Must_have_memory; extern int GrabInProgress; extern char *ConnectionInfo; extern Bool noTestExtensions; diff --git a/nx-X11/programs/Xserver/mi/micursor.c b/nx-X11/programs/Xserver/mi/micursor.c index e95c43b3d..90b0f2ae9 100644 --- a/nx-X11/programs/Xserver/mi/micursor.c +++ b/nx-X11/programs/Xserver/mi/micursor.c @@ -53,8 +53,6 @@ SOFTWARE. #include "misc.h" #include "mi.h" -extern Bool Must_have_memory; - void miRecolorCursor( pScr, pCurs, displayed) ScreenPtr pScr; @@ -65,11 +63,9 @@ miRecolorCursor( pScr, pCurs, displayed) * This is guaranteed to correct any color-dependent state which may have * been bound up in private state created by RealizeCursor */ - (* pScr->UnrealizeCursor)( pScr, pCurs); - Must_have_memory = TRUE; /* XXX */ - (* pScr->RealizeCursor)( pScr, pCurs); - Must_have_memory = FALSE; /* XXX */ - if ( displayed) - (* pScr->DisplayCursor)( pScr, pCurs); + pScr->UnrealizeCursor(pScr, pCurs); + pScr->RealizeCursor(pScr, pCurs); + if (displayed) + pScr->DisplayCursor(pScr, pCurs); } diff --git a/nx-X11/programs/Xserver/mi/migc.c b/nx-X11/programs/Xserver/mi/migc.c index 4d67cbf5d..afd5031a4 100644 --- a/nx-X11/programs/Xserver/mi/migc.c +++ b/nx-X11/programs/Xserver/mi/migc.c @@ -68,11 +68,9 @@ miCreateGCOps(prototype) { GCOpsPtr ret; - /* XXX */ Must_have_memory = TRUE; - ret = (GCOpsPtr) malloc(sizeof(GCOps)); - /* XXX */ Must_have_memory = FALSE; + ret = malloc(sizeof(GCOps)); if (!ret) - return 0; + return NULL; *ret = *prototype; ret->devPrivate.val = 1; return ret; diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index 0a1e3f7b2..5634bb621 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -257,8 +257,6 @@ Bool PanoramiXExtensionDisabledHack = FALSE; int auditTrailLevel = 1; -Bool Must_have_memory = FALSE; - #if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED) #define HAS_SAVED_IDS_AND_SETEUID #endif -- cgit v1.2.3 From d8f5e647c92b73835665c555d06c8814c7d0dbb5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 30 May 2019 23:50:53 +0200 Subject: NXwindow.c: fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NXwindow.c:265:27: warning: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Wformat-overflow=] sprintf(artsd_port,"%d", nPort); ^~ NXwindow.c:265:26: note: directive argument in the range [-2147476648, 2147483647] sprintf(artsd_port,"%d", nPort); ^~~~ NXwindow.c:265:7: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 10 sprintf(artsd_port,"%d", nPort); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- nx-X11/programs/Xserver/hw/nxagent/NXwindow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 2fe37f79c..0851daf97 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -296,7 +296,7 @@ InitRootWindow(WindowPtr pWin) #ifdef NXAGENT_ARTSD { char artsd_port[10]; - int nPort; + short int nPort; extern void nxagentPropagateArtsdProperties(ScreenPtr pScreen, char *port); nPort = atoi(display) + 7000; sprintf(artsd_port,"%d", nPort); -- cgit v1.2.3 From a3e0376f95cb57aeda12438313cba67b1690d685 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 29 May 2019 23:52:44 +0200 Subject: Window.c: remove leftover (commented) code This was eventually replaced by nxagentAddConfiguredWindow(pWin, CW_Map) some lines below which is just leading to the same code being executed some time later. (nxagentAddConfiguredWindow() will add a window to a list. nxagentFlushConfiguredWindow() is called at certain points to update all windows in that list in one go. "update" here means calling XConfigureWindow() or XMapWindow() on the real display.) --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 8307c3de4..7d98d25fe 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -1942,20 +1942,6 @@ Bool nxagentRealizeWindow(WindowPtr pWin) #endif */ - /* - * Mapping of the root window is called by - * InitRootWindow in DIX. Skip the operation - * if we are in rootless mode. - */ - - /* - * if (!nxagentOption(Rootless) || - * nxagentRootlessWindow != pWin) - * { - * XMapWindow(nxagentDisplay, nxagentWindow(pWin)); - * } - */ - #ifdef TEST if (nxagentOption(Rootless) && nxagentLastWindowDestroyed) { -- cgit v1.2.3 From 9f5ddede95086c6f31efe89ed228ac035a89a8e5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 30 May 2019 00:10:43 +0200 Subject: Window.c: Drop defines CWParent and CWStackingOrder They were just aliases to already existing defines and were not used stringently. So we had mix of aliased and non-aliased uses which is confusing when trying to understand the code... --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 28 ++++++++++++++-------------- nx-X11/programs/Xserver/hw/nxagent/Windows.h | 3 --- 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 7d98d25fe..f602d0ed3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -727,7 +727,7 @@ Bool nxagentPositionWindow(WindowPtr pWin, int x, int y) (void *) pWin, nxagentWindow(pWin), x, y); #endif - nxagentAddConfiguredWindow(pWin, CWParent | CWX | CWY | CWWidth | + nxagentAddConfiguredWindow(pWin, CWSibling | CWX | CWY | CWWidth | CWHeight | CWBorderWidth); return True; @@ -1284,7 +1284,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) { if (mask & CW_RootlessRestack) { - mask = CWStackingOrder; + mask = CWStackMode; } } @@ -1299,7 +1299,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) if (mask & CW_Update) { - mask |= CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackingOrder; + mask |= CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackMode; } if (mask & CWX) @@ -1378,7 +1378,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) MAKE_SYNC_CONFIGURE_WINDOW; } - if (mask & CWStackingOrder && + if (mask & CWStackMode && nxagentWindowPriv(pWin)->siblingAbove != nxagentWindowSiblingAbove(pWin)) { WindowPtr pSib; @@ -1478,7 +1478,7 @@ void nxagentConfigureWindow(WindowPtr pWin, unsigned int mask) * really needed? * * - * else if (mask & CWStackingOrder) + * else if (mask & CWStackMode) * { * if (nxagentSplashWindow) * { @@ -1920,12 +1920,12 @@ Bool nxagentRealizeWindow(WindowPtr pWin) /* * Not needed. * - * nxagentConfigureWindow(pWin, CWStackingOrder); + * nxagentConfigureWindow(pWin, CWStackMode); * * nxagentFlushConfigureWindow(); */ - nxagentAddConfiguredWindow(pWin, CWStackingOrder); + nxagentAddConfiguredWindow(pWin, CWStackMode); nxagentAddConfiguredWindow(pWin, CW_Shape); /* add by dimbor */ @@ -2116,10 +2116,10 @@ void nxagentCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion) void nxagentClipNotify(WindowPtr pWin, int dx, int dy) { /* - * nxagentConfigureWindow(pWin, CWStackingOrder); + * nxagentConfigureWindow(pWin, CWStackMode); */ - nxagentAddConfiguredWindow(pWin, CWStackingOrder); + nxagentAddConfiguredWindow(pWin, CWStackMode); nxagentAddConfiguredWindow(pWin, CW_Shape); #ifndef NXAGENT_SHAPE @@ -3572,10 +3572,10 @@ void nxagentAddConfiguredWindow(WindowPtr pWin, unsigned int valuemask) { unsigned int mask; - mask = valuemask & (CWParent | CWX | CWY | CWWidth | CWHeight | - CWBorderWidth | CWStackingOrder | CW_Map | CW_Update | CW_Shape); + mask = valuemask & (CWSibling | CWX | CWY | CWWidth | CWHeight | + CWBorderWidth | CWStackMode | CW_Map | CW_Update | CW_Shape); - valuemask &= ~(CWParent | CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackingOrder); + valuemask &= ~(CWSibling | CWX | CWY | CWWidth | CWHeight | CWBorderWidth | CWStackMode); if (mask & CWX && nxagentWindowPriv(pWin)->x != @@ -3612,11 +3612,11 @@ void nxagentAddConfiguredWindow(WindowPtr pWin, unsigned int valuemask) valuemask |= CWBorderWidth; } - if (mask & CWStackingOrder && + if (mask & CWStackMode && nxagentWindowPriv(pWin)->siblingAbove != nxagentWindowSiblingAbove(pWin)) { - valuemask |= CWStackingOrder; + valuemask |= CWStackMode; } { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Windows.h b/nx-X11/programs/Xserver/hw/nxagent/Windows.h index 8612cdf82..35d686a33 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Windows.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Windows.h @@ -159,9 +159,6 @@ extern int nxagentWindowPrivateIndex; #define nxagentDefaultWindowIsVisible() \ (nxagentVisibility != VisibilityFullyObscured) -#define CWParent CWSibling -#define CWStackingOrder CWStackMode - #define CW_Map (1 << 15) #define CW_Update (1 << 16) #define CW_Shape (1 << 17) -- cgit v1.2.3 From 28e42b3bd0d7fb5d5674acd256fed5e84903a271 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 4 May 2019 01:44:36 +0200 Subject: mi: Hush an almost certainly bogus warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 57e872301f5e836be2efb8f952f9c9711650b447 Author: Adam Jackson Date: Thu Apr 5 13:07:09 2018 -0400 mi: Hush an almost certainly bogus warning In file included from ../mi/miexpose.c:83: ../mi/miexpose.c: In function ‘miHandleExposures’: ../include/regionstr.h:174:22: warning: ‘expBox.y2’ may be used uninitialized in this function [-Wmaybe-uninitialized] (_pReg)->extents = *(_pBox); ~~~~~~~~~~~~~~~~~^~~~~~~~~~ ../mi/miexpose.c:139:12: note: ‘expBox.y2’ was declared here BoxRec expBox; ^~~~~~ etc. It's initialized if (extents), and then only read if (extents), but gcc doesn't seem to figure that out. Whatever, bzero it to be explicit. Signed-off-by: Adam Jackson Acked-by: Keith Packard --- nx-X11/programs/Xserver/mi/miexpose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/mi/miexpose.c b/nx-X11/programs/Xserver/mi/miexpose.c index 8e60f475e..274a8d4ce 100644 --- a/nx-X11/programs/Xserver/mi/miexpose.c +++ b/nx-X11/programs/Xserver/mi/miexpose.c @@ -151,7 +151,7 @@ miHandleExposures(pSrcDrawable, pDstDrawable, the window background */ WindowPtr pSrcWin; - BoxRec expBox; + BoxRec expBox = { 0, }; Bool extents; /* This prevents warning about pscr not being used. */ -- cgit v1.2.3 From b961e190bc69bc93cb1f3fd6cbff7e9c1247de25 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 1 May 2019 02:06:30 +0200 Subject: miwindow.c: add hint to Red Hat Bugzilla + fix --- nx-X11/programs/Xserver/mi/miwindow.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/mi/miwindow.c b/nx-X11/programs/Xserver/mi/miwindow.c index 2a583eda7..c696caf26 100644 --- a/nx-X11/programs/Xserver/mi/miwindow.c +++ b/nx-X11/programs/Xserver/mi/miwindow.c @@ -1052,6 +1052,7 @@ miSetShape(pWin) * pointer to the parent, so maybe doesn't change * the attribute of the window itself. This is to * be better investigated. + * Update: Red Hat fixed this bug the same way (BZ 676270). */ if (WasViewable && pOldClip) -- cgit v1.2.3 From 3900ba3f8459c4822eaa6b8ac6035980a63fdfff Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 1 May 2019 10:40:47 +0200 Subject: NXshm.c: remove left-overs from patch format was broken, would not compile --- nx-X11/programs/Xserver/hw/nxagent/NXshm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 246d39355..9a314391c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -387,8 +387,8 @@ ProcShmPutImage(client) ((stuff->format != ZPixmap) && (stuff->srcX < screenInfo.bitmapScanlinePad) && ((stuff->format == XYBitmap) || - - ((stuff->srcY == 0) && - - (stuff->srcHeight == stuff->totalHeight))))) && + ((stuff->srcY == 0) && + (stuff->srcHeight == stuff->totalHeight))))) && ((stuff->srcX + stuff->srcWidth) == stuff->totalWidth)) (*pGC->ops->PutImage) (pDraw, pGC, stuff->depth, stuff->dstX, stuff->dstY, @@ -396,7 +396,7 @@ ProcShmPutImage(client) stuff->srcX, stuff->format, shmdesc->addr + stuff->offset + (stuff->srcY * length)); -- else + else #endif { #ifdef TEST -- cgit v1.2.3 From 1a8de6352d068e0a45904cf9b80bde30561eca2f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 30 May 2019 00:30:46 +0200 Subject: dix/window.c: fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Window.c:3827:46: warning: array subscript 128 is above array bounds of ‘StoringPixmapRec *[128]’ {aka ‘struct *[128]’} [-Warray-bounds] i, (void *) nxagentBSPixmapList[i]); --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index f602d0ed3..6758e0875 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -3938,16 +3938,16 @@ int nxagentEmptyBSPixmapList(void) StoringPixmapPtr nxagentFindItemBSPixmapList(unsigned long pixmapId) { - int i; - - for (i = 0; i < BSPIXMAPLIMIT; i++) + for (int i = 0; i < BSPIXMAPLIMIT; i++) { if ((nxagentBSPixmapList[i] != NULL) && (nxagentBSPixmapList[i] -> storingPixmapId == pixmapId)) { #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: pixmapId [%lu].\n", pixmapId); - fprintf(stderr, "nxagentFindItemBSPixmapList: nxagentBSPixmapList[%d] -> storingPixmapId [%lu].\n", + fprintf(stderr, "%s: pixmapId [%lu].\n", __func__, pixmapId); + fprintf(stderr, "%s: nxagentBSPixmapList[%d] = [%p].\n", __func__, + i, (void *) nxagentBSPixmapList[i]); + fprintf(stderr, "%s: nxagentBSPixmapList[%d] -> storingPixmapId [%lu].\n", __func__, i, nxagentBSPixmapList[i] -> storingPixmapId); #endif @@ -3955,15 +3955,13 @@ StoringPixmapPtr nxagentFindItemBSPixmapList(unsigned long pixmapId) } } - #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: WARNING! Item not found.\n"); + #ifdef WARNING + fprintf(stderr, "%s: WARNING! Item not found.\n", __func__); #endif #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: Pixmap with id [%lu] not found.\n", + fprintf(stderr, "%s: Pixmap with id [%lu] not found.\n", __func__, pixmapId); - fprintf(stderr, "nxagentBSPixmapList[%d] = [%p].\n", - i, (void *) nxagentBSPixmapList[i]); #endif return NULL; -- cgit v1.2.3 From 1bfafc127c82b87bbb398bbd7c6984144c3fb3eb Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 30 May 2019 11:38:10 +0200 Subject: Window.c: add missing comment about nxagentConfiguredWindowList was in inital version of 6ce9fb5f2875754f97035d3338b3d0e1d20169ae but got lost during some rebasing/cherry-picking preceeding the pull request. --- nx-X11/programs/Xserver/hw/nxagent/Window.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index 6758e0875..78a5081f0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -3470,6 +3470,12 @@ void nxagentSetTopLevelEventMask(WindowPtr pWin) } /* + * Run nxagentConfigureWindow() on all windows in + * nxagentConfiguredWindowList and move them from the list + * afterwards. The list will be empty then. + * + * This is also taking care of entries in nxagentExposeQueue that need + * to be synchronized with the real X server. */ void nxagentFlushConfigureWindow(void) { -- cgit v1.2.3 From 2b25eb3d2fb4b2a50c0c746dfe967cfb82e38e1c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 12 Jun 2019 00:16:48 +0200 Subject: Pixmap.c: fix comment phrasing/spelling --- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index be154f9c2..676a0aebb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -1355,7 +1355,7 @@ Bool nxagentPixmapOnShadowDisplay(PixmapPtr pMap) /* FIXME: If the pixmap has a different depth from the window, the - XPutImage returns a BadMatch. For example this may happens if + XPutImage returns a BadMatch. For example this may happen if the Render extension is enabled. Can we fix this creating a new pixmap? */ @@ -1372,7 +1372,7 @@ FIXME: If the pixmap has a different depth from the window, the /* * If the framebuffer is updated continuously, the nxagent - * visualization become too much slow. + * visualization becomes much too slow. */ if ((GetTimeInMillis() - showTime) < 500) -- cgit v1.2.3 From 6d00a387fc138b575dfe9133d5120fa9cb6a3a45 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 12 Jun 2019 19:25:57 +0200 Subject: Rootless.c: improve TEST/WARN/DEBUG outout by adding [] around values as almost everywhere --- nx-X11/programs/Xserver/hw/nxagent/Rootless.c | 72 +++++++++++++-------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c index 82ec14fe9..f50cd1295 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c @@ -485,7 +485,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) { #ifdef TEST fprintf(stderr, "nxagentExportProperty: WARNING! Ignored ChangeProperty " - "on %swindow %lx property %s type %s nUnits %ld format %d\n", + "on %swindow [0x%lx] property [%s] type [%s] nUnits [%ld] format [%d]\n", nxagentWindowTopLevel(pWin) ? "toplevel " : "", nxagentWindow(pWin), validateString(propertyS), validateString(typeS), nUnits, format); #endif @@ -565,8 +565,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~IconPixmapHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon pixmap %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon pixmap [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_pixmap, propertyS, typeS, (void *) pWin); #endif @@ -587,8 +587,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~IconWindowHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon window %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon window [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_window, propertyS, typeS, (void *) pWin); #endif @@ -609,8 +609,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~IconMaskHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon mask %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up icon mask [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_mask, propertyS, typeS, (void *) pWin); #endif @@ -631,8 +631,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) propHints.flags &= ~WindowGroupHint; #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window group %x from hint " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window group [0x%x] from hint " + "exporting property [%s] type [%s] on window [%p].\n", (unsigned int) wmHints.window_group, propertyS, typeS, (void *) pWin); #endif @@ -650,7 +650,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) if (!atoms) { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '%s'- bailing out.\n", typeS); + fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '[%s]'- bailing out.\n", typeS); #endif return False; } @@ -679,7 +679,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) if (atoms[j] == None) { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to convert local atom %ld [%s].\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to convert local atom [%ld] [%s].\n", (long int) input[i], validateString(atomName)); #endif } @@ -708,7 +708,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) if (!wind) { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS); + fprintf(stderr, "nxagentExportProperty: WARNING! malloc() failed for '[%s]' - bailing out.\n", typeS); #endif return False; } @@ -728,8 +728,8 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) else { #ifdef WARNING - fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window %ld " - "exporting property %s type %s on window %p.\n", + fprintf(stderr, "nxagentExportProperty: WARNING! Failed to look up window [%ld] " + "exporting property [%s] type [%s] on window [%p].\n", (long int) input[i], propertyS, typeS, (void *) pWin); #endif @@ -819,7 +819,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) { #ifdef TEST fprintf(stderr, "nxagentExportProperty: WARNING! Ignored ChangeProperty " - "on %swindow %x property %s type %s nUnits %ld format %d\n", + "on %swindow [0x%x] property [%s] type [%s] nUnits [%ld] format [%d]\n", nxagentWindowTopLevel(pWin) ? "toplevel " : "", nxagentWindow(pWin), validateString(propertyS), validateString(typeS), nUnits, format); @@ -866,7 +866,7 @@ void nxagentImportProperty(Window window, if (pWin == NULL) { #ifdef TEST - fprintf(stderr, "nxagentImportProperty: Failed to look up remote window %lx property [%ld] exiting.\n", + fprintf(stderr, "nxagentImportProperty: Failed to look up remote window [0x%lx] property [%ld] exiting.\n", window, property); #endif @@ -885,7 +885,7 @@ void nxagentImportProperty(Window window, } #ifdef TEST - fprintf(stderr, "nxagentImportProperty: Window %lx property [%ld]: %s\n", + fprintf(stderr, "nxagentImportProperty: Window [0x%lx] property [%ld]: [%s]\n", window, property, validateString(NameForAtom(propertyL))); #endif @@ -900,7 +900,7 @@ void nxagentImportProperty(Window window, if (buffer == NULL && (nitems > 0)) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: Failed to retrieve remote property [%ld] %s on Window %ld\n", + fprintf(stderr, "nxagentImportProperty: Failed to retrieve remote property [%ld] [%s] on Window [%ld]\n", (long int) property, validateString(NameForAtom(propertyL)), (long int) window); #endif } @@ -956,8 +956,8 @@ void nxagentImportProperty(Window window, else if (wmState.icon) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote window %ld" - " importing property %ld of type WM_STATE", (long int) wmState.icon, + fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote window [%ld]" + " importing property [%ld] of type WM_STATE", (long int) wmState.icon, (long int) property); #endif } @@ -982,7 +982,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote icon " - "pixmap %d from hint importing property [%ld] type %s on window %p.\n", + "pixmap [%d] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_pixmap, (long int) property, typeS, (void *) pWin); #endif @@ -1003,7 +1003,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote icon " - "window %x from hint importing property [%ld] type %s on window %p.\n", + "window [0x%x] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_window, (long int) property, typeS, (void *) pWin); #endif @@ -1024,7 +1024,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote icon " - "mask %x from hint importing property [%ld] type %s on window %p.\n", + "mask [0x%x] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.icon_mask, (long int) property, typeS, (void *) pWin); #endif } @@ -1044,7 +1044,7 @@ void nxagentImportProperty(Window window, #ifdef WARNING fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote window " - "group %x from hint importing property [%ld] type %s on window %p.\n", + "group [0x%x] from hint importing property [%ld] type [%s] on window [%p].\n", (unsigned int) wmHints.window_group, (long int) property, typeS, (void *) pWin); #endif @@ -1060,7 +1060,7 @@ void nxagentImportProperty(Window window, if (atoms == NULL) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS); + fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '[%s]' - bailing out.\n", typeS); #endif return; @@ -1077,7 +1077,7 @@ void nxagentImportProperty(Window window, if (atoms[i] == None) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote atom %ld.\n", + fprintf(stderr, "nxagentImportProperty: WARNING! Failed to convert remote atom [%ld].\n", (long int) input[i]); #endif } @@ -1093,7 +1093,7 @@ void nxagentImportProperty(Window window, if (!wind) { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '%s' - bailing out.\n", typeS); + fprintf(stderr, "nxagentImportProperty: WARNING! malloc() failed for '[%s]' - bailing out.\n", typeS); #endif return; @@ -1113,8 +1113,8 @@ void nxagentImportProperty(Window window, else { #ifdef WARNING - fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote window %lx " - "importing property [%ld] type %s on window %p.\n", + fprintf(stderr, "nxagentImportProperty: WARNING! Failed to look up remote window [0x%lx] " + "importing property [%ld] type [%s] on window [%p].\n", (long int) input[i], (long int) property, typeS, (void*)pWin); #endif @@ -1127,7 +1127,7 @@ void nxagentImportProperty(Window window, { #ifdef TEST fprintf(stderr, "nxagentImportProperty: ChangeProperty " - "on window %lx property [%ld] type %s nitems %ld format %d\n", + "on window [0x%lx] property [%ld] type [%s] nitems [%ld] format [%d]\n", window, property, typeS, nitems, format); #endif @@ -1138,7 +1138,7 @@ void nxagentImportProperty(Window window, { #ifdef TEST fprintf(stderr, "nxagentImportProperty: WARNING! Ignored ChangeProperty " - "on window %lx property [%ld] type %s ntems %ld format %d\n", + "on window [0x%lx] property [%ld] type [%s] ntems [%ld] format [%d]\n", window, property, validateString(typeS), nitems, format); #endif } @@ -1183,7 +1183,7 @@ void nxagentRemovePropertyFromList(void) struct nxagentPropertyRec *tmp = nxagentPropertyList.first; #ifdef TEST - fprintf(stderr, "nxagentRemovePropertyFromList: Property %ld on Window %lx to list, list size is %d.\n\n", + fprintf(stderr, "nxagentRemovePropertyFromList: Property [%ld] on Window [0x%lx] to list, list size is [%d].\n\n", nxagentPropertyList.first -> property, nxagentPropertyList.first -> window, nxagentPropertyList.size); #endif @@ -1220,8 +1220,8 @@ void nxagentAddPropertyToList(Atom property, WindowPtr pWin) } #ifdef TEST - fprintf(stderr, "nxagentAddPropertyToList: Adding record Property %ld - Window %lx[%p]" - "to list, list size is %d.\n", property, nxagentWindow(pWin), (void*) pWin, + fprintf(stderr, "nxagentAddPropertyToList: Adding record Property [%ld] - Window [0x%lx][%p]" + "to list, list size is [%d].\n", property, nxagentWindow(pWin), (void*) pWin, nxagentPropertyList.size); #endif @@ -1262,12 +1262,12 @@ Bool nxagentNotifyMatchChangeProperty(void *p) XPropertyEvent *X = p; #ifdef TEST - fprintf(stderr, "nxagentNotifyMatchChangeProperty: Property notify on window %lx property %ld.\n", + fprintf(stderr, "nxagentNotifyMatchChangeProperty: Property notify on window [0x%lx] property [%ld].\n", X -> window, X -> atom); if (first) { - fprintf(stderr, "nxagentNotifyMatchChangeProperty: First element on list is window %lx property %ld list size is %d.\n", + fprintf(stderr, "nxagentNotifyMatchChangeProperty: First element on list is window [0x%lx] property [%ld] list size is [%d].\n", first -> window, first -> property, nxagentPropertyList.size); } else -- cgit v1.2.3 From 308824ba96b8752835e15dedf2bc0e1cd7c1ddaa Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 13 Jun 2019 22:56:45 +0200 Subject: xkb: initialize tsyms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backport of this commit: commit b2167015043a458e9cf93b827b43eb5b7c552ce9 Author: Giuseppe Bilotta Date: Sat Nov 4 23:06:27 2017 +0100 xkb: initialize tsyms This fixes some “Conditional jump depends on uninitialized value(s)” errors spotted by valgrind. Reviewed-by: Eric Engestrom Signed-off-by: Giuseppe Bilotta --- nx-X11/programs/Xserver/xkb/xkbUtils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/xkbUtils.c b/nx-X11/programs/Xserver/xkb/xkbUtils.c index 21a5ce76a..a545f06eb 100644 --- a/nx-X11/programs/Xserver/xkb/xkbUtils.c +++ b/nx-X11/programs/Xserver/xkb/xkbUtils.c @@ -187,7 +187,7 @@ XkbDescPtr xkb; unsigned key,nG,explicit; KeySymsPtr pCore; int types[XkbNumKbdGroups]; -KeySym tsyms[XkbMaxSymsPerKey],*syms; +KeySym tsyms[XkbMaxSymsPerKey] = {NoSymbol},*syms; XkbMapChangesPtr mc; xkb= pXDev->key->xkbInfo->desc; -- cgit v1.2.3 From 0f8dbbab2a218269165f06de37db59b5a20f09ea Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 14 Jun 2019 00:14:17 +0200 Subject: Screen.c: correctly free stuff in nxagentCloseScreen fixes a memory leak: ==19074== 2 bytes in 1 blocks are definitely lost in loss record 8 of 313 ==19074== at 0x483577F: malloc (vg_replace_malloc.c:299) ==19074== by 0x1FD83D: fbAllocatePrivates (fballpriv.c:79) ==19074== by 0x20A666: fbSetupScreen (fbscreen.c:110) ==19074== by 0x20A666: fbScreenInit (fbscreen.c:300) ==19074== by 0x1DEA4C: nxagentOpenScreen (Screen.c:1356) ==19074== by 0x16D7F8: AddScreen (dispatch.c:4257) ==19074== by 0x1DA0CF: InitOutput (Init.c:397) ==19074== by 0x14DCC2: main (main.c:280) --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 8568562c2..7d180da44 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -2141,20 +2141,32 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) fprintf(stderr, "running nxagentCloseScreen()\n"); #endif + /* + * We have called fbScreenInit() in nxagenOpenScreen, which in turn + * called fbOpenScreen. But we are not using the data as created by + * fbOpenScreen but have freed it and replaced by our own. So we free + * our own stuff here and take care that fbCloseScreen will not free + * them again. + */ + for (i = 0; i < pScreen->numDepths; i++) { free(pScreen->allowedDepths[i].vids); + pScreen->allowedDepths[i].vids = NULL; } + pScreen->numDepths = 0; + /* * Free the frame buffer. */ free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr); + free(pScreen->devPrivate);pScreen->devPrivate = NULL; + free(pScreen->allowedDepths); pScreen->allowedDepths = NULL; + free(pScreen->visuals); pScreen->visuals = NULL; - free(pScreen->allowedDepths); - free(pScreen->visuals); - free(pScreen->devPrivate); + fbCloseScreen(pScreen); /* * Reset the geometry and alpha information -- cgit v1.2.3 From 3b06ad51d91ff2b9442f159cddf34ed03bc2dd35 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jun 2019 16:06:02 +0200 Subject: Screen.c: Fix: make sure RRCloseScreen is being called Fixes ArcticaProject/nx-libs#598 In nxagentOpenScreen we first initialized the RRExtension for the screen and then replaced pScreen->CloseScreen by nxagentCloseScreen. This resulted in RandR's RRCloseScreen (and any other CloseScreen procedure installed by extensions) being no longer called. Moving RandR init after configuring pScreen->CloseScreen ensures the correct calling cascade: RRCloseScreen -> nxagentCloseScreen ->fbCloseScreen (called explicitly by nxagentCloseScreen). Which in turn will fix this memory leak: ==9688== 328 (312 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 271 of 319 ==9688== at 0x4837B65: calloc (vg_replace_malloc.c:752) ==9688== by 0x4ED2C6: RRScreenInit (randr.c:329) ==9688== by 0x1F2B18: nxagentInitRandRExtension (Extensions.c:122) ==9688== by 0x1DEAFF: nxagentOpenScreen (Screen.c:1409) ==9688== by 0x16D7F8: AddScreen (dispatch.c:4257) ==9688== by 0x1DA0CF: InitOutput (Init.c:397) ==9688== by 0x14DCC2: main (main.c:280) --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 7d180da44..84ef9c4a4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1401,13 +1401,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, pScreen -> rootVisual = defaultVisual; pScreen -> rootDepth = rootDepth; - /* - * Complete the initialization of the RANDR - * extension. - */ - - nxagentInitRandRExtension(pScreen); - /* * Set up the internal structures used for * tracking the proxy resources associated @@ -1694,6 +1687,13 @@ N/A nxagentOption(Height)) / 32) } + /* + * Complete the initialization of the RANDR + * extension. + */ + + nxagentInitRandRExtension(pScreen); + #ifdef TEST nxagentPrintAgentGeometry(NULL, "nxagentOpenScreen:"); #endif -- cgit v1.2.3 From 340de78e26e7837561909ae2a44c2ef85863d87b Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jun 2019 17:31:32 +0200 Subject: Keyboard.c: nullify freed pointers While trying to properly free memory allocated by XKB I accidently called nxagentFreeKeyboardDeviceData twice and noticed it would cause a segfault here. As the other pointers are also nullified after being freed let's just do it here, too. --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 96b33ea7d..46686b754 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -1327,14 +1327,18 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) dev->focus = NULL; } - for (k = dev->kbdfeed; k; k = knext) + if (dev->kbdfeed) { - knext = k->next; - #ifdef XKB - if (k->xkb_sli) - XkbFreeSrvLedInfo(k->xkb_sli); - #endif - free(k); + for (k = dev->kbdfeed; k; k = knext) + { + knext = k->next; + #ifdef XKB + if (k->xkb_sli) + XkbFreeSrvLedInfo(k->xkb_sli); + #endif + free(k); + } + dev->kbdfeed = NULL; } #ifdef DEBUG -- cgit v1.2.3 From ca741177e8a36f0eb5e84a047681bfd2edd3e3ba Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jun 2019 18:15:05 +0200 Subject: CloseDevice: call XkbRemoveResourceClient before freeing key class struct This patch is not necessary at the current code level. But when xkb code introduced the dev->key check Xorg upstream missed that. So we backport it now to skip that trap when updating xkb code. Author: Alan Coopersmith Date: Mon Jan 4 18:21:54 2010 -0800 CloseDevice: call XkbRemoveResourceClient before freeing key class struct XkbRemoveResourceClient() returns immediately if dev->key is NULL. CloseDevice calls XkbRemoveResourceClient until it removes all resources. If we free dev->key and NULL it before XkbRemoveResourceClient, then infinite loop ensues, and the server appears to hang on exit or crash. Signed-off-by: Alan Coopersmith Reviewed-by: Peter Hutterer Reviewed-by: Daniel Stone Signed-off-by: Keith Packard Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/dix/devices.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c index 51cf3fef9..8ad1cc371 100644 --- a/nx-X11/programs/Xserver/dix/devices.c +++ b/nx-X11/programs/Xserver/dix/devices.c @@ -203,7 +203,15 @@ CloseDevice(register DeviceIntPtr dev) if (dev->inited) (void)(*dev->deviceProc)(dev, DEVICE_CLOSE); + +#ifdef XKB + while (dev->xkb_interest) { + XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource); + } +#endif + free(dev->name); + if (dev->key) { #ifdef XKB @@ -267,11 +275,6 @@ CloseDevice(register DeviceIntPtr dev) #endif free(l); } -#ifdef XKB - while (dev->xkb_interest) { - XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource); - } -#endif free(dev->sync.event); free(dev); } -- cgit v1.2.3 From 4dd1f3cbdff984ff55bc2f88c64b2544c8d88148 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jun 2019 20:25:09 +0200 Subject: Fix memleaks: Free devPrivates of devices on shutdown Fixes these two memory leaks identified by valgrind: ==28336== 32 (8 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 180 of 308 ==28336== at 0x48356AF: malloc (vg_replace_malloc.c:298) ==28336== by 0x4837DE7: realloc (vg_replace_malloc.c:826) ==28336== by 0x1AE322: AllocateDevicePrivate (privates.c:439) ==28336== by 0x27527B: XkbSetExtension (xkbActions.c:72) ==28336== by 0x198E9B: _RegisterPointerDevice (devices.c:361) ==28336== by 0x1DBA35: InitInput (Init.c:440) ==28336== by 0x14DBD6: main (main.c:303) ==28336== ==28336== 32 (8 direct, 24 indirect) bytes in 1 blocks are definitely lost in loss record 181 of 308 ==28336== at 0x48356AF: malloc (vg_replace_malloc.c:298) ==28336== by 0x4837DE7: realloc (vg_replace_malloc.c:826) ==28336== by 0x1AE322: AllocateDevicePrivate (privates.c:439) ==28336== by 0x27527B: XkbSetExtension (xkbActions.c:72) ==28336== by 0x198F1B: _RegisterKeyboardDevice (devices.c:384) ==28336== by 0x1DBA3D: InitInput (Init.c:441) ==28336== by 0x14DBD6: main (main.c:303) --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 9 ++++++++- nx-X11/programs/Xserver/hw/nxagent/Pointer.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 46686b754..c8038955b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -1025,11 +1025,18 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio break; case DEVICE_CLOSE: - #ifdef TEST fprintf(stderr, "nxagentKeyboardProc: Called for [DEVICE_CLOSE].\n"); #endif + for (int i = 0; i < pDev->nPrivates; i++) + { + free(pDev->devPrivates[i].ptr); + pDev->devPrivates[i].ptr = NULL; + } + free(pDev->devPrivates); + pDev->devPrivates = NULL; + break; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c index c59230724..85d286b96 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pointer.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pointer.c @@ -40,7 +40,7 @@ is" without express or implied warranty. #include "X.h" #include "Xproto.h" #include "screenint.h" -#include "input.h" +#include "inputstr.h" #include "misc.h" #include "scrnintstr.h" #include "servermd.h" @@ -162,11 +162,18 @@ int nxagentPointerProc(DeviceIntPtr pDev, int onoff) break; case DEVICE_CLOSE: - #ifdef TEST fprintf(stderr, "nxagentPointerProc: Called for [DEVICE_CLOSE].\n"); #endif + for (int i = 0; i < pDev->nPrivates; i++) + { + free(pDev->devPrivates[i].ptr); + pDev->devPrivates[i].ptr = NULL; + } + free(pDev->devPrivates); + pDev->devPrivates = NULL; + break; } -- cgit v1.2.3 From 7564422263a10ec8992e538bb741b2ddb51dad82 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jun 2019 23:37:51 +0200 Subject: Screen.c: fix another memory leak ==12280== 0 bytes in 5 blocks are definitely lost in loss record 1 of 304 ==12280== at 0x483577F: malloc (vg_replace_malloc.c:299) ==12280== by 0x2EFC29: init_visuals (xf86glx.c:489) ==12280== by 0x2EFC29: __MESA_initVisuals (xf86glx.c:540) ==12280== by 0x17C902: GlxInitVisuals (glxext.c:317) ==12280== by 0x218C03: fbInitVisuals (fbcmap.c:668) ==12280== by 0x20BC41: fbFinishScreenInit (fbscreen.c:229) ==12280== by 0x20C005: fbScreenInit (fbscreen.c:273) ==12280== by 0x1E024C: nxagentOpenScreen (Screen.c:1356) ==12280== by 0x16D828: AddScreen (dispatch.c:4171) ==12280== by 0x1DB7DF: InitOutput (Init.c:396) ==12280== by 0x14DB12: main (main.c:279) ==12280== ==12280== 64 bytes in 2 blocks are definitely lost in loss record 223 of 304 ==12280== at 0x483577F: malloc (vg_replace_malloc.c:299) ==12280== by 0x2EFA05: init_visuals (xf86glx.c:489) ==12280== by 0x2EFA05: __MESA_initVisuals (xf86glx.c:540) ==12280== by 0x17C902: GlxInitVisuals (glxext.c:317) ==12280== by 0x218C03: fbInitVisuals (fbcmap.c:668) ==12280== by 0x20BC41: fbFinishScreenInit (fbscreen.c:229) ==12280== by 0x20C005: fbScreenInit (fbscreen.c:273) ==12280== by 0x1E024C: nxagentOpenScreen (Screen.c:1356) ==12280== by 0x16D828: AddScreen (dispatch.c:4171) ==12280== by 0x1DB7DF: InitOutput (Init.c:396) ==12280== by 0x14DB12: main (main.c:279) --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 84ef9c4a4..2fcb741db 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1391,15 +1391,23 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * by fbScreenInit with our own. */ - free(pScreen -> visuals); + for (int i = 0; i < pScreen->numDepths; i++) + { + #ifdef DEBUG + fprintf(stderr, "%s: depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); + #endif + free(pScreen->allowedDepths[i].vids); + } + free(pScreen -> allowedDepths); + pScreen -> allowedDepths = depths; + pScreen -> numDepths = numDepths; + pScreen -> rootDepth = rootDepth; + free(pScreen -> visuals); pScreen -> visuals = visuals; - pScreen -> allowedDepths = depths; pScreen -> numVisuals = numVisuals; - pScreen -> numDepths = numDepths; pScreen -> rootVisual = defaultVisual; - pScreen -> rootDepth = rootDepth; /* * Set up the internal structures used for -- cgit v1.2.3 From 5cb497146091acf84f389f6b459f5d2f8ea86643 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 18 Jun 2019 18:57:17 +0200 Subject: mi/miinitext.c: fix memleaks: remove (double) glx initialization Fix these memory leaks: ==30021== 128 bytes in 1 blocks are definitely lost in loss record 230 of 302 ==30021== at 0x483577F: malloc (vg_replace_malloc.c:299) ==30021== by 0x2EF89C: init_visuals (xf86glx.c:390) ==30021== by 0x2EF89C: __MESA_initVisuals (xf86glx.c:541) ==30021== by 0x17C922: GlxInitVisuals (glxext.c:317) ==30021== by 0x218E73: fbInitVisuals (fbcmap.c:668) ==30021== by 0x20BEB1: fbFinishScreenInit (fbscreen.c:229) ==30021== by 0x20C275: fbScreenInit (fbscreen.c:273) ==30021== by 0x1E0317: nxagentOpenScreen (Screen.c:1357) ==30021== by 0x16D848: AddScreen (dispatch.c:4171) ==30021== by 0x1DB7FF: InitOutput (Init.c:396) ==30021== by 0x14DB12: main (main.c:279) ==30021== ==30021== 3,072 (192 direct, 2,880 indirect) bytes in 1 blocks are definitely lost in loss record 290 of 302 ==30021== at 0x483577F: malloc (vg_replace_malloc.c:299) ==30021== by 0x2CCCC7: _gl_context_modes_create (glcontextmodes.c:364) ==30021== by 0x2EF87C: init_visuals (xf86glx.c:381) ==30021== by 0x2EF87C: __MESA_initVisuals (xf86glx.c:541) ==30021== by 0x17C922: GlxInitVisuals (glxext.c:317) ==30021== by 0x218E73: fbInitVisuals (fbcmap.c:668) ==30021== by 0x20BEB1: fbFinishScreenInit (fbscreen.c:229) ==30021== by 0x20C275: fbScreenInit (fbscreen.c:273) ==30021== by 0x1E0317: nxagentOpenScreen (Screen.c:1357) ==30021== by 0x16D848: AddScreen (dispatch.c:4171) ==30021== by 0x1DB7FF: InitOutput (Init.c:396) ==30021== by 0x14DB12: main (main.c:279) The problem here is that GlxInitVisuals is called twice. First via fbScreenInit and then again via nxagentInitGlxExtension. We remove the first one to ensure the code in nxagenOpenScreen works as initially intended. There's an xorg upstream patch that does the same (7d74690536b64f7b8e8036507ab7790807349c50), but it also cleans up other stuff we do not even have in out source (yet?). --- nx-X11/programs/Xserver/mi/miinitext.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/mi/miinitext.c b/nx-X11/programs/Xserver/mi/miinitext.c index 9e0f82643..319cb1f2d 100644 --- a/nx-X11/programs/Xserver/mi/miinitext.c +++ b/nx-X11/programs/Xserver/mi/miinitext.c @@ -228,7 +228,6 @@ extern void GlxPushProvider(__GLXprovider *impl); */ #ifndef __DARWIN__ extern void GlxExtensionInit(void); -extern void GlxWrapInitVisuals(miInitVisualsProcPtr *); #else extern void DarwinGlxExtensionInit(void); extern void DarwinGlxWrapInitVisuals(miInitVisualsProcPtr *); @@ -474,9 +473,7 @@ InitVisualWrap() { miResetInitVisuals(); #ifdef GLXEXT -#ifndef __DARWIN__ - GlxWrapInitVisuals(&miInitVisualsProc); -#else +#ifdef __DARWIN__ DarwinGlxWrapInitVisuals(&miInitVisualsProc); #endif #endif -- cgit v1.2.3 From 17d5e62ba400e105b7faf130ef31db299a5478c7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Mon, 17 Jun 2019 21:57:45 +0200 Subject: Events.c: use designated initializer in nxagentDeactivatePointerGrab --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 4bddbba3a..8e976779d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -4011,21 +4011,23 @@ void nxagentDeactivatePointerGrab(void) if (grab) { - XButtonEvent X; - memset(&X, 0, sizeof(XButtonEvent)); - - X.type = ButtonRelease; - X.serial = 0; - X.send_event = FALSE; - X.time = currentTime.milliseconds; - X.display = nxagentDisplay; - X.window = nxagentWindow(grab -> window); - X.root = RootWindow(nxagentDisplay, 0); - X.subwindow = 0; - X.x = X.y = X.x_root = X.y_root = 0; - X.state = 0x100; - X.button = 1; - X.same_screen = TRUE; + XButtonEvent X = { + .type = ButtonRelease, + .serial = 0, + .send_event = FALSE, + .time = currentTime.milliseconds, + .display = nxagentDisplay, + .window = nxagentWindow(grab -> window), + .root = RootWindow(nxagentDisplay, 0), + .subwindow = 0, + .x = 0, + .y = 0, + .x_root = 0, + .y_root = 0, + .state = 0x100, + .button = 1, + .same_screen = TRUE, + }; XPutBackEvent(nxagentDisplay, (XEvent*)&X); } -- cgit v1.2.3 From 7e12c9ba57eb583cf1d0a22894fa3c4c090a2c7f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 18 Jun 2019 19:04:12 +0200 Subject: Extension.c: code simplifications --- nx-X11/programs/Xserver/hw/nxagent/Extensions.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c index 785724cea..239d84b85 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Extensions.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Extensions.c @@ -98,13 +98,12 @@ void nxagentInitGlxExtension(VisualPtr *visuals, DepthPtr *depths, int *numVisuals, int *numDepths, int *rootDepth, VisualID *defaultVisual) { - miInitVisualsProcPtr initVisuals; /* * Initialize the visuals to use the GLX extension. */ - initVisuals = NULL; + miInitVisualsProcPtr initVisuals = NULL; GlxWrapInitVisuals(&initVisuals); @@ -372,15 +371,13 @@ static int nxagentRandRInitSizes(ScreenPtr pScreen) int nxagentRandRSetConfig(ScreenPtr pScreen, Rotation rotation, int rate, RRScreenSizePtr pSize) { - int r; - UpdateCurrentTime(); /* * Whatever size is OK for us. */ - r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height, + int r = nxagentResizeScreen(pScreen, pSize -> width, pSize -> height, pSize -> mmWidth, pSize -> mmHeight); nxagentMoveViewport(pScreen, 0, 0); @@ -430,8 +427,6 @@ void nxagentRandRSetWindowsSize(int width, int height) int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, CARD32 mmWidth, CARD32 mmHeight) { - int result; - UpdateCurrentTime(); if (nxagentOption(DesktopResize) == 1 && @@ -453,7 +448,7 @@ int nxagentRandRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, nxagentChangeOption(Height, height); } - result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); + int result = nxagentResizeScreen(pScreen, width, height, mmWidth, mmHeight); if (result == 1 && nxagentOption(DesktopResize) == 1 && nxagentOption(Fullscreen) == 0 && nxagentOption(AllScreens) == 0) -- cgit v1.2.3 From b5eb7c76e9758973a84a060d47b044f2acc980d3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 18 Jun 2019 19:10:38 +0200 Subject: Screen.c: more debug output --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 2fcb741db..b5d133b42 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1394,7 +1394,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, for (int i = 0; i < pScreen->numDepths; i++) { #ifdef DEBUG - fprintf(stderr, "%s: depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); + fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); #endif free(pScreen->allowedDepths[i].vids); } @@ -2159,6 +2159,9 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) for (i = 0; i < pScreen->numDepths; i++) { + #ifdef DEBUG + fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); + #endif free(pScreen->allowedDepths[i].vids); pScreen->allowedDepths[i].vids = NULL; } -- cgit v1.2.3 From bffdacc48a6bd49e4ac1b4ce5d2fcc8eecdb811c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Tue, 18 Jun 2019 23:36:45 +0200 Subject: glxext.c: fix another memory leak ==10226== 3,337 bytes in 1 blocks are definitely lost in loss record 295 of 307 ==10226== at 0x483577F: malloc (vg_replace_malloc.c:299) ==10226== by 0x6281DB9: strdup (strdup.c:42) ==10226== by 0x2ABA9E: __glXClientInfo (glxcmds.c:2170) ==10226== by 0x17CA3E: __glXDispatch (NXglxext.c:128) ==10226== by 0x16EE77: Dispatch (NXdispatch.c:476) ==10226== by 0x14DCE0: main (main.c:353) There's no point in trying to free cl->* after memset(0). This one is a bug that is found identically in xorg upstream and has only been fixed during rework of the whole client resource freeing stuff. So we fix it in glxext.c. --- nx-X11/programs/Xserver/GL/glx/glxext.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/GL/glx/glxext.c b/nx-X11/programs/Xserver/GL/glx/glxext.c index e92e605fa..4f2d2082d 100644 --- a/nx-X11/programs/Xserver/GL/glx/glxext.c +++ b/nx-X11/programs/Xserver/GL/glx/glxext.c @@ -64,6 +64,7 @@ static void ResetClientState(int clientIndex) if (cl->returnBuf) free(cl->returnBuf); if (cl->largeCmdBuf) free(cl->largeCmdBuf); if (cl->currentContexts) free(cl->currentContexts); + if (cl->GLClientextensions) free(cl->GLClientextensions); memset(cl, 0, sizeof(__GLXclientState)); /* ** By default, assume that the client supports @@ -71,9 +72,6 @@ static void ResetClientState(int clientIndex) */ cl->GLClientmajorVersion = 1; cl->GLClientminorVersion = 0; - if (cl->GLClientextensions) - free(cl->GLClientextensions); - } /* -- cgit v1.2.3 From cb508b2632f661e19b44f1375ddce3ffb415f4c5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 25 May 2019 19:38:14 +0200 Subject: various scope improvements --- nx-X11/programs/Xserver/hw/nxagent/Events.c | 24 +++++-------- nx-X11/programs/Xserver/hw/nxagent/Font.c | 49 +++++++++----------------- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 4 +-- nx-X11/programs/Xserver/hw/nxagent/NXglyph.c | 8 +---- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 12 ++----- nx-X11/programs/Xserver/hw/nxagent/Pixmap.c | 18 ++++------ nx-X11/programs/Xserver/hw/nxagent/Rootless.c | 38 +++++++------------- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 4 +-- 8 files changed, 50 insertions(+), 107 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 8e976779d..9d9f5d204 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -1964,14 +1964,14 @@ FIXME: Don't enqueue the KeyRelease event if the key was } case UnmapNotify: { - WindowPtr pWin; - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: Going to handle new UnmapNotify event.\n"); #endif if (nxagentOption(Rootless) == 1) { + WindowPtr pWin; + if ((pWin = nxagentRootlessTopLevelWindow(X.xunmap.window)) != NULL || ((pWin = nxagentWindowPtr(X.xunmap.window)) != NULL && nxagentWindowTopLevel(pWin) == 1)) @@ -1995,22 +1995,19 @@ FIXME: Don't enqueue the KeyRelease event if the key was } case MapNotify: { - WindowPtr pWin; - ClientPtr pClient; - #ifdef TEST fprintf(stderr, "nxagentDispatchEvents: Going to handle new MapNotify event.\n"); #endif if (nxagentOption(Rootless) == 1) { - Bool value = 1; + WindowPtr pWin; if ((pWin = nxagentRootlessTopLevelWindow(X.xmap.window)) != NULL || ((pWin = nxagentWindowPtr(X.xmap.window)) != NULL && nxagentWindowTopLevel(pWin) == 1)) { - pClient = wClient(pWin); + ClientPtr pClient = wClient(pWin); nxagentScreenTrap = 1; @@ -2021,6 +2018,8 @@ FIXME: Don't enqueue the KeyRelease event if the key was if (pWin != NULL) { + Bool value = 1; + TraverseTree(pWin, nxagentChangeMapPrivate, &value); } } @@ -2355,8 +2354,6 @@ int nxagentHandleKeyPress(XEvent *X, enum HandleEventResult *result) int nxagentHandlePropertyNotify(XEvent *X) { - int resource; - if (nxagentOption(Rootless) && !nxagentNotifyMatchChangeProperty((XPropertyEvent *) X)) { #ifdef TEST @@ -2366,7 +2363,7 @@ int nxagentHandlePropertyNotify(XEvent *X) if (nxagentWindowPtr(X -> xproperty.window) != NULL) { - resource = NXGetCollectPropertyResource(nxagentDisplay); + int resource = NXGetCollectPropertyResource(nxagentDisplay); if (resource == -1) { @@ -2643,8 +2640,6 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) { - WindowPtr pWin; - *result = doNothing; #ifdef TEST @@ -2680,7 +2675,7 @@ int nxagentHandleClientMessageEvent(XEvent *X, enum HandleEventResult *result) return 0; } - pWin = nxagentWindowPtr(X -> xclient.window); + WindowPtr pWin = nxagentWindowPtr(X -> xclient.window); if (pWin == NULL) { @@ -2886,7 +2881,6 @@ int nxagentHandleXkbKeyboardStateEvent(XEvent *X) int nxagentHandleXFixesSelectionNotify(XEvent *X) { - int i; Atom local; XFixesSelectionEvent *xfixesEvent = (XFixesSelectionEvent *) X; @@ -2915,7 +2909,7 @@ int nxagentHandleXFixesSelectionNotify(XEvent *X) if (SelectionCallback) { - i = 0; + int i = 0; while ((i < NumCurrentSelections) && CurrentSelections[i].selection != local) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 8de50fdc3..c135adb72 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -165,8 +165,6 @@ static struct _nxagentFailedToReconnectFonts void nxagentFreeFontCache(void) { - int i; - #ifdef NXAGENT_FONTCACHE_DEBUG fprintf(stderr, "Font: Freeing nxagent font cache\n"); #endif @@ -178,7 +176,7 @@ void nxagentFreeFontCache(void) fprintf(stderr, "Font: Freeing nxagent font cache, there are [%d] entries.\n", CACHE_INDEX); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { #ifdef NXAGENT_FONTCACHE_DEBUG fprintf(stderr, "Font: Freeing nxagent font cache entry [%d] entry pointer is [%p], name [%s]\n", @@ -208,8 +206,6 @@ void nxagentFreeFontCache(void) void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) { - int i, q, p; - char **xList; int xLen = 0; @@ -241,7 +237,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) * other one will select the 'real' fonts. */ - for (p = 0; p < patternsQt; p++) + for (int p = 0; p < patternsQt; p++) { xList = XListFonts(nxagentDisplay, patterns[p], maxNames, &xLen); @@ -256,11 +252,9 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) nxagentListRemoteAddName(searchPattern, maxNames); - for (i = 0; i < xLen; i++) + for (int i = 0; i < xLen; i++) { - q = 1; - - nxagentListRemoteAddName(xList[i], q); + nxagentListRemoteAddName(xList[i], 1); } XFreeFontNames(xList); @@ -270,7 +264,7 @@ void nxagentListRemoteFonts(const char *searchPattern, const int maxNames) fprintf(stderr, "nxagentListRemoteFonts: Printing remote font list.\n"); - for (i = 0; i < nxagentRemoteFontList.length; i++) + for (int i = 0; i < nxagentRemoteFontList.length; i++) { fprintf(stderr, "Font# %d, \"%s\"\n", i, nxagentRemoteFontList.list[i]->name); } @@ -353,9 +347,7 @@ void nxagentListRemoteAddName(const char *name, int status) static void nxagentFreeRemoteFontList(nxagentFontList *listRec) { - int l; - - for (l = 0; l < listRec -> length; l++) + for (int l = 0; l < listRec -> length; l++) { if (listRec -> list[l]) { @@ -857,7 +849,6 @@ static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) { nxagentPrivFont *privFont; Bool *pBool = (Bool*)param2; - int i; if (pFont == NULL || !*pBool) return; @@ -869,7 +860,7 @@ static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) (void *) pFont, privFont -> font_struct ? nxagentFont(pFont) : 0); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if (strcasecmp(CACHE_NAME(i), privFont -> fontName) == 0) { @@ -1043,13 +1034,11 @@ static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFreeCacheBeforeReconnect(void) { - int i; - #ifdef NXAGENT_RECONNECT_FONT_DEBUG printFontCacheDump("nxagentFreeCacheBeforeReconnect"); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if (CACHE_FSTRUCT(i)) { @@ -1061,15 +1050,13 @@ static void nxagentFreeCacheBeforeReconnect(void) static void nxagentCleanCacheAfterReconnect(void) { - int i, j; int real_size = CACHE_INDEX; - nxCacheFontEntryRecPtr swapEntryPtr; #ifdef NXAGENT_RECONNECT_FONT_DEBUG printFontCacheDump("nxagentCleanCacheAfterReconnect"); #endif - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if(CACHE_FSTRUCT(i) == NULL) { @@ -1078,8 +1065,11 @@ static void nxagentCleanCacheAfterReconnect(void) } } - for (i = 0; i < real_size; i++) + for (int i = 0; i < real_size; i++) { + int j; + nxCacheFontEntryRecPtr swapEntryPtr; + /* Find - first bad occurrence if exist. */ while ((i < real_size) && CACHE_FSTRUCT(i)) i++; @@ -1108,11 +1098,9 @@ static void nxagentCleanCacheAfterReconnect(void) #ifdef NXAGENT_RECONNECT_FONT_DEBUG static void printFontCacheDump(char* msg) { - int i; - fprintf(stderr, "%s - begin -\n", msg); - for (i = 0; i < CACHE_INDEX; i++) + for (int i = 0; i < CACHE_INDEX; i++) { if (CACHE_FSTRUCT(i)) { @@ -1129,7 +1117,6 @@ static void printFontCacheDump(char* msg) Bool nxagentReconnectAllFonts(void *p0) { - int cid; Bool fontSuccess = True; reconnectFlexibility = *((int *) p0); @@ -1147,7 +1134,7 @@ Bool nxagentReconnectAllFonts(void *p0) FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, (FindResType) nxagentFontReconnect, &fontSuccess); - for (cid = 0; cid < MAXCLIENTS; cid++) + for (int cid = 0; cid < MAXCLIENTS; cid++) { if (clients[cid]) { @@ -1258,7 +1245,6 @@ static void nxagentFreeFailedToReconnectFonts(void) Bool nxagentReconnectFailedFonts(void *p0) { - int i; int attempt = 1; const int maxAttempt = 5; @@ -1312,7 +1298,7 @@ Bool nxagentReconnectFailedFonts(void *p0) nxagentFreeRemoteFontList(&nxagentRemoteFontList); nxagentListRemoteFonts("*", nxagentMaxFontNames); - for(i = 0; i < nxagentFailedToReconnectFonts.index; i++) + for(int i = 0; i < nxagentFailedToReconnectFonts.index; i++) { fontSuccess = True; @@ -1365,7 +1351,6 @@ Bool nxagentReconnectFailedFonts(void *p0) Bool nxagentDisconnectAllFonts(void) { - int cid; Bool fontSuccess = True; #if defined(NXAGENT_RECONNECT_DEBUG) || defined(NXAGENT_RECONNECT_FONT_DEBUG) @@ -1384,7 +1369,7 @@ Bool nxagentDisconnectAllFonts(void) FindClientResourcesByType(clients[serverClient -> index], RT_NX_FONT, (FindResType) nxagentFontDisconnect, &fontSuccess); - for(cid = 0; cid < MAXCLIENTS; cid++) + for(int cid = 0; cid < MAXCLIENTS; cid++) { if( clients[cid] && fontSuccess ) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index c8038955b..cff92ec48 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -1299,8 +1299,6 @@ static int nxagentRestoreKeyboardDeviceData(DeviceIntPtr devBackup, DeviceIntPtr static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) { - KbdFeedbackPtr k, knext; - if (!dev) { #ifdef PANIC @@ -1336,7 +1334,7 @@ static int nxagentFreeKeyboardDeviceData(DeviceIntPtr dev) if (dev->kbdfeed) { - for (k = dev->kbdfeed; k; k = knext) + for (KbdFeedbackPtr k = dev->kbdfeed, knext; k; k = knext) { knext = k->next; #ifdef XKB diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 35dcbc132..1f82e73dc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -138,12 +138,6 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) int oldSize; CARD32 s; - #ifdef NXAGENT_SERVER - - CARD32 c; - - #endif - tableEntries = hash->tableEntries + change; hashSet = FindGlyphHashSet (tableEntries); if (hashSet == hash->hashSet) @@ -164,7 +158,7 @@ ResizeGlyphHash (GlyphHashPtr hash, CARD32 change, Bool global) #ifdef NXAGENT_SERVER - c = hash->table[i].corruptedGlyph; + CARD32 c = hash->table[i].corruptedGlyph; #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 4ea7d2d73..e35d1e9bc 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -309,12 +309,6 @@ static PicturePtr createSourcePicture(void) unsigned int totalPictureSize; - DevUnion *ppriv; - - char *privPictureRecAddr; - - int i; - /* * Compute size of entire PictureRect, plus privates. */ @@ -327,9 +321,9 @@ static PicturePtr createSourcePicture(void) if (pPicture != NULL) { - ppriv = (DevUnion *) (pPicture + 1); + DevUnion *ppriv = (DevUnion *) (pPicture + 1); - for (i = 0; i < picturePrivateCount; ++i) + for (int i = 0; i < picturePrivateCount; ++i) { /* * Other privates are inaccessible. @@ -338,7 +332,7 @@ static PicturePtr createSourcePicture(void) ppriv[i].ptr = NULL; } - privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; + char *privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; ppriv[nxagentPicturePrivateIndex].ptr = (void *) privPictureRecAddr; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 676a0aebb..653426ebb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -700,7 +700,6 @@ static void nxagentPixmapMatchID(void *p0, XID x1, void *p2) PixmapPtr nxagentPixmapPtr(Pixmap pixmap) { - int i; struct nxagentPixmapPair pair; if (pixmap == None) @@ -714,7 +713,7 @@ PixmapPtr nxagentPixmapPtr(Pixmap pixmap) FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentPixmapMatchID, &pair); - for (i = 0; (pair.pMap == NULL) && (i < MAXCLIENTS); i++) + for (int i = 0; (pair.pMap == NULL) && (i < MAXCLIENTS); i++) { if (clients[i]) { @@ -790,8 +789,8 @@ void nxagentDisconnectPixmap(void *p0, XID x1, void *p2) Bool nxagentDisconnectAllPixmaps(void) { - int r = 1; int i; + int r = 1; #ifdef TEST fprintf(stderr, "nxagentDisconnectAllPixmaps: Going to iterate through pixmap resources.\n"); @@ -958,8 +957,6 @@ Bool nxagentReconnectAllPixmaps(void *p0) { Bool result = 1; - int i; - #ifdef TEST fprintf(stderr, "nxagentReconnectAllPixmaps: Going to recreate all pixmaps.\n"); #endif @@ -991,7 +988,7 @@ Bool nxagentReconnectAllPixmaps(void *p0) #endif - for (i = 0, result = 1; i < MAXCLIENTS; result = 1, i++) + for (int i = 0, result = 1; i < MAXCLIENTS; result = 1, i++) { if (clients[i] != NULL) { @@ -1138,10 +1135,9 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) if (!integrity) { - int i; char *p, *q; - for (i = 0, p = image -> data, q = data; i < length; i++) + for (int i = 0, p = image -> data, q = data; i < length; i++) { if (p[i] != q[i]) { @@ -1187,7 +1183,6 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap) Bool nxagentCheckAllPixmapIntegrity(void) { - int i; Bool imageIsGood = True; #ifdef TEST @@ -1197,7 +1192,7 @@ Bool nxagentCheckAllPixmapIntegrity(void) FindClientResourcesByType(clients[serverClient -> index], RT_NX_PIXMAP, nxagentCheckOnePixmapIntegrity, &imageIsGood); - for (i = 0; (i < MAXCLIENTS) && (imageIsGood); i++) + for (int i = 0; (i < MAXCLIENTS) && (imageIsGood); i++) { if (clients[i]) { @@ -1630,11 +1625,10 @@ void nxagentPrintResourcePredicate(void *value, XID id, XID type, void *cdata) void nxagentPrintResources(void) { Bool result; - int i; nxagentPrintResourceTypes(); - for (i = 0; i < MAXCLIENTS; i++) + for (int i = 0; i < MAXCLIENTS; i++) { if (clients[i]) { diff --git a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c index f50cd1295..c2611c194 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Rootless.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Rootless.c @@ -120,12 +120,10 @@ static void nxagentPrintRootlessTopLevelWindowMap(void); void nxagentPrintRootlessTopLevelWindowMap(void) { - int i; - fprintf(stderr, "nxagentPrintRootlessTopLevelWindowMap: Map size is [%d] num of entry [%d].\n", topLevelParentMap.size, topLevelParentMap.next); - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { fprintf(stderr, "nxagentPrintRootlessTopLevelWindowMap: [%d] pWin at [%p] XID at [%ld].\n", i, (void *) topLevelParentMap.elt[i].pWin, (long int) topLevelParentMap.elt[i].xid); @@ -136,9 +134,7 @@ void nxagentPrintRootlessTopLevelWindowMap(void) void nxagentRootlessAddTopLevelWindow(WindowPtr pWin, Window w) { - int i; - - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { if (topLevelParentMap.elt[i].pWin == pWin) { @@ -181,9 +177,7 @@ void nxagentRootlessAddTopLevelWindow(WindowPtr pWin, Window w) WindowPtr nxagentRootlessTopLevelWindow(Window w) { - int i; - - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { if (w == topLevelParentMap.elt[i].xid) { @@ -196,9 +190,7 @@ WindowPtr nxagentRootlessTopLevelWindow(Window w) void nxagentRootlessDelTopLevelWindow(WindowPtr pWin) { - int i; - - for (i = 0; i < topLevelParentMap.next; i++) + for (int i = 0; i < topLevelParentMap.next; i++) { if (pWin == topLevelParentMap.elt[i].pWin) { @@ -506,7 +498,6 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) /* FIXME: is it okay here to ignore malloc fails? */ unsigned long *buffer = malloc(nUnits * sizeof(*buffer)); int *input = value; - int i; if (buffer) { @@ -514,7 +505,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) export = True; output = (char*) buffer; - for (i = 0; i < nUnits; i++) + for (int i = 0; i < nUnits; i++) { buffer[i] = input[i]; } @@ -644,7 +635,6 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) XlibAtom *atoms = malloc(nUnits * sizeof(*atoms)); Atom *input = value; const char *atomName = NULL; - int i; int j = 0; if (!atoms) @@ -659,7 +649,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) export = True; output = (char *) atoms; - for (i = 0; i < nUnits; i++) + for (int i = 0; i < nUnits; i++) { /* * Exporting the _NET_WM_PING property could @@ -703,7 +693,6 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) XlibWindow *wind = malloc(nUnits * sizeof(*wind)); ClientPtr pClient = wClient(pWin); WindowPtr pWindow; - int i; if (!wind) { @@ -717,7 +706,7 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) export = True; output = (char*) wind; - for (i = 0; i < nUnits; i++) + for (int i = 0; i < nUnits; i++) { pWindow = (WindowPtr)SecurityLookupWindow(input[i], pClient, DixDestroyAccess); @@ -774,15 +763,14 @@ int nxagentExportProperty(pWin, property, type, format, mode, nUnits, value) } else if (mode == PropModeReplace) { - int n; - char *data; + char * data = (char *) output; XDeleteProperty(nxagentDisplay, nxagentWindow(pWin), propertyX); - data = (char *) output; - while (nUnits > 0) { + int n; + if ((format >> 3) * nUnits + sizeof(xChangePropertyReq) < (MAX_REQUEST_SIZE << 2)) { @@ -1055,7 +1043,6 @@ void nxagentImportProperty(Window window, { Atom *atoms = malloc(nitems * sizeof(Atom)); Atom *input = (Atom*) buffer; - int i; if (atoms == NULL) { @@ -1070,7 +1057,7 @@ void nxagentImportProperty(Window window, import = True; output = (char *) atoms; - for (i = 0; i < nitems; i++) + for (int i = 0; i < nitems; i++) { atoms[i] = nxagentRemoteToLocalAtom(input[i]); @@ -1088,7 +1075,6 @@ void nxagentImportProperty(Window window, Window *input = (Window*) buffer; Window *wind = malloc(nitems * sizeof(Window)); WindowPtr pWindow; - int i; if (!wind) { @@ -1102,7 +1088,7 @@ void nxagentImportProperty(Window window, import = True; output = (char*) wind; - for (i = 0; i < nitems; i++) + for (int i = 0; i < nitems; i++) { pWindow = nxagentWindowPtr(input[i]); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index b5d133b42..147a3108d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -2143,8 +2143,6 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio Bool nxagentCloseScreen(ScreenPtr pScreen) { - int i; - #ifdef DEBUG fprintf(stderr, "running nxagentCloseScreen()\n"); #endif @@ -2157,7 +2155,7 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) * them again. */ - for (i = 0; i < pScreen->numDepths; i++) + for (int i = 0; i < pScreen->numDepths; i++) { #ifdef DEBUG fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); -- cgit v1.2.3 From 8205db4254b4dfba3ecc0cd800e334bdf430b3e3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 19 Jun 2019 01:12:26 +0200 Subject: Font.c: code simplifications --- nx-X11/programs/Xserver/hw/nxagent/Font.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index c135adb72..fb441d431 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -369,18 +369,16 @@ static void nxagentFreeRemoteFontList(nxagentFontList *listRec) Bool nxagentFontFind(const char *name, int *pos) { - int low,high,res,iter,lpos; - if (!nxagentRemoteFontList.length) { *pos=0; return False; } - low = 0; - high = nxagentRemoteFontList.length - 1; - iter = 0; - res = 1; - lpos = nxagentRemoteFontList.length; + int low = 0; + int high = nxagentRemoteFontList.length - 1; + int iter = 0; + int res = 1; + int lpos = nxagentRemoteFontList.length; while (low <= high) { *pos = (high + low)/2; @@ -416,18 +414,15 @@ Bool nxagentFontFind(const char *name, int *pos) Bool nxagentFontLookUp(const char *name) { int i; - int result; - - char *scalable; if (name != NULL && strlen(name) == 0) { return 0; } - result = nxagentFontFind(name, &i); + int result = nxagentFontFind(name, &i); - scalable = NULL; + char *scalable = NULL; /* * Let's try with the scalable font description. @@ -435,9 +430,7 @@ Bool nxagentFontLookUp(const char *name) if (result == 0) { - scalable = nxagentMakeScalableFontName(name, 0); - - if (scalable != NULL) + if ((scalable = nxagentMakeScalableFontName(name, 0)) != NULL) { result = nxagentFontFind(scalable, &i); @@ -451,9 +444,7 @@ Bool nxagentFontLookUp(const char *name) if (result == 0) { - scalable = nxagentMakeScalableFontName(name, 1); - - if (scalable != NULL) + if ((scalable = nxagentMakeScalableFontName(name, 1)) != NULL) { result = nxagentFontFind(scalable, &i); @@ -888,7 +879,6 @@ static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) static void nxagentCollectFailedFont(FontPtr fpt, XID id) { - if (nxagentFailedToReconnectFonts.font == NULL) { nxagentFailedToReconnectFonts.size = 8; @@ -1632,7 +1622,6 @@ XFontStruct* nxagentLoadQueryFont(register Display *dpy, char *name, FontPtr pFo int nxagentFreeFont(XFontStruct *fs) { - if (fs -> per_char) { #ifdef USE_XF86BIGFONT -- cgit v1.2.3 From 234be0245324b01676aff764b756248f4e57b45d Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 19 Jun 2019 23:10:40 +0200 Subject: glyph.c: fix a read beyond end of heap buffer If compiled with -fsanitize=address this showed up when running startlxde: ==11551==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60d000018fbc at pc 0x7f270a9ed57b bp 0x7fff30ef3050 sp 0x7fff30ef2800 READ of size 204 at 0x60d000018fbc thread T0 #0 0x7f270a9ed57a (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xb857a) #1 0x559dafcd5c93 in FindGlyphRef ../../render/glyph.c:179 #2 0x559dafcd705d in AddGlyph /work/nx-libs/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c:71 #3 0x559dafccc0ff in ProcRenderAddGlyphs ../../mi/../render/render.c:1186 #4 0x559dafcbd5a5 in ProcRenderDispatch /work/nx-libs/nx-X11/programs/Xserver/hw/nxagent/NXrender.c:1689 #5 0x559dafcbc4ea in Dispatch /work/nx-libs/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c:476 #6 0x559dafc4e9b0 in main /work/nx-libs/nx-X11/programs/Xserver/dix/main.c:353 #7 0x7f2708e1d09a in __libc_start_main ../csu/libc-start.c:308 #8 0x559dafc4f5d9 in _start (/work/nx-libs/nx-X11/programs/Xserver/nxagent+0x6e5d9) 0x60d000018fbc is located 0 bytes to the right of 140-byte region [0x60d000018f30,0x60d000018fbc) allocated by thread T0 here: #0 0x7f270aa1e330 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9330) #1 0x559dafcd646c in AllocateGlyph ../../render/glyph.c:348 This happens when two glyphs are compared via memcmp and the smaller one happens to be identical to the beginning of the bigger one. Newer render implementations use a sha1 hash instead of memcmp so this patch will (hopefully) be obsolete once render gets updated. --- nx-X11/programs/Xserver/hw/nxagent/NXglyph.c | 61 ++++++++++++++++++++++++++++ nx-X11/programs/Xserver/render/glyph.c | 2 + 2 files changed, 63 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c index 1f82e73dc..72d8242bd 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyph.c @@ -59,6 +59,67 @@ #endif +GlyphRefPtr +FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) +{ + CARD32 elt, step, s; + GlyphPtr glyph; + GlyphRefPtr table, gr, del; + CARD32 tableSize = hash->hashSet->size; + + table = hash->table; + elt = signature % tableSize; + step = 0; + del = 0; + for (;;) + { + gr = &table[elt]; + s = gr->signature; + glyph = gr->glyph; + if (!glyph) + { + if (del) + gr = del; + break; + } + if (glyph == DeletedGlyph) + { + if (!del) + del = gr; + else if (gr == del) + break; + } +#ifdef NXAGENT_SERVER + else if (s == signature && match && glyph->size != compare->size) + { + /* + * if the glyphsize is different there's no need to do a memcmp + * because it will surely report difference. And even worse: + * it will read beyond the end of glyph under some + * circumstances, which can be detected when compiling with + * -fsanitize=address. + */ + } +#endif + else if (s == signature && + (!match || + memcmp (&compare->info, &glyph->info, compare->size) == 0)) + { + break; + } + if (!step) + { + step = signature % hash->hashSet->rehash; + if (!step) + step = 1; + } + elt += step; + if (elt >= tableSize) + elt -= tableSize; + } + return gr; +} + void AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) { diff --git a/nx-X11/programs/Xserver/render/glyph.c b/nx-X11/programs/Xserver/render/glyph.c index a379b505f..93aed401b 100644 --- a/nx-X11/programs/Xserver/render/glyph.c +++ b/nx-X11/programs/Xserver/render/glyph.c @@ -144,6 +144,7 @@ GlyphInit (ScreenPtr pScreen) return TRUE; } +#ifndef NXAGENT_SERVER GlyphRefPtr FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) { @@ -192,6 +193,7 @@ FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) } return gr; } +#endif CARD32 HashGlyph (GlyphPtr glyph) -- cgit v1.2.3 From 6da1066109241d8c84cdb2b4674f4dd2a15c1a9c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Wed, 19 Jun 2019 23:44:40 +0200 Subject: Keyboard.c: fix three memory leaks ==12976==ERROR: LeakSanitizer: detected memory leaks Direct leak of 6 byte(s) in 1 object(s) allocated from: #0 0x7f510b3ac810 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3a810) #1 0x559ca29c5035 in nxagentKeyboardProc /home/uli/work/nx/ArcticaProject/nx-libs/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c:866 #2 0x7a29bff07 () Direct leak of 1 byte(s) in 1 object(s) allocated from: #0 0x7f510b3ac810 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3a810) #1 0x559ca29c509a in nxagentKeyboardProc /home/uli/work/nx/ArcticaProject/nx-libs/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c:870 #2 0x7a29bff07 () Direct leak of 1 byte(s) in 1 object(s) allocated from: #0 0x7f510b3ac810 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3a810) #1 0x559ca29c507f in nxagentKeyboardProc /home/uli/work/nx/ArcticaProject/nx-libs/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c:869 #2 0x7a29bff07 () SUMMARY: AddressSanitizer: 8 byte(s) leaked in 3 allocation(s). --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index cff92ec48..b2ae7dfd1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -945,6 +945,10 @@ XkbError: { NXShadowInitKeymap(&(pDev->key->curKeySyms)); } + + free(rules); + free(variant); + free(options); } if (xkb) -- cgit v1.2.3 From 6f954bb7d6fe3e80cce70121b18f09f39f0a1ce8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 00:13:25 +0200 Subject: Quarks.c: add missing ) --- nx-X11/lib/src/Quarks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/lib/src/Quarks.c b/nx-X11/lib/src/Quarks.c index 132ec6f67..0e702d566 100644 --- a/nx-X11/lib/src/Quarks.c +++ b/nx-X11/lib/src/Quarks.c @@ -88,7 +88,7 @@ static XrmQuark nextUniq = -1; /* next quark from XrmUniqueQuark */ #define STRQUANTSIZE (sizeof(XrmString) * (QUANTUMMASK + 1)) #ifdef PERMQ #define QUANTSIZE (STRQUANTSIZE + \ - (sizeof(Bits) * ((QUANTUMMASK + 1) >> 3)) + (sizeof(Bits) * ((QUANTUMMASK + 1) >> 3))) #else #define QUANTSIZE STRQUANTSIZE #endif -- cgit v1.2.3 From f55402572cc659888be7ace585bea8c8fcb7db32 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 00:26:47 +0200 Subject: dix/dispatch: fix a small memory leak --- nx-X11/programs/Xserver/dix/dispatch.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 6b6dbcad9..d656da748 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -4150,7 +4150,10 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , pScreen->devPrivates = (DevUnion *)calloc(sizeof(DevUnion), screenPrivateCount); if (!pScreen->devPrivates && screenPrivateCount) + { + free(pScreen); return -1; + } ret = init_screen(pScreen, i); if (ret != 0) { -- cgit v1.2.3 From 9f9b790f855f4a969b4ae6730e9cad8a9e743a3a Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 00:42:01 +0200 Subject: fb: fix memory leak in fbOverlayFinishScreenInit commit 2aa935bc5cc1e2d5365a97b8c5bb3d33eb5fc758 Author: Tiago Vignatti Date: Fri Mar 25 22:10:55 2011 +0200 fb: fix memory leak in fbOverlayFinishScreenInit Signed-off-by: Tiago Vignatti Reviewed-by: Nicolas Peninguy Reviewed-by: Peter Hutterer --- nx-X11/programs/Xserver/fb/fboverlay.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/fb/fboverlay.c b/nx-X11/programs/Xserver/fb/fboverlay.c index 6e0bbf252..95101a731 100644 --- a/nx-X11/programs/Xserver/fb/fboverlay.c +++ b/nx-X11/programs/Xserver/fb/fboverlay.c @@ -410,16 +410,20 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1, &defaultVisual, ((unsigned long)1<<(bpp1-1)) | - ((unsigned long)1<<(bpp2-1)), 8)) + ((unsigned long)1<<(bpp2-1)), 8)) { + free(pScrPriv); return FALSE; + } if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0, depth1, ndepths, depths, defaultVisual, nvisuals, visuals #ifdef FB_OLD_MISCREENINIT , (miBSFuncPtr) 0 #endif - )) + )) { + free(pScrPriv); return FALSE; + } /* MI thinks there's no frame buffer */ #ifdef MITSHM ShmRegisterFbFuncs(pScreen); -- cgit v1.2.3 From 78eff73e4a8cf6a428dd4bd5ed50e0515ec8794f Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 00:51:32 +0200 Subject: render: Propagate allocation failure from createSourcePicture() commit 211d4c2d353b5e379716484055a3f58235ea65f4 Author: Chris Wilson Date: Wed Dec 14 15:55:22 2011 +0000 render: Propagate allocation failure from createSourcePicture() All the callers were already checking for failure, except that createSourcePicture() itself was failing to check whether it successfully allocated the Picture. [ajax: Rebase, fix line wrap of preceding line] Signed-off-by: Chris Wilson Reviewed-by: Jeremy Huddleston --- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 2 ++ nx-X11/programs/Xserver/render/picture.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index e35d1e9bc..01821f474 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -318,6 +318,8 @@ static PicturePtr createSourcePicture(void) sizeof(nxagentPrivPictureRec); pPicture = (PicturePtr) calloc(1, totalPictureSize); + if (!pPicture) + return 0; if (pPicture != NULL) { diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c index eba042903..c06ac3550 100644 --- a/nx-X11/programs/Xserver/render/picture.c +++ b/nx-X11/programs/Xserver/render/picture.c @@ -979,6 +979,8 @@ static PicturePtr createSourcePicture(void) { PicturePtr pPicture; pPicture = (PicturePtr) malloc(sizeof(PictureRec)); + if (!pPicture) + return 0; pPicture->pDrawable = 0; pPicture->pFormat = 0; pPicture->pNext = 0; -- cgit v1.2.3 From e63d9de4565b97645956adf19d7f162ae0d471bd Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 00:59:16 +0200 Subject: NXrender: fix another memleak --- nx-X11/programs/Xserver/hw/nxagent/NXrender.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index fd9c0be82..190f746a4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -1004,7 +1004,11 @@ ProcRenderCompositeGlyphs (ClientPtr client) elementsBase = malloc(nlist * sizeof(XGlyphElt8)); if (!elementsBase) - return BadAlloc; + { + free(glyphsBase); + free(listsBase); + return BadAlloc; + } buffer = (CARD8 *) (stuff + 1); glyphs = glyphsBase; -- cgit v1.2.3 From 213e63eed7f808633dc865af94a9ea4ee703f228 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 01:21:44 +0200 Subject: Screen.c: fix two memleaks While at it create and use the freeDepths() helper function. --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 37 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 147a3108d..67151733f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -844,6 +844,19 @@ static int nxagentColorOffset(unsigned long mask) return count; } +void freeDepths(DepthPtr depths, int num) +{ + for (int i = 0; i < num; i++) + { + #ifdef DEBUG + fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, depths[i].depth, i, (void*) depths[i].vids); + #endif + free(depths[i].vids); + depths[i].vids = NULL; + } + free(depths); +} + Bool nxagentOpenScreen(ScreenPtr pScreen, int argc, char *argv[]) { @@ -1335,6 +1348,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (!pFrameBufferBits) { + freeDepths(depths, numDepths); return FALSE; } @@ -1356,6 +1370,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (!fbScreenInit(pScreen, pFrameBufferBits, nxagentOption(RootWidth), nxagentOption(RootHeight), monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel)) { + freeDepths(depths, numDepths); return FALSE; } @@ -1391,15 +1406,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * by fbScreenInit with our own. */ - for (int i = 0; i < pScreen->numDepths; i++) - { - #ifdef DEBUG - fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); - #endif - free(pScreen->allowedDepths[i].vids); - } - - free(pScreen -> allowedDepths); + freeDepths(pScreen->allowedDepths, pScreen->numDepths); pScreen -> allowedDepths = depths; pScreen -> numDepths = numDepths; pScreen -> rootDepth = rootDepth; @@ -2155,15 +2162,8 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) * them again. */ - for (int i = 0; i < pScreen->numDepths; i++) - { - #ifdef DEBUG - fprintf(stderr, "%s: freeing depth [%d] index [%d] vids [%p]\n", __func__, pScreen->allowedDepths[i].depth, i, (void*) pScreen->allowedDepths[i].vids); - #endif - free(pScreen->allowedDepths[i].vids); - pScreen->allowedDepths[i].vids = NULL; - } - + freeDepths(pScreen->allowedDepths, pScreen->numDepths); + pScreen->allowedDepths = NULL; pScreen->numDepths = 0; /* @@ -2172,7 +2172,6 @@ Bool nxagentCloseScreen(ScreenPtr pScreen) free(((PixmapPtr)pScreen -> devPrivate) -> devPrivate.ptr); free(pScreen->devPrivate);pScreen->devPrivate = NULL; - free(pScreen->allowedDepths); pScreen->allowedDepths = NULL; free(pScreen->visuals); pScreen->visuals = NULL; fbCloseScreen(pScreen); -- cgit v1.2.3 From bb08043a65ba7e600fafaa3c703915fcb8ad79d4 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 01:29:21 +0200 Subject: Screen.c: fix two more memleaks of visuals --- nx-X11/programs/Xserver/hw/nxagent/Screen.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 67151733f..6ec4b245f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -1349,6 +1349,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, if (!pFrameBufferBits) { freeDepths(depths, numDepths); + free(visuals); return FALSE; } @@ -1371,6 +1372,7 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, monitorResolution, monitorResolution, PixmapBytePad(nxagentOption(RootWidth), rootDepth), bitsPerPixel)) { freeDepths(depths, numDepths); + free(visuals); return FALSE; } -- cgit v1.2.3 From 528e1e4ef520506733ac3eeef374fcca41214cd1 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 01:31:17 +0200 Subject: NXpicture.c: code simplification --- nx-X11/programs/Xserver/hw/nxagent/NXpicture.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 01821f474..491af5b30 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -303,21 +303,17 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) static PicturePtr createSourcePicture(void) { - PicturePtr pPicture; - extern int nxagentPicturePrivateIndex; - unsigned int totalPictureSize; - /* * Compute size of entire PictureRect, plus privates. */ - totalPictureSize = sizeof(PictureRec) + + unsigned int totalPictureSize = sizeof(PictureRec) + picturePrivateCount * sizeof(DevUnion) + sizeof(nxagentPrivPictureRec); - pPicture = (PicturePtr) calloc(1, totalPictureSize); + PicturePtr pPicture = (PicturePtr) calloc(1, totalPictureSize); if (!pPicture) return 0; -- cgit v1.2.3 From 3c0469971a5092781783b6a5c86b668047e475be Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 01:35:22 +0200 Subject: os/access.c: add missing } --- nx-X11/programs/Xserver/os/access.c | 1 + 1 file changed, 1 insertion(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/os/access.c b/nx-X11/programs/Xserver/os/access.c index d8d035ade..df540e704 100644 --- a/nx-X11/programs/Xserver/os/access.c +++ b/nx-X11/programs/Xserver/os/access.c @@ -1348,6 +1348,7 @@ GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) if (getpeerucred(fd, &peercred) < 0) { FreeLocalClientCreds(lcc); return -1; + } lcc->euid = ucred_geteuid(peercred); if (lcc->euid != -1) lcc->fieldsSet |= LCC_UID_SET; -- cgit v1.2.3 From fd7e1f989b757667e7d7a3f0d08c9ee4b21a3a7c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 18:52:31 +0200 Subject: Keyboard.c: rearrange code to make cppcheck happy Otherwise it will (falsely) report "Memory pointed to by 'sessionpath' is freed twice." --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index b2ae7dfd1..7330784de 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -1696,7 +1696,10 @@ static char* getKeyboardFilePath(void) free(sessionpath); FatalError("malloc for keyboard file path failed."); } - free(sessionpath); + else + { + free(sessionpath); + } } else { -- cgit v1.2.3 From b4d3dc5bff6a8d3b09a61dbf8421a46fd23b82e8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 19:14:10 +0200 Subject: NXdixfonts.c: fix index out of bounds --- nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index 50bf719c6..bfb208593 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -1216,7 +1216,7 @@ nxdoListFontsAndAliases(client, fss) if (c->savedName) { memcpy(tmp,c->savedName,c->savedNameLen>255?255:c->savedNameLen); - tmp[c->savedNameLen>255?256:c->savedNameLen]=0; + tmp[c->savedNameLen>255?255:c->savedNameLen]=0; if (nxagentFontLookUp(tmp)) break; else tmp[0]=0; @@ -1225,7 +1225,7 @@ nxdoListFontsAndAliases(client, fss) else { memcpy(tmp,name,namelen>255?255:namelen); - tmp[namelen>255?256:namelen]=0; + tmp[namelen>255?255:namelen]=0; if (nxagentFontLookUp(tmp)) break; else tmp[0]=0; -- cgit v1.2.3 From d48824195009b2497b4233c9d3f2a8f9c1e6a2d7 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 19:51:00 +0200 Subject: compext/Png.c: late image_index allocation Move allocation of image_index close before first_use. This way we do not need to free it if previous step fail. And we cannot forget that free() call. While at it replace malloc+memset by calloc. --- nx-X11/programs/Xserver/hw/nxagent/compext/Png.c | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c index 0a258c5a3..e80f3879d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c +++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c @@ -253,17 +253,6 @@ char *PngCompressData(XImage *image, int *compressed_size) NXColorTable color_table[NB_COLOR_MAX]; CARD8 *image_index; - image_index = (CARD8 *) malloc((image -> height) * (image -> width) * sizeof(CARD8)); - - /* - * TODO: Be sure the padded bytes are cleaned. - * It would be better to set to zero the bytes - * that are not aligned to the word boundary - * at the end of the procedure. - */ - - memset(image_index, 0, (image -> height) * (image -> width) * sizeof(CARD8)); - *compressed_size = 0; pngDataLen = 0; @@ -283,7 +272,6 @@ char *PngCompressData(XImage *image, int *compressed_size) bitsPerPixel); #endif - free(image_index); return NULL; } @@ -316,7 +304,6 @@ char *PngCompressData(XImage *image, int *compressed_size) fprintf(stderr, "******PngCompressData: PANIC! Failed creating the png_create_write_struct.\n"); #endif - free(image_index); return NULL; } @@ -329,7 +316,6 @@ char *PngCompressData(XImage *image, int *compressed_size) #endif png_destroy_write_struct(&png_ptr, NULL); - free(image_index); return NULL; } @@ -341,7 +327,6 @@ char *PngCompressData(XImage *image, int *compressed_size) #endif png_destroy_write_struct(&png_ptr, &info_ptr); - free(image_index); return NULL; } @@ -364,8 +349,6 @@ char *PngCompressData(XImage *image, int *compressed_size) PNG_DEST_SIZE(w, h)); #endif - free(image_index); - return NULL; } @@ -383,6 +366,24 @@ char *PngCompressData(XImage *image, int *compressed_size) return NULL; } + image_index = (CARD8 *) calloc(1, (image -> height) * (image -> width) * sizeof(CARD8)); + if (image_index == NULL) + { + #ifdef PANIC + fprintf(stderr, "******PngCompressData: PANIC! Could not alloc image_index.\n"); + #endif + + free(pngCompBuf); + return NULL; + } + + /* + * TODO: Be sure the padded bytes are cleaned. + * It would be better to set to zero the bytes + * that are not aligned to the word boundary + * at the end of the procedure. + */ + png_set_compression_level(png_ptr, PNG_Z_LEVEL); if (bitsPerPixel == 16) -- cgit v1.2.3 From e440e722d8639411722d8a2499df46fe18c45f31 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 19:53:39 +0200 Subject: compext/Png.c: simplify srcBuf allocation --- nx-X11/programs/Xserver/hw/nxagent/compext/Png.c | 43 +++++++----------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c index e80f3879d..77a1941ea 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c +++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c @@ -481,47 +481,23 @@ char *PngCompressData(XImage *image, int *compressed_size) return NULL; } + int count; if (color_type == PNG_COLOR_TYPE_PALETTE) { - srcBuf = (CARD8 *) malloc(w * sizeof(CARD8)); - - if (srcBuf == NULL) - { - #ifdef PANIC - fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n", - (int) (w * sizeof(CARD8))); - #endif - - free(image_index); - - return NULL; - } - - /* - * TODO: Be sure the padded bytes are cleaned. - * It would be better to set to zero the bytes - * that are not aligned to the word boundary - * at the end of the procedure. - */ - - memset(srcBuf, 0, w * sizeof(CARD8)); + count = w; } else { - srcBuf = (CARD8 *) malloc(w * 3 * sizeof(CARD8)); - - /* - * TODO: See above. - */ - - memset(srcBuf, 0, w * 3 * sizeof(CARD8)); + count = 3 * w; } + srcBuf = (CARD8 *) calloc(count, sizeof(CARD8)); + if (srcBuf == NULL) { #ifdef PANIC fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n", - w * 3); + (int) (count * sizeof(CARD8))); #endif free(pngCompBuf); @@ -530,6 +506,13 @@ char *PngCompressData(XImage *image, int *compressed_size) return NULL; } + /* + * TODO: Be sure the padded bytes are cleaned. + * It would be better to set to zero the bytes + * that are not aligned to the word boundary + * at the end of the procedure. + */ + for (dy = 0; dy < h; dy++) { if (color_type == PNG_COLOR_TYPE_RGB) -- cgit v1.2.3 From 956caeb8af1f14a52879d39c98caeb1e13edd546 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 19:54:44 +0200 Subject: compext/Png.c: Nullify after free --- nx-X11/programs/Xserver/hw/nxagent/compext/Png.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c index 77a1941ea..5c3a27612 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c +++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c @@ -532,8 +532,8 @@ char *PngCompressData(XImage *image, int *compressed_size) dy, h); #endif - free(srcBuf); - free(image_index); + free(srcBuf); srcBuf = NULL; + free(image_index); image_index = NULL; if (setjmp(png_jmpbuf(png_ptr))) { -- cgit v1.2.3 From c8520ac0aabb475d92ea6b60e3113f2999c04eb8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 20 Jun 2019 23:14:09 +0200 Subject: mi/miexpose.c: add missing free() --- nx-X11/programs/Xserver/mi/miexpose.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/mi/miexpose.c b/nx-X11/programs/Xserver/mi/miexpose.c index 274a8d4ce..40272f962 100644 --- a/nx-X11/programs/Xserver/mi/miexpose.c +++ b/nx-X11/programs/Xserver/mi/miexpose.c @@ -757,7 +757,10 @@ int what; if (screenContext[i] == (GCPtr)NULL) { if (!ResType && !(ResType = CreateNewResourceType(tossGC))) + { + free(prect); return; + } screenContext[i] = CreateGC((DrawablePtr)pWin, (BITS32) 0, (XID *)NULL, &status); if (!screenContext[i]) -- cgit v1.2.3 From 56dcc8a4b6a9ed3b7f55e0eeaeff9bc14737cdd5 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 10:10:21 +0200 Subject: xkb: remove oldState from XkbHandleActions. Fixes this cppcheck finding: [nx-X11/programs/Xserver/xkb/xkbActions.c:1306]: (error) Uninitialized variable: oldState commit 35a4b8e7f4526a92d44cb16a783f21030cd1f6df Author: Peter Hutterer Date: Tue May 5 16:51:59 2009 +1000 xkb: remove oldState from XkbHandleActions. I really don't know what the purpose of this variable is or was, aside from potentially clobbering up our key state since there's a path where it may be used uninitialised. Also, this means that xkbi->prev_state is now accessible from the DIX with meaningful data. Signed-off-by: Peter Hutterer --- nx-X11/programs/Xserver/xkb/xkbActions.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/xkbActions.c b/nx-X11/programs/Xserver/xkb/xkbActions.c index d2dda00f4..90bad93e0 100644 --- a/nx-X11/programs/Xserver/xkb/xkbActions.c +++ b/nx-X11/programs/Xserver/xkb/xkbActions.c @@ -1142,7 +1142,6 @@ XkbSrvInfoPtr xkbi; KeyClassPtr keyc; int changed,sendEvent; Bool genStateNotify; -XkbStateRec oldState; XkbAction act; XkbFilterPtr filter; Bool keyEvent; @@ -1157,7 +1156,7 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); xkbi= keyc->xkbInfo; key= xE->u.u.detail; if ((xkbi->flags&_XkbStateNotifyInProgress)==0) { - oldState= xkbi->state; + xkbi->prev_state = xkbi->state; xkbi->flags|= _XkbStateNotifyInProgress; genStateNotify= True; } @@ -1303,11 +1302,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); else if (keyEvent) FixKeyState(xE,dev); - xkbi->prev_state= oldState; XkbComputeDerivedState(xkbi); keyc->prev_state= keyc->state; keyc->state= XkbStateFieldFromRec(&xkbi->state); - changed = XkbStateChangedFlags(&oldState,&xkbi->state); + changed = XkbStateChangedFlags(&xkbi->prev_state,&xkbi->state); if (genStateNotify) { if (changed) { xkbStateNotify sn; -- cgit v1.2.3 From 4962c5a8dee7bc2b903b9aafa27f4d0fd3c1d177 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 10:41:36 +0200 Subject: XKB: Remove a bunch of mad ifdefs commit 534fc5140b039a8c98ab715d0a6740d513b41209 Author: Daniel Stone Date: Sun Feb 3 23:30:22 2008 +1100 XKB: Remove a bunch of mad ifdefs We have SEEK_SET and size_t, seriously. Also use DebugF instead of ifdef DEBUG, and ditch a couple of random bits that were never used. --- nx-X11/programs/Xserver/xkb/XKBGAlloc.c | 8 +-- nx-X11/programs/Xserver/xkb/XKBMAlloc.c | 4 +- nx-X11/programs/Xserver/xkb/XKBMisc.c | 5 +- nx-X11/programs/Xserver/xkb/ddxBeep.c | 4 -- nx-X11/programs/Xserver/xkb/ddxCtrls.c | 23 --------- nx-X11/programs/Xserver/xkb/ddxList.c | 13 +---- nx-X11/programs/Xserver/xkb/ddxLoad.c | 80 +++++------------------------ nx-X11/programs/Xserver/xkb/maprules.c | 86 ++++++++++++-------------------- nx-X11/programs/Xserver/xkb/xkb.c | 2 - nx-X11/programs/Xserver/xkb/xkbAccessX.c | 8 +-- nx-X11/programs/Xserver/xkb/xkbEvents.c | 30 ++++------- nx-X11/programs/Xserver/xkb/xkbInit.c | 17 +------ nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c | 4 +- nx-X11/programs/Xserver/xkb/xkbUtils.c | 10 ---- nx-X11/programs/Xserver/xkb/xkmread.c | 16 +----- 15 files changed, 67 insertions(+), 243 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/XKBGAlloc.c b/nx-X11/programs/Xserver/xkb/XKBGAlloc.c index b5a7cc317..ac757232e 100644 --- a/nx-X11/programs/Xserver/xkb/XKBGAlloc.c +++ b/nx-X11/programs/Xserver/xkb/XKBGAlloc.c @@ -37,12 +37,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "xkbgeom.h" -#ifdef X_NOT_POSIX -#define Size_t unsigned int -#else -#define Size_t size_t -#endif - /***====================================================================***/ static void @@ -463,7 +457,7 @@ _XkbGeomAlloc( XPointer * old, unsigned short * num, unsigned short * total, int num_new, - Size_t sz_elem) + size_t sz_elem) { if (num_new<1) return Success; diff --git a/nx-X11/programs/Xserver/xkb/XKBMAlloc.c b/nx-X11/programs/Xserver/xkb/XKBMAlloc.c index 178d4153c..e3d9c9495 100644 --- a/nx-X11/programs/Xserver/xkb/XKBMAlloc.c +++ b/nx-X11/programs/Xserver/xkb/XKBMAlloc.c @@ -52,10 +52,8 @@ XkbClientMapPtr map; ((!XkbIsLegalKeycode(xkb->min_key_code))|| (!XkbIsLegalKeycode(xkb->max_key_code))|| (xkb->max_key_codemin_key_code))) { -#ifdef DEBUG -fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n", + DebugF("bad keycode (%d,%d) in XkbAllocClientMap\n", xkb->min_key_code,xkb->max_key_code); -#endif return BadValue; } diff --git a/nx-X11/programs/Xserver/xkb/XKBMisc.c b/nx-X11/programs/Xserver/xkb/XKBMisc.c index 2c5cf42c7..0c533773d 100644 --- a/nx-X11/programs/Xserver/xkb/XKBMisc.c +++ b/nx-X11/programs/Xserver/xkb/XKBMisc.c @@ -413,10 +413,7 @@ unsigned changed,tmp; if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) { CARD8 old; old= xkb->ctrls->per_key_repeat[key/8]; -#ifdef RETURN_SHOULD_REPEAT - if (*XkbKeySymsPtr(xkb,key) != XK_Return) -#endif - xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8)); + xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8)); if (changes && (old!=xkb->ctrls->per_key_repeat[key/8])) changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask; } diff --git a/nx-X11/programs/Xserver/xkb/ddxBeep.c b/nx-X11/programs/Xserver/xkb/ddxBeep.c index 9f55ff3b8..cf5570b58 100644 --- a/nx-X11/programs/Xserver/xkb/ddxBeep.c +++ b/nx-X11/programs/Xserver/xkb/ddxBeep.c @@ -142,10 +142,6 @@ Atom name; next= 0; pitch= oldPitch= ctrl->bell_pitch; duration= oldDuration= ctrl->bell_duration; -#ifdef DEBUG - if (xkbDebugFlags>1) - ErrorF("beep: %d (count= %d)\n",xkbInfo->beepType,xkbInfo->beepCount); -#endif name= None; switch (xkbInfo->beepType) { default: diff --git a/nx-X11/programs/Xserver/xkb/ddxCtrls.c b/nx-X11/programs/Xserver/xkb/ddxCtrls.c index 783576a5a..33ae7d2d0 100644 --- a/nx-X11/programs/Xserver/xkb/ddxCtrls.c +++ b/nx-X11/programs/Xserver/xkb/ddxCtrls.c @@ -46,12 +46,6 @@ int realRepeat; realRepeat= ctrl->autoRepeat; if ((dev->kbdfeed)&&(XkbDDXUsesSoftRepeat(dev))) ctrl->autoRepeat= 0; -#ifdef DEBUG -if (xkbDebugFlags&0x4) { - ErrorF("XkbDDXKeybdCtrlProc: setting repeat to %d (real repeat is %d)\n", - ctrl->autoRepeat,realRepeat); -} -#endif if (dev->key && dev->key->xkbInfo && dev->key->xkbInfo->kbdProc) (*dev->key->xkbInfo->kbdProc)(dev,ctrl); ctrl->autoRepeat= realRepeat; @@ -92,23 +86,6 @@ unsigned changed, i; unsigned char *rep_old, *rep_new, *rep_fb; changed= new->enabled_ctrls^old->enabled_ctrls; -#ifdef NOTDEF - if (changed&XkbRepeatKeysMask) { - if (dev->kbdfeed) { - int realRepeat; - - if (new->enabled_ctrls&XkbRepeatKeysMask) - dev->kbdfeed->ctrl.autoRepeat= realRepeat= 1; - else dev->kbdfeed->ctrl.autoRepeat= realRepeat= 0; - - if (XkbDDXUsesSoftRepeat(dev)) - dev->kbdfeed->ctrl.autoRepeat= FALSE; - if (dev->kbdfeed->CtrlProc) - (*dev->kbdfeed->CtrlProc)(dev,&dev->kbdfeed->ctrl); - dev->kbdfeed->ctrl.autoRepeat= realRepeat; - } - } -#endif for (rep_old = old->per_key_repeat, rep_new = new->per_key_repeat, rep_fb = dev->kbdfeed->ctrl.autoRepeats, diff --git a/nx-X11/programs/Xserver/xkb/ddxList.c b/nx-X11/programs/Xserver/xkb/ddxList.c index cc95c8603..449828a59 100644 --- a/nx-X11/programs/Xserver/xkb/ddxList.c +++ b/nx-X11/programs/Xserver/xkb/ddxList.c @@ -41,14 +41,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif -#endif - #ifdef WIN32 /* from ddxLoad.c */ extern const char* Win32TempDir(); @@ -210,9 +202,8 @@ char tmpname[PATH_MAX]; #ifndef WIN32 in= Popen(buf,"r"); #else -#ifdef DEBUG_CMD - ErrorF("xkb executes: %s\n",buf); -#endif + if (xkbDebugFlags) + DebugF("xkb executes: %s\n",buf); if (System(buf) < 0) ErrorF("Could not invoke keymap compiler\n"); else diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index b770ba026..306a3530f 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -55,14 +55,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #if defined(CSRG_BASED) || defined(linux) || defined(__GNU__) #include -#endif - -#ifndef PATH_MAX -#ifdef MAXPATHLEN -#define PATH_MAX MAXPATHLEN -#else -#define PATH_MAX 1024 -#endif #endif /* @@ -166,44 +158,19 @@ Win32System(const char *cmdline) #define System(x) Win32System(x) #endif -#ifdef MAKE_XKM_OUTPUT_DIR -/* Borrow trans_mkdir from Xtransutil.c to more safely make directories */ -# undef X11_t -# define TRANS_SERVER -# define PRMSG(lvl,x,a,b,c) \ - if (lvl <= 1) { LogMessage(X_ERROR,x,a,b,c); } else ((void)0) -# include -# ifndef XKM_OUTPUT_DIR_MODE -# define XKM_OUTPUT_DIR_MODE 0755 -# endif -#endif - static void OutputDirectory( char* outdir, size_t size) { #ifndef WIN32 - if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size) -#ifdef MAKE_XKM_OUTPUT_DIR - && (trans_mkdir(XKM_OUTPUT_DIR, XKM_OUTPUT_DIR_MODE) == 0) -#endif - ) + if (getuid() == 0 && (strlen(XKM_OUTPUT_DIR) < size)) { /* if server running as root it *may* be able to write */ /* FIXME: check whether directory is writable at all */ (void) strcpy (outdir, XKM_OUTPUT_DIR); } else -#endif -#ifdef _PATH_VARTMP - if ((strlen(_PATH_VARTMP) + 1) < size) - { - (void) strcpy (outdir, _PATH_VARTMP); - if (outdir[strlen(outdir) - 1] != '/') /* Hi IBM, Digital */ - (void) strcat (outdir, "/"); - } else -#endif -#ifdef WIN32 +#else if (strlen(Win32TempDir()) + 1 < size) { (void) strcpy(outdir, Win32TempDir()); @@ -264,15 +231,10 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; xkm_output_dir,outFile) == -1) cmd = NULL; } -#ifdef DEBUG if (xkbDebugFlags) { - ErrorF("XkbDDXCompileNamedKeymap compiling keymap using:\n"); - ErrorF(" \"cmd\"\n"); + DebugF("XkbDDXCompileNamedKeymap compiling keymap using:\n"); + DebugF(" \"cmd\"\n"); } -#endif -#ifdef DEBUG_CMD - ErrorF("xkb executes: %s\n",cmd); -#endif if (System(cmd)==0) { if (nameRtrn) { strncpy(nameRtrn,outFile,nameRtrnLen); @@ -284,9 +246,7 @@ char *cmd = NULL,file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile; free(cmd); return True; } -#ifdef DEBUG - ErrorF("Error compiling keymap (%s)\n",names->keymap); -#endif + DebugF("Error compiling keymap (%s)\n",names->keymap); if (outFile!=NULL) _XkbFree(outFile); if (cmd!=NULL) @@ -399,12 +359,8 @@ char tmpname[PATH_MAX]; if (fclose(out)==0 && System(buf) >= 0) #endif { -#ifdef DEBUG_CMD - ErrorF("xkb executes: %s\n",buf); - ErrorF("xkbcomp input:\n"); - XkbWriteXKBKeymapForNames(stderr,names,NULL,xkb,want,need); - ErrorF("end xkbcomp input\n"); -#endif + if (xkbDebugFlags) + DebugF("xkb executes: %s\n",buf); if (nameRtrn) { strncpy(nameRtrn,keymap,nameRtrnLen); nameRtrn[nameRtrnLen-1]= '\0'; @@ -413,24 +369,20 @@ char tmpname[PATH_MAX]; free (buf); return True; } -#ifdef DEBUG else - ErrorF("Error compiling keymap (%s)\n",keymap); -#endif + DebugF("Error compiling keymap (%s)\n",keymap); #ifdef WIN32 /* remove the temporary file */ unlink(tmpname); #endif } -#ifdef DEBUG else { #ifndef WIN32 - ErrorF("Could not invoke keymap compiler\n"); + DebugF("Could not invoke keymap compiler\n"); #else - ErrorF("Could not open file %s\n", tmpname); + DebugF("Could not open file %s\n", tmpname); #endif } -#endif if (nameRtrn) nameRtrn[0]= '\0'; if (buf != NULL) @@ -505,17 +457,13 @@ unsigned missing; return 0; } else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) { -#ifdef NOISY - ErrorF("Couldn't compile keymap file\n"); -#endif + DebugF("Couldn't compile keymap file\n"); return 0; } } else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need, nameRtrn,nameRtrnLen)){ -#ifdef NOISY - ErrorF("Couldn't compile keymap file\n"); -#endif + DebugF("Couldn't compile keymap file\n"); return 0; } file= XkbDDXOpenConfigFile(nameRtrn,fileName,PATH_MAX); @@ -530,11 +478,9 @@ unsigned missing; (void) unlink (fileName); return 0; } -#ifdef DEBUG else if (xkbDebugFlags) { - ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); + DebugF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); } -#endif fclose(file); (void) unlink (fileName); return (need|want)&(~missing); diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index 295f1acf6..af6c112fe 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -48,16 +48,6 @@ #include "xkbstr.h" #include -#ifdef DEBUG -#define PR_DEBUG(s) fprintf(stderr,s) -#define PR_DEBUG1(s,a) fprintf(stderr,s,a) -#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b) -#else -#define PR_DEBUG(s) -#define PR_DEBUG1(s,a) -#define PR_DEBUG2(s,a,b) -#endif - /***====================================================================***/ #define DFLT_LINE_SIZE 128 @@ -169,8 +159,8 @@ Bool endOfFile,spacePending,slashPending,inComment; } if (checkbang && ch=='!') { if (line->num_line!=0) { - PR_DEBUG("The '!' legal only at start of line\n"); - PR_DEBUG("Line containing '!' ignored\n"); + DebugF("The '!' legal only at start of line\n"); + DebugF("Line containing '!' ignored\n"); line->num_line= 0; inComment= 0; break; @@ -271,9 +261,7 @@ unsigned present, l_ndx_present, v_ndx_present; register int i; int len, ndx; _Xstrtokparams strtok_buf; -#ifdef DEBUG Bool found; -#endif l_ndx_present = v_ndx_present = present= 0; @@ -282,9 +270,7 @@ Bool found; bzero((char *)remap,sizeof(RemapSpec)); remap->number = len; while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) { -#ifdef DEBUG found= False; -#endif str= NULL; if (strcmp(tok,"=")==0) continue; @@ -297,22 +283,20 @@ Bool found; *end != '\0' || ndx == -1) break; if (ndx < 1 || ndx > XkbNumKbdGroups) { - PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx); - PR_DEBUG1("Index must be in range 1..%d\n", + DebugF("Illegal %s index: %d\n", cname[i], ndx); + DebugF("Index must be in range 1..%d\n", XkbNumKbdGroups); break; } } else { ndx = 0; } -#ifdef DEBUG found= True; -#endif if (present&(1<num_remap= 0; return; } if ((present&COMPONENT_MASK)==0) { - PR_DEBUG("Mapping needs at least one component\n"); - PR_DEBUG("Illegal mapping ignored\n"); + DebugF("Mapping needs at least one component\n"); + DebugF("Illegal mapping ignored\n"); remap->num_remap= 0; return; } if (((present&COMPONENT_MASK)&(1<num_remap= 0; return; } @@ -432,8 +412,8 @@ Bool append = False; } if (remap->num_remap==0) { - PR_DEBUG("Must have a mapping before first line of data\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("Must have a mapping before first line of data\n"); + DebugF("Illegal line of data ignored\n"); return False; } bzero((char *)&tmp,sizeof(FileSpec)); @@ -445,8 +425,8 @@ Bool append = False; continue; } if (nread>remap->num_remap) { - PR_DEBUG("Too many words on a line\n"); - PR_DEBUG1("Extra word \"%s\" ignored\n",tok); + DebugF("Too many words on a line\n"); + DebugF("Extra word \"%s\" ignored\n",tok); continue; } tmp.name[remap->remap[nread].word]= tok; @@ -454,8 +434,8 @@ Bool append = False; append = True; } if (nreadnum_remap) { - PR_DEBUG1("Too few words on a line: %s\n", line->line); - PR_DEBUG("line ignored\n"); + DebugF("Too few words on a line: %s\n", line->line); + DebugF("line ignored\n"); return False; } @@ -901,9 +881,7 @@ XkbRF_AddRule(XkbRF_RulesPtr rules) } if (!rules->rules) { rules->sz_rules= rules->num_rules= 0; -#ifdef DEBUG - fprintf(stderr,"Allocation failure in XkbRF_AddRule\n"); -#endif + DebugF("Allocation failure in XkbRF_AddRule\n"); return NULL; } bzero((char *)&rules->rules[rules->num_rules],sizeof(XkbRF_RuleRec)); @@ -1020,7 +998,7 @@ XkbRF_AddVarDesc(XkbRF_DescribeVarsPtr vars) } if (!vars->desc) { vars->sz_desc= vars->num_desc= 0; - PR_DEBUG("Allocation failure in XkbRF_AddVarDesc\n"); + DebugF("Allocation failure in XkbRF_AddVarDesc\n"); return NULL; } vars->desc[vars->num_desc].name= NULL; @@ -1057,7 +1035,7 @@ XkbRF_AddVarToDescribe(XkbRF_RulesPtr rules,char *name) XkbRF_DescribeVarsRec); } if ((!rules->extra_names)||(!rules->extra)) { - PR_DEBUG("allocation error in extra parts\n"); + DebugF("allocation error in extra parts\n"); rules->sz_extra= rules->num_extra= 0; rules->extra_names= NULL; rules->extra= NULL; @@ -1100,7 +1078,7 @@ int len,headingtype,extra_ndx = 0; } if (extra_ndx<0) { XkbRF_DescribeVarsPtr var; - PR_DEBUG1("Extra heading \"%s\" encountered\n",tok); + DebugF("Extra heading \"%s\" encountered\n",tok); var= XkbRF_AddVarToDescribe(rules,tok); if (var) extra_ndx= var-rules->extra; @@ -1111,20 +1089,20 @@ int len,headingtype,extra_ndx = 0; } if (headingtype == HEAD_NONE) { - PR_DEBUG("Must have a heading before first line of data\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("Must have a heading before first line of data\n"); + DebugF("Illegal line of data ignored\n"); continue; } len = strlen(line.line); if ((tmp.name= strtok(line.line, " \t")) == NULL) { - PR_DEBUG("Huh? No token on line\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("Huh? No token on line\n"); + DebugF("Illegal line of data ignored\n"); continue; } if (strlen(tmp.name) == len) { - PR_DEBUG("No description found\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("No description found\n"); + DebugF("Illegal line of data ignored\n"); continue; } @@ -1132,8 +1110,8 @@ int len,headingtype,extra_ndx = 0; while ((*tok!='\n')&&isspace(*tok)) tok++; if (*tok == '\0') { - PR_DEBUG("No description found\n"); - PR_DEBUG("Illegal line of data ignored\n"); + DebugF("No description found\n"); + DebugF("Illegal line of data ignored\n"); continue; } tmp.desc= tok; diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 8d3fc6108..e6521c952 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -5677,10 +5677,8 @@ char * str; return status; } else if (length!=0) { -#ifdef DEBUG ErrorF("Internal Error! BadLength in ProcXkbGetDeviceInfo\n"); ErrorF(" Wrote %d fewer bytes than expected\n",length); -#endif return BadLength; } if (stuff->wanted&(~supported)) { diff --git a/nx-X11/programs/Xserver/xkb/xkbAccessX.c b/nx-X11/programs/Xserver/xkb/xkbAccessX.c index 5d9917d2b..3eafaa5b7 100644 --- a/nx-X11/programs/Xserver/xkb/xkbAccessX.c +++ b/nx-X11/programs/Xserver/xkb/xkbAccessX.c @@ -126,11 +126,9 @@ xEvent xE; xE.u.u.type = type; xE.u.u.detail = keyCode; xE.u.keyButtonPointer.time = GetTimeInMillis(); -#ifdef DEBUG if (xkbDebugFlags&0x8) { - ErrorF("AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up")); + DebugF("AXKE: Key %d %s\n",keyCode,(xE.u.u.type==KeyPress?"down":"up")); } -#endif if (!_XkbIsPressEvent(type) && isRepeat) XkbLastRepeatEvent= (void *)&xE; @@ -524,10 +522,8 @@ KeySym * sym = XkbKeySymsPtr(xkbi->desc,key); XkbRepeatKeysMask)) { if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) { -#ifdef DEBUG if (xkbDebugFlags&0x10) - ErrorF("Starting software autorepeat...\n"); -#endif + DebugF("Starting software autorepeat...\n"); xkbi->repeatKey = key; xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer, 0, ctrls->repeat_delay, diff --git a/nx-X11/programs/Xserver/xkb/xkbEvents.c b/nx-X11/programs/Xserver/xkb/xkbEvents.c index c7a0f9e87..6e8df3490 100644 --- a/nx-X11/programs/Xserver/xkb/xkbEvents.c +++ b/nx-X11/programs/Xserver/xkb/xkbEvents.c @@ -804,21 +804,19 @@ XkbSrvInfoPtr xkbi; xkbi= pXDev->key->xkbInfo; if ( pClient->xkbClientFlags & _XkbClientInitialized ) { -#ifdef DEBUG if ((xkbDebugFlags&0x10)&& ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { - ErrorF("XKbFilterWriteEvents:\n"); - ErrorF(" Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state); - ErrorF(" XkbLastRepeatEvent!=xE (0x%x!=0x%x) %s\n", + DebugF("XKbFilterWriteEvents:\n"); + DebugF(" Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state); + DebugF(" XkbLastRepeatEvent!=xE (0x%x!=0x%x) %s\n", XkbLastRepeatEvent,xE, ((XkbLastRepeatEvent!=(void *)xE)?"True":"False")); - ErrorF(" (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n", + DebugF(" (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n", pClient->xkbClientFlags, (_XkbWantsDetectableAutoRepeat(pClient)?"True":"False")); - ErrorF(" !IsRelease(%d) %s\n",xE[0].u.u.type, + DebugF(" !IsRelease(%d) %s\n",xE[0].u.u.type, (!_XkbIsReleaseEvent(xE[0].u.u.type))?"True":"False"); } -#endif /* DEBUG */ if ( (XkbLastRepeatEvent==(void *)xE) && (_XkbWantsDetectableAutoRepeat(pClient)) && (_XkbIsReleaseEvent(xE[0].u.u.type)) ) { @@ -853,13 +851,11 @@ XkbSrvInfoPtr xkbi; if (xE[0].u.u.type == ButtonPress && ((xE[0].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && (xkbi->lockedPtrButtons & button_mask) == button_mask) { -#ifdef DEBUG /* If the MouseKeys is pressed, and the "real" mouse is also pressed * when the mouse is released, the server does not behave properly. * Faking a release of the button here solves the problem. */ - ErrorF("Faking release of button %d\n", xE[0].u.u.detail); -#endif + DebugF("Faking release of button %d\n", xE[0].u.u.detail); XkbDDXFakePointerButton(ButtonRelease, xE[0].u.u.detail); } } @@ -868,19 +864,17 @@ XkbSrvInfoPtr xkbi; for (i=0;istate; - ErrorF("XKbFilterWriteEvents (non-XKB):\n"); - ErrorF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state); - ErrorF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods, + DebugF("XKbFilterWriteEvents (non-XKB):\n"); + DebugF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state); + DebugF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods, s->grab_mods); - ErrorF("compat lookup= 0x%02x, grab= 0x%02x\n", + DebugF("compat lookup= 0x%02x, grab= 0x%02x\n", s->compat_lookup_mods, s->compat_grab_mods); } -#endif if ( (type>=KeyPress)&&(type<=MotionNotify) ) { CARD16 old,new; @@ -900,9 +894,7 @@ XkbSrvInfoPtr xkbi; if (type == ButtonPress && ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask && (xkbi->lockedPtrButtons & button_mask) == button_mask) { -#ifdef DEBUG - ErrorF("Faking release of button %d\n", xE[i].u.u.detail); -#endif + DebugF("Faking release of button %d\n", xE[i].u.u.detail); XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail); } } diff --git a/nx-X11/programs/Xserver/xkb/xkbInit.c b/nx-X11/programs/Xserver/xkb/xkbInit.c index 2f7fa475d..f37e202d8 100644 --- a/nx-X11/programs/Xserver/xkb/xkbInit.c +++ b/nx-X11/programs/Xserver/xkb/xkbInit.c @@ -284,10 +284,6 @@ XkbSetRulesDflts(char *rulesFile,char *model,char *layout, /***====================================================================***/ -#if defined(luna) -#define XKB_DDX_PERMANENT_LOCK 1 -#endif - #include "xkbDflts.h" static Bool @@ -394,15 +390,6 @@ Atom unknown; names->indicators[LED_COMPOSE-1] = CREATE_ATOM("Compose"); #endif } -#ifdef DEBUG_RADIO_GROUPS - if (names->num_rg<1) { - names->radio_groups= (Atom *)_XkbCalloc(RG_COUNT, sizeof(Atom)); - if (names->radio_groups) { - names->num_rg = RG_COUNT; - names->radio_groups[RG_BOGUS_FUNCTION_GROUP]= CREATE_ATOM("BOGUS"); - } - } -#endif if (xkb->geom!=NULL) names->geometry= xkb->geom->name; else names->geometry= unknown; @@ -773,9 +760,7 @@ XkbSrvLedInfoPtr sli; sli= XkbFindSrvLedInfo(pXDev,XkbDfltXIClass,XkbDfltXIId,0); if (sli && xkbi) XkbCheckIndicatorMaps(xkbi->device,sli,XkbAllIndicatorsMask); -#ifdef DEBUG - else ErrorF("No indicator feedback in XkbFinishInit (shouldn't happen)!\n"); -#endif + else DebugF("No indicator feedback in XkbFinishInit (shouldn't happen)!\n"); return softRepeat; } diff --git a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c index ede23556e..253b4654e 100644 --- a/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c +++ b/nx-X11/programs/Xserver/xkb/xkbPrKeyEv.c @@ -52,11 +52,9 @@ unsigned ndx; xkbi= keyc->xkbInfo; key= xE->u.u.detail; -#ifdef DEBUG if (xkbDebugFlags&0x8) { - ErrorF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); + DebugF("XkbPKE: Key %d %s\n",key,(xE->u.u.type==KeyPress?"down":"up")); } -#endif if ( (xkbi->repeatKey==key) && (xE->u.u.type==KeyRelease) && ((xkbi->desc->ctrls->enabled_ctrls&XkbRepeatKeysMask)==0) ) { diff --git a/nx-X11/programs/Xserver/xkb/xkbUtils.c b/nx-X11/programs/Xserver/xkb/xkbUtils.c index a545f06eb..941bb4038 100644 --- a/nx-X11/programs/Xserver/xkb/xkbUtils.c +++ b/nx-X11/programs/Xserver/xkb/xkbUtils.c @@ -191,16 +191,6 @@ KeySym tsyms[XkbMaxSymsPerKey] = {NoSymbol},*syms; XkbMapChangesPtr mc; xkb= pXDev->key->xkbInfo->desc; -#ifdef NOTYET - if (firstmin_key_code) { - if (first>=XkbMinLegalKeyCode) { - xkb->min_key_code= first; - /* 1/12/95 (ef) -- XXX! should zero out the new maps */ - changes->map.changed|= XkbKeycodesMask; -generate a NewKeyboard notify here? - } - } -#endif if (first+num-1>xkb->max_key_code) { /* 1/12/95 (ef) -- XXX! should allow XKB structures to grow */ num= xkb->max_key_code-first+1; diff --git a/nx-X11/programs/Xserver/xkb/xkmread.c b/nx-X11/programs/Xserver/xkb/xkmread.c index 4871f3a35..c8b2a4591 100644 --- a/nx-X11/programs/Xserver/xkb/xkmread.c +++ b/nx-X11/programs/Xserver/xkb/xkmread.c @@ -50,10 +50,6 @@ XkbInternAtom(Display *dpy,char *str,Bool only_if_exists) return MakeAtom(str,strlen(str),!only_if_exists); } -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - /***====================================================================***/ static XPointer @@ -547,10 +543,8 @@ FindTypeForKey(XkbDescPtr xkb,Atom name,unsigned width,KeySym *syms) register unsigned i; for (i=0;imap->num_types;i++) { if (xkb->map->types[i].name==name) { -#ifdef DEBUG if (xkb->map->types[i].num_levels!=width) - fprintf(stderr,"Group width mismatch between key and type\n"); -#endif + DebugF("Group width mismatch between key and type\n"); return &xkb->map->types[i]; } } @@ -1072,10 +1066,8 @@ unsigned i,size_toc; ignored_result = fread(file_info,SIZEOF(xkmFileInfo),1,file); size_toc= file_info->num_toc; if (size_toc>max_toc) { -#ifdef DEBUG - fprintf(stderr,"Warning! Too many TOC entries; last %d ignored\n", + DebugF("Warning! Too many TOC entries; last %d ignored\n", size_toc-max_toc); -#endif size_toc= max_toc; } for (i=0;ixkb==NULL) result->xkb= XkbAllocKeyboard(); for (i=0;i Date: Fri, 21 Jun 2019 10:45:57 +0200 Subject: xkbEvents.c: Fix "warning: unused variable `s'". commit 2391c409a2840d61fed93832650c0d6c82ebebdf Author: Eamon Walsh Date: Fri Jun 13 22:48:17 2008 -0400 Fix "warning: unused variable `s'". --- nx-X11/programs/Xserver/xkb/xkbEvents.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/xkbEvents.c b/nx-X11/programs/Xserver/xkb/xkbEvents.c index 6e8df3490..791673753 100644 --- a/nx-X11/programs/Xserver/xkb/xkbEvents.c +++ b/nx-X11/programs/Xserver/xkb/xkbEvents.c @@ -866,14 +866,13 @@ XkbSrvInfoPtr xkbi; type= xE[i].u.u.type; if ((xkbDebugFlags&0x4)&& ((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) { - XkbStatePtr s= &xkbi->state; DebugF("XKbFilterWriteEvents (non-XKB):\n"); DebugF("event= 0x%04x\n",xE[0].u.keyButtonPointer.state); - DebugF("lookup= 0x%02x, grab= 0x%02x\n",s->lookup_mods, - s->grab_mods); + DebugF("lookup= 0x%02x, grab= 0x%02x\n",xkbi->state.lookup_mods, + xkbi->state.grab_mods); DebugF("compat lookup= 0x%02x, grab= 0x%02x\n", - s->compat_lookup_mods, - s->compat_grab_mods); + xkbi->state.compat_lookup_mods, + xkbi->state.compat_grab_mods); } if ( (type>=KeyPress)&&(type<=MotionNotify) ) { CARD16 old,new; -- cgit v1.2.3 From 054e906f6059366150bb7426973542203c8a0e4c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 10:57:09 +0200 Subject: xkb: Use snprintf to measure string lengths instead of manual strlen math commit a4a2e814d5d0e6152307a301eda1d6fc1c555aaa Author: Alan Coopersmith Date: Sun Feb 13 21:36:02 2011 -0800 xkb: Use snprintf to measure string lengths instead of manual strlen math Signed-off-by: Alan Coopersmith Signed-off-by: Peter Hutterer Reviewed-by: Daniel Stone --- nx-X11/programs/Xserver/xkb/ddxLoad.c | 21 +++++++++++---------- nx-X11/programs/Xserver/xkb/maprules.c | 3 +-- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/ddxLoad.c b/nx-X11/programs/Xserver/xkb/ddxLoad.c index 306a3530f..bff69196f 100644 --- a/nx-X11/programs/Xserver/xkb/ddxLoad.c +++ b/nx-X11/programs/Xserver/xkb/ddxLoad.c @@ -404,15 +404,16 @@ FILE * file; &&(!isalpha(xkm_output_dir[0]) || xkm_output_dir[1]!=':') #endif ) { - if (strlen(XkbBaseDirectory)+strlen(xkm_output_dir) - +strlen(mapName)+6 <= PATH_MAX) - { - sprintf(buf,"%s/%s%s.xkm",XkbBaseDirectory, - xkm_output_dir,mapName); - } + if (snprintf(buf, PATH_MAX, "%s/%s%s.xkm", XkbBaseDirectory, + xkm_output_dir, mapName) >= PATH_MAX) + buf[0] = '\0'; + } + else + { + if (snprintf(buf, PATH_MAX, "%s%s.xkm", xkm_output_dir, mapName) + >= PATH_MAX) + buf[0] = '\0'; } - else if (strlen(xkm_output_dir)+strlen(mapName)+5 <= PATH_MAX) - sprintf(buf,"%s%s.xkm",xkm_output_dir,mapName); if (buf[0] != '\0') file= fopen(buf,"rb"); else file= NULL; @@ -505,9 +506,9 @@ XkbRF_RulesPtr rules; sprintf(buf,"rules/%s",rules_name); } else { - if (strlen(XkbBaseDirectory)+strlen(rules_name)+8 > PATH_MAX) + if (snprintf(buf, PATH_MAX, "%s/rules/%s", XkbBaseDirectory, rules_name) + >= PATH_MAX) return False; - sprintf(buf,"%s/rules/%s",XkbBaseDirectory,rules_name); } if ((file= fopen(buf,"r"))==NULL) return False; diff --git a/nx-X11/programs/Xserver/xkb/maprules.c b/nx-X11/programs/Xserver/xkb/maprules.c index af6c112fe..6bc7e4022 100644 --- a/nx-X11/programs/Xserver/xkb/maprules.c +++ b/nx-X11/programs/Xserver/xkb/maprules.c @@ -953,9 +953,8 @@ Bool ok; if ((!base)||(!rules)) return False; if (locale) { - if (strlen(base)+strlen(locale)+2 > PATH_MAX) + if (snprintf(buf, PATH_MAX, "%s-%s", base, locale) >= PATH_MAX) return False; - sprintf(buf,"%s-%s", base, locale); } else { if (strlen(base)+1 > PATH_MAX) -- cgit v1.2.3 From 813acdd2df24a8e3f44152d90a26f1beef11b38c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 11:01:59 +0200 Subject: xkb: Silence some compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 83913de25d35709b3ab7b0ab124b73924145d2dd Author: Adam Jackson Date: Thu Apr 5 12:59:11 2018 -0400 xkb: Silence some compiler warnings Of the form: ../xkb/XKBGAlloc.c: In function ‘SrvXkbAddGeomKeyAlias’: ../xkb/XKBGAlloc.c:591:13: warning: ‘strncpy’ specified bound 4 equals destination size [-Wstringop-truncation] strncpy(alias->real, realStr, XkbKeyNameLength); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is intentional; the code that reads from these fields never reads more than 4 bytes anyway. Rephrase things in terms of memcpy so that's clear. Obviously this is awful but in XKB awful is par. Signed-off-by: Adam Jackson Acked-by: Keith Packard --- nx-X11/programs/Xserver/xkb/XKBGAlloc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/XKBGAlloc.c b/nx-X11/programs/Xserver/xkb/XKBGAlloc.c index ac757232e..bfbd0c325 100644 --- a/nx-X11/programs/Xserver/xkb/XKBGAlloc.c +++ b/nx-X11/programs/Xserver/xkb/XKBGAlloc.c @@ -702,7 +702,8 @@ register XkbKeyAliasPtr alias; for (i=0,alias=geom->key_aliases;inum_key_aliases;i++,alias++) { if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) { bzero(alias->real,XkbKeyNameLength); - strncpy(alias->real,realStr,XkbKeyNameLength); + memcpy(alias->real, realStr, + min(XkbKeyNameLength, strlen(realStr))); return alias; } } @@ -712,8 +713,8 @@ register XkbKeyAliasPtr alias; } alias= &geom->key_aliases[geom->num_key_aliases]; bzero(alias,sizeof(XkbKeyAliasRec)); - strncpy(alias->alias,aliasStr,XkbKeyNameLength); - strncpy(alias->real,realStr,XkbKeyNameLength); + memcpy(alias->alias, aliasStr, min(XkbKeyNameLength, strlen(aliasStr))); + memcpy(alias->real, realStr, min(XkbKeyNameLength, strlen(realStr))); geom->num_key_aliases++; return alias; } @@ -930,8 +931,8 @@ Bool found; if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success)) return NULL; key= &row->keys[row->num_keys]; - strncpy(key->under.name,under,XkbKeyNameLength); - strncpy(key->over.name,over,XkbKeyNameLength); + memcpy(key->under.name, under, min(XkbKeyNameLength, strlen(under))); + memcpy(key->over.name, over, min(XkbKeyNameLength, strlen(over))); row->num_keys++; return key; } -- cgit v1.2.3 From 31c3d27ea3d2546beb267ed3cc083e040908e246 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 11:13:46 +0200 Subject: xkmread.c: fix compiler warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xkmread.c: In function ‘XkmReadFileSectionName’: xkmread.c:1181:25: warning: ‘tmpTOC.type’ may be used uninitialized in this function [-Wmaybe-uninitialized] XkbConfigText(tmpTOC.type,XkbMessage),0); --- nx-X11/programs/Xserver/xkb/xkmread.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/xkmread.c b/nx-X11/programs/Xserver/xkb/xkmread.c index c8b2a4591..b24c43e03 100644 --- a/nx-X11/programs/Xserver/xkb/xkmread.c +++ b/nx-X11/programs/Xserver/xkb/xkmread.c @@ -1177,8 +1177,12 @@ char name[100]; return Xstrdup(name); break; default: + /* tmpTOC is unitilaoized here, so we use the one from toc for now. _XkbLibError(_XkbErrBadImplementation, XkbConfigText(tmpTOC.type,XkbMessage),0); + */ + _XkbLibError(_XkbErrBadImplementation, + XkbConfigText(toc->type,XkbMessage),0); break; } return NULL; -- cgit v1.2.3 From 5be6d271ba4f4c48d0441cf0ed3d8909a6ffd774 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 11:22:28 +0200 Subject: xkb: fix what looks to be a copy-paste error with first vs firstMM commit 758393951233d1b2520cf4cefd33ec4288a3880a Author: Dave Airlie Date: Wed Sep 12 11:09:40 2018 +1000 xkb: fix what looks to be a copy-paste error with first vs firstMM Pointed out by coverity. Signed-off-by: Dave Airlie --- nx-X11/programs/Xserver/xkb/xkb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index e6521c952..238b0897e 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -2363,7 +2363,7 @@ ProcXkbSetMap(ClientPtr client) else first= last= 0; if (change.map.num_modmap_keys>0) { firstMM= change.map.first_modmap_key; - lastMM= first+change.map.num_modmap_keys-1; + lastMM= firstMM + change.map.num_modmap_keys - 1; } else firstMM= lastMM= 0; if ((last>0) && (lastMM>0)) { -- cgit v1.2.3 From 2bb498a4c767b7d12db84e59b77020bcd70a057c Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 11:38:39 +0200 Subject: Keyboard.c: fix another cppcheck finding [Keyboard.c:559]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 7330784de..8ff4528a1 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -555,8 +555,9 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) for (int i = 1; i <= 32; i++) { + unsigned int mask = (unsigned int)1 << (i - 1); values.led = i; - values.led_mode = (ctrl->leds & (1 << (i - 1))) ? LedModeOn : LedModeOff; + values.led_mode = (ctrl->leds & mask) ? LedModeOn : LedModeOff; XChangeKeyboardControl(nxagentDisplay, value_mask, &values); } -- cgit v1.2.3 From 364035c00258c17924174dac7921b5a8e68e6459 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 11:39:03 +0200 Subject: Keyboard.c: use existing define instead of hardcoced value --- nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 8ff4528a1..4952c0197 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -553,7 +553,7 @@ void nxagentChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) value_mask = KBLed | KBLedMode; - for (int i = 1; i <= 32; i++) + for (int i = 1; i <= XkbNumIndicators; i++) { unsigned int mask = (unsigned int)1 << (i - 1); values.led = i; -- cgit v1.2.3 From b91b3d807d3e049358027d53ec5e4574e16850b3 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Fri, 21 Jun 2019 12:04:23 +0200 Subject: record/set.c: silence cpp finding [nx-X11/programs/Xserver/record/set.c:361]: (warning) Possible null pointer dereference: stackIntervals stackIntervals is only NULL if nIntervals is 0, too. In that case memcpy will do nothing and so it is ok to pass NULL as source. But it is ugly nevertheless... --- nx-X11/programs/Xserver/record/set.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/record/set.c b/nx-X11/programs/Xserver/record/set.c index c3085c54d..3086f9670 100644 --- a/nx-X11/programs/Xserver/record/set.c +++ b/nx-X11/programs/Xserver/record/set.c @@ -357,7 +357,8 @@ IntervalListCreateSet(RecordSetInterval *pIntervals, int nIntervals, if (!prls) goto bailout; prls->baseSet.ops = &IntervalListSetOperations; } - memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval)); + if (nIntervals > 0) + memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval)); prls->nIntervals = nIntervals; bailout: if (stackIntervals) free(stackIntervals); -- cgit v1.2.3