From b02e006b2733ea457df41791f6054309e4edf7f6 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 18:46:00 -0500 Subject: [PATCH 1/9] dmx: warning fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dear gcc: I do not care about machines where sizeof(void *) < sizeof(int), and neither should you. dmxextension.c: In function ‘dmxBECreateResources’: dmxextension.c:858:26: warning: cast from pointer to integer of different size dmxextension.c: In function ‘dmxBERestoreRenderPict’: dmxextension.c:1062:29: warning: cast from pointer to integer of different size dmxextension.c: In function ‘dmxBERestoreRenderGlyph’: dmxextension.c:1084:35: warning: cast from pointer to integer of different size dmxextension.c: In function ‘dmxAttachScreen’: dmxextension.c:1277:8: warning: cast to pointer from integer of different size dmxextension.c:1286:34: warning: cast to pointer from integer of different size dmxextension.c:1292:35: warning: cast to pointer from integer of different size dmxextension.c: In function ‘dmxBEDestroyResources’: dmxextension.c:1456:26: warning: cast from pointer to integer of different size dmxextension.c: In function ‘dmxDetachScreen’: dmxextension.c:1599:8: warning: cast to pointer from integer of different size Reviewed-by: Peter Hutterer Signed-off-by: Adam Jackson --- hw/dmx/dmxextension.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c index 45cb3db93..bd326ce2a 100644 --- a/hw/dmx/dmxextension.c +++ b/hw/dmx/dmxextension.c @@ -855,7 +855,7 @@ static void dmxBERestorePixmap(PixmapPtr pPixmap) static void dmxBECreateResources(pointer value, XID id, RESTYPE type, pointer n) { - int scrnNum = (int)n; + int scrnNum = (uintptr_t)n; ScreenPtr pScreen = screenInfo.screens[scrnNum]; if ((type & TypeMask) == (RT_WINDOW & TypeMask)) { @@ -1059,7 +1059,7 @@ static void dmxBERestoreRenderPict(pointer value, XID id, pointer n) { PicturePtr pPicture = value; /* The picture */ DrawablePtr pDraw = pPicture->pDrawable; /* The picture's drawable */ - int scrnNum = (int)n; + int scrnNum = (uintptr_t)n; if (pDraw->pScreen->myNum != scrnNum) { /* Picture not on the screen we are restoring*/ @@ -1081,7 +1081,7 @@ static void dmxBERestoreRenderPict(pointer value, XID id, pointer n) static void dmxBERestoreRenderGlyph(pointer value, XID id, pointer n) { GlyphSetPtr glyphSet = value; - int scrnNum = (int)n; + int scrnNum = (uintptr_t)n; dmxGlyphPrivPtr glyphPriv = DMX_GET_GLYPH_PRIV(glyphSet); DMXScreenInfo *dmxScreen = &dmxScreens[scrnNum]; GlyphRefPtr table; @@ -1274,7 +1274,7 @@ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr) for (i = currentMaxClients; --i >= 0; ) if (clients[i]) FindAllClientResources(clients[i], dmxBECreateResources, - (pointer)idx); + (pointer)(uintptr_t)idx); /* Create window hierarchy (top down) */ dmxBECreateWindowTree(idx); @@ -1283,13 +1283,15 @@ int dmxAttachScreen(int idx, DMXScreenAttributesPtr attr) for (i = currentMaxClients; --i >= 0; ) if (clients[i]) FindClientResourcesByType(clients[i],PictureType, - dmxBERestoreRenderPict,(pointer)idx); + dmxBERestoreRenderPict, + (pointer)(uintptr_t)idx); /* Restore the glyph state for RENDER */ for (i = currentMaxClients; --i >= 0; ) if (clients[i]) FindClientResourcesByType(clients[i],GlyphSetType, - dmxBERestoreRenderGlyph,(pointer)idx); + dmxBERestoreRenderGlyph, + (pointer)(uintptr_t)idx); /* Refresh screen by generating exposure events for all windows */ dmxForceExposures(idx); @@ -1453,7 +1455,7 @@ static void dmxBESavePixmap(PixmapPtr pPixmap) static void dmxBEDestroyResources(pointer value, XID id, RESTYPE type, pointer n) { - int scrnNum = (int)n; + int scrnNum = (uintptr_t)n; ScreenPtr pScreen = screenInfo.screens[scrnNum]; if ((type & TypeMask) == (RT_WINDOW & TypeMask)) { @@ -1596,7 +1598,7 @@ int dmxDetachScreen(int idx) for (i = currentMaxClients; --i >= 0; ) if (clients[i]) FindAllClientResources(clients[i], dmxBEDestroyResources, - (pointer)idx); + (pointer)(uintptr_t)idx); /* Free scratch GCs */ dmxBEDestroyScratchGCs(idx); From c1fe0b155d0567440228aa5d9e36036f37670e3b Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 18:52:57 -0500 Subject: [PATCH 2/9] dmx: warning fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dmxgc.c: In function ‘dmxChangeClip’: dmxgc.c:386:5: warning: case label value exceeds maximum value for type dmxgc.c:387:5: warning: case label value exceeds maximum value for type dmxgc.c:388:5: warning: case label value exceeds maximum value for type dmxgc.c:389:5: warning: case label value exceeds maximum value for type Reviewed-by: Peter Hutterer Signed-off-by: Adam Jackson --- hw/dmx/dmxgc.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c index 829200e6a..f10f9a074 100644 --- a/hw/dmx/dmxgc.c +++ b/hw/dmx/dmxgc.c @@ -383,12 +383,7 @@ void dmxChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects) break; case CT_PIXMAP: - case CT_UNSORTED: - case CT_YSORTED: - case CT_YXSORTED: - case CT_YXBANDED: - /* These clip types are condensed down to either NONE or REGION - in the mi code */ + /* Condensed down to REGION in the mi code */ break; } From ffd323b7c0212ed9b348e51cd9b36363d7c4d1f2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 18:55:20 -0500 Subject: [PATCH 3/9] dmx: warning fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dmxinputinit.c: At top level: dmxinputinit.c:135:29: warning: ‘DMXCommonOth’ defined but not used DMXCommonOth is actually mentioned in a #if 0 block, so delete it and the block that references it. If anyone needs it, git remembers. Reviewed-by: Peter Hutterer Signed-off-by: Adam Jackson --- hw/dmx/input/dmxinputinit.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c index 7cac86f79..6fc11cd0d 100644 --- a/hw/dmx/input/dmxinputinit.c +++ b/hw/dmx/input/dmxinputinit.c @@ -132,14 +132,6 @@ static DMXLocalInputInfoRec DMXConsoleKbd = { NULL, dmxCommonKbdCtrl, dmxCommonKbdBell }; -static DMXLocalInputInfoRec DMXCommonOth = { - "common-oth", DMX_LOCAL_OTHER, DMX_LOCAL_TYPE_COMMON, 1, - dmxCommonCopyPrivate, NULL, - NULL, NULL, NULL, dmxCommonOthGetInfo, - dmxCommonOthOn, dmxCommonOthOff -}; - - static DMXLocalInputInfoRec DMXLocalDevices[] = { /* Dummy drivers that can compile on any OS */ #ifdef __linux__ @@ -897,29 +889,6 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI) } } break; -#if 0 - case IsXExtensionDevice: - case IsXExtensionKeyboard: - case IsXExtensionPointer: - if (doXI) { - if (!dmxInput->numDevs) { - dmxLog(dmxWarning, - "Cannot use remote (%s) XInput devices if" - " not also using core devices\n", - dmxInput->name); - } else { - dmxLocal = dmxInputCopyLocal(dmxInput, - &DMXCommonOth); - dmxLocal->isCore = FALSE; - dmxLocal->sendsCore = FALSE; - dmxLocal->deviceId = devices[i].id; - dmxLocal->deviceName = (devices[i].name - ? strdup(devices[i].name) - : NULL); - } - } - break; -#endif } } XFreeDeviceList(devices); From 7a08f9abef7219fabdab8d1d49e8d3afb042e36a Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 18:59:39 -0500 Subject: [PATCH 4/9] dmx: warning fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dmxinputinit.c: In function ‘dmxBlockHandler’: dmxinputinit.c:610:44: warning: cast from pointer to integer of different size dmxinputinit.c: In function ‘dmxWakeupHandler’: dmxinputinit.c:637:41: warning: cast from pointer to integer of different size dmxinputinit.c: In function ‘dmxInputInit’: dmxinputinit.c:1041:36: warning: cast to pointer from integer of different size Reviewed-by: Peter Hutterer Signed-off-by: Adam Jackson --- hw/dmx/input/dmxinputinit.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c index 6fc11cd0d..5cbd620c9 100644 --- a/hw/dmx/input/dmxinputinit.c +++ b/hw/dmx/input/dmxinputinit.c @@ -607,7 +607,7 @@ static void dmxCollectAll(DMXInputInfo *dmxInput) static void dmxBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadMask) { - DMXInputInfo *dmxInput = &dmxInputs[(int)blockData]; + DMXInputInfo *dmxInput = &dmxInputs[(uintptr_t)blockData]; static unsigned long generation = 0; if (generation != serverGeneration) { @@ -634,7 +634,7 @@ static void dmxSwitchReturn(pointer p) static void dmxWakeupHandler(pointer blockData, int result, pointer pReadMask) { - DMXInputInfo *dmxInput = &dmxInputs[(int)blockData]; + DMXInputInfo *dmxInput = &dmxInputs[(uintptr_t)blockData]; int i; if (dmxInput->vt_switch_pending) { @@ -1036,9 +1036,8 @@ void dmxInputInit(DMXInputInfo *dmxInput) dmxInput->processInputEvents = dmxProcessInputEvents; dmxInput->detached = False; - RegisterBlockAndWakeupHandlers(dmxBlockHandler, - dmxWakeupHandler, - (void *)dmxInput->inputIdx); + RegisterBlockAndWakeupHandlers(dmxBlockHandler, dmxWakeupHandler, + (void *)(uintptr_t)dmxInput->inputIdx); } static void dmxInputFreeLocal(DMXLocalInputInfoRec *local) From d127075da06239852c1cc745abfe63d0d180d984 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 20 Jan 2011 19:03:33 -0500 Subject: [PATCH 5/9] xdmxconfig: warning fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xdmxconfig.c: In function ‘dmxConfigCanvasDraw’: xdmxconfig.c:299:23: warning: ‘maxHeight’ may be used uninitialized in this function Reviewed-by: Peter Hutterer Signed-off-by: Adam Jackson --- hw/dmx/config/xdmxconfig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/dmx/config/xdmxconfig.c b/hw/dmx/config/xdmxconfig.c index 033b52512..c67077aec 100644 --- a/hw/dmx/config/xdmxconfig.c +++ b/hw/dmx/config/xdmxconfig.c @@ -142,7 +142,7 @@ static void dmxConfigGetDims(int *maxWidth, int *maxHeight) DMXConfigEntryPtr e; *maxWidth = dmxConfigWallWidth = 0; - *maxWidth = dmxConfigWallHeight = 0; + *maxHeight = dmxConfigWallHeight = 0; if (!dmxConfigCurrent) return; dmxConfigWallWidth = dmxConfigCurrent->width; From f953ae7d8a578d135a6faaf69d9c06eae7c85ede Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Mon, 14 Dec 2009 14:38:10 -0500 Subject: [PATCH 6/9] os: Reduce smart scheduler setup calls We can return from WaitForSomething with no clients ready for any number of reasons. There's no reason to set up the scheduler timer when this happens. Reviewed-by: Keith Packard Signed-off-by: Adam Jackson --- os/WaitFor.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/os/WaitFor.c b/os/WaitFor.c index e66300490..867cb04b8 100644 --- a/os/WaitFor.c +++ b/os/WaitFor.c @@ -153,13 +153,17 @@ WaitForSomething(int *pClientsReady) fd_set clientsWritable; int curclient; int selecterr; - int nready; + static int nready; fd_set devicesReadable; CARD32 now = 0; Bool someReady = FALSE; FD_ZERO(&clientsReadable); + if (nready) + SmartScheduleStopTimer(); + nready = 0; + /* We need a while loop here to handle crashed connections and the screen saver timeout */ while (1) @@ -211,7 +215,6 @@ WaitForSomething(int *pClientsReady) } XFD_COPYSET(&AllSockets, &LastSelectMask); } - SmartScheduleStopTimer (); BlockHandler((pointer)&wt, (pointer)&LastSelectMask); if (NewOutputPending) @@ -230,7 +233,6 @@ WaitForSomething(int *pClientsReady) } selecterr = GetErrno(); WakeupHandler(i, (pointer)&LastSelectMask); - SmartScheduleStartTimer (); if (i <= 0) /* An error or timeout occurred */ { if (dispatchException) @@ -388,6 +390,10 @@ WaitForSomething(int *pClientsReady) #endif } } + + if (nready) + SmartScheduleStartTimer(); + return nready; } From 3282e3c627f97f079e3a9af756a6b13bd9a5f227 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 15 Apr 2010 08:46:28 -0400 Subject: [PATCH 7/9] resource: s/NullResource/NULL/g Reviewed-by: Alan Coopersmith Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- dix/resource.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/dix/resource.c b/dix/resource.c index 6bd240368..18ed68223 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -167,7 +167,6 @@ typedef struct _Resource { RESTYPE type; pointer value; } ResourceRec, *ResourcePtr; -#define NullResource ((ResourcePtr)NULL) typedef struct _ClientResource { ResourcePtr *resources; @@ -326,7 +325,7 @@ InitClientResources(ClientPtr client) clientTable[i].expectID = client->clientAsMask; for (j=0; j= 0; rptr++, tptr++) { - *rptr = NullResource; + *rptr = NULL; *tptr = rptr; } clientTable[client].hashsize++; @@ -555,7 +554,7 @@ RebuildTable(int client) for (res = *rptr; res; res = next) { next = res->next; - res->next = NullResource; + res->next = NULL; tptr = &tails[Hash(client, res->id)]; **tptr = res; *tptr = &res->next; From cb61cf5c99004ba3c76b504220c6728b5f2d2de6 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 15 Apr 2010 18:36:55 -0400 Subject: [PATCH 8/9] resource: Remove expectID hack This is clearly meant to short-circuit the (modestly) expensive resource lookup in LegalNewID. The problem is that long-lived clients will eventually run completely through their XID space and start asking XC-MISC for IDs to reuse. Once that happens, the comparison against expectID will always be true, and we'll no longer catch XID collisions at all. Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- dix/resource.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/dix/resource.c b/dix/resource.c index 18ed68223..f558ed27f 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -175,7 +175,6 @@ typedef struct _ClientResource { int hashsize; /* log(2)(buckets) */ XID fakeID; XID endFakeID; - XID expectID; } ClientResourceRec; RESTYPE lastResourceType; @@ -322,7 +321,6 @@ InitClientResources(ClientPtr client) clientTable[i].fakeID = client->clientAsMask | (client->index ? SERVER_BIT : SERVER_MINID); clientTable[i].endFakeID = (clientTable[i].fakeID | RESOURCE_ID_MASK) + 1; - clientTable[i].expectID = client->clientAsMask; for (j=0; jvalue = value; *head = res; rrec->elements++; - if (!(id & SERVER_BIT) && (id >= rrec->expectID)) - rrec->expectID = id + 1; CallResourceStateCallback(ResourceStateAdding, res); return TRUE; } @@ -895,9 +891,6 @@ LegalNewID(XID id, ClientPtr client) #endif /* PANORAMIX */ if (client->clientAsMask == (id & ~RESOURCE_ID_MASK)) { - if (clientTable[client->index].expectID <= id) - return TRUE; - rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient, DixGetAttrAccess); return rc == BadValue; From a1d885fdd67503a442b348626d2eddf6d22419e8 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 23 Jun 2010 13:28:55 -0400 Subject: [PATCH 9/9] resource: Fix indentation Reviewed-by: Alan Coopersmith Reviewed-by: Daniel Stone Signed-off-by: Adam Jackson --- dix/resource.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dix/resource.c b/dix/resource.c index f558ed27f..26d2c72aa 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -881,21 +881,21 @@ LegalNewID(XID id, ClientPtr client) #ifdef PANORAMIX XID minid, maxid; - if (!noPanoramiXExtension) { - minid = client->clientAsMask | (client->index ? - SERVER_BIT : SERVER_MINID); - maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1; - if ((id >= minid) && (id <= maxid)) - return TRUE; - } + if (!noPanoramiXExtension) { + minid = client->clientAsMask | (client->index ? + SERVER_BIT : SERVER_MINID); + maxid = (clientTable[client->index].fakeID | RESOURCE_ID_MASK) + 1; + if ((id >= minid) && (id <= maxid)) + return TRUE; + } #endif /* PANORAMIX */ - if (client->clientAsMask == (id & ~RESOURCE_ID_MASK)) - { - rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient, - DixGetAttrAccess); - return rc == BadValue; - } - return FALSE; + if (client->clientAsMask == (id & ~RESOURCE_ID_MASK)) + { + rc = dixLookupResourceByClass(&val, id, RC_ANY, serverClient, + DixGetAttrAccess); + return rc == BadValue; + } + return FALSE; } int