summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamey Sharp <jamey@minilop.net>2009-10-08 13:38:44 +1100
committerDaniel Stone <daniel@fooishbar.org>2009-10-08 13:38:44 +1100
commitb0dd6be2c8703f7062d45ac9fd646550c7d54e3b (patch)
tree98c7ac7a8d90fea6fcdd44525fc42e84d0cb4914
parentb680a89262efcfef4644adb4a61ae42ea0db0c93 (diff)
Cast small-int values through intptr_t when passed as pointers
On 64-bit systems, int and pointers don't have the same size, so GCC gives warnings about casts between int and pointer types. However, in the cases covered by this patch, it's always a value that fits in int being stored temporarily as a pointer and then converted back later, which is safe. Casting through the pointer-sized integer type intptr_t convinces the compiler that this is OK. Signed-off-by: Jamey Sharp <jamey@minilop.net> Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--Xext/xtest.c6
-rw-r--r--composite/compwindow.c4
-rw-r--r--dix/events.c4
-rw-r--r--glx/glxcmds.c2
-rw-r--r--hw/xfree86/dri/dri.c8
-rw-r--r--hw/xfree86/os-support/bus/linuxPci.c2
6 files changed, 14 insertions, 12 deletions
diff --git a/Xext/xtest.c b/Xext/xtest.c
index 6b0e9fd14..5af2b5c83 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -640,8 +640,8 @@ int AllocXTestDevice (ClientPtr client, char* name,
retval = AllocDevicePair( client, xtestname, ptr, keybd, CorePointerProc, CoreKeyboardProc, FALSE);
if ( retval == Success ){
- dixSetPrivate(&((*ptr)->devPrivates), XTestDevicePrivateKey, (void *)master_ptr->id);
- dixSetPrivate(&((*keybd)->devPrivates), XTestDevicePrivateKey, (void *)master_keybd->id);
+ dixSetPrivate(&((*ptr)->devPrivates), XTestDevicePrivateKey, (void *)(intptr_t)master_ptr->id);
+ dixSetPrivate(&((*keybd)->devPrivates), XTestDevicePrivateKey, (void *)(intptr_t)master_keybd->id);
XIChangeDeviceProperty(*ptr, XIGetKnownProperty(XI_PROP_XTEST_DEVICE),
XA_INTEGER, 8, PropModeReplace, 1, &dummy,
@@ -677,7 +677,7 @@ IsXTestDevice(DeviceIntPtr dev, DeviceIntPtr master)
return is_XTest;
tmp = dixLookupPrivate(&dev->devPrivates, XTestDevicePrivateKey);
- mid = (int)tmp;
+ mid = (intptr_t)tmp;
/* deviceid 0 is reserved for XIAllDevices, non-zero mid means XTest
* device */
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 4267a51c7..9bc43b05b 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -99,7 +99,7 @@ static Bool
compRepaintBorder (ClientPtr pClient, pointer closure)
{
WindowPtr pWindow;
- int rc = dixLookupWindow(&pWindow, (XID)closure, pClient, DixWriteAccess);
+ int rc = dixLookupWindow(&pWindow, (XID)(intptr_t)closure, pClient, DixWriteAccess);
if (rc == Success) {
RegionRec exposed;
@@ -130,7 +130,7 @@ compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
SetBorderSize (pWindow);
if (HasBorder (pWindow))
QueueWorkProc (compRepaintBorder, serverClient,
- (pointer) pWindow->drawable.id);
+ (pointer)(intptr_t) pWindow->drawable.id);
return WT_WALKCHILDREN;
}
diff --git a/dix/events.c b/dix/events.c
index d60b8a534..14e3900b9 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1460,7 +1460,7 @@ static DevPrivateKey GrabPrivateKey = &GrabPrivateKeyIndex;
static void
DetachFromMaster(DeviceIntPtr dev)
{
- int id;
+ intptr_t id;
if (!dev->u.master)
return;
@@ -1482,7 +1482,7 @@ ReattachToOldMaster(DeviceIntPtr dev)
p = dixLookupPrivate(&dev->devPrivates, GrabPrivateKey);
- id = (int)p; /* silence gcc warnings */
+ id = (intptr_t) p; /* silence gcc warnings */
dixLookupDevice(&master, id, serverClient, DixUseAccess);
if (master)
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index ba4c12398..eedab652f 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -2057,7 +2057,7 @@ int __glXDisp_BindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
if (ret == Success) {
if (barrier)
/* add source for cleanup when drawable is gone */
- AddResource(drawable, __glXSwapBarrierRes, (pointer)screen);
+ AddResource(drawable, __glXSwapBarrierRes, (pointer)(intptr_t)screen);
else
/* delete source */
FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index faddfe6ec..0de9be621 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1277,7 +1277,7 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
/* track this in case the client dies */
AddResource(FakeClientID(client->index), DRIDrawablePrivResType,
- (pointer)pDrawable->id);
+ (pointer)(intptr_t)pDrawable->id);
if (pDRIDrawablePriv->hwDrawable) {
drmUpdateDrawableInfo(pDRIPriv->drmFD,
@@ -1348,7 +1348,7 @@ DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable)
if (pDrawable->type == DRAWABLE_WINDOW) {
LookupClientResourceComplex(client, DRIDrawablePrivResType,
DRIDestroyDrawableCB,
- (pointer)pDrawable->id);
+ (pointer)(intptr_t)pDrawable->id);
}
else { /* pixmap (or for GLX 1.3, a PBuffer) */
/* NOT_DONE */
@@ -1364,7 +1364,9 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
WindowPtr pWin;
int rc;
- id = (XID)pResource;
+ /* For DRIDrawablePrivResType, the XID is the client's fake ID. The
+ * important XID is the value in pResource. */
+ id = (XID)(intptr_t)pResource;
rc = dixLookupWindow(&pWin, id, serverClient, DixGetAttrAccess);
if (rc == Success) {
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 920a14949..289315ebc 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -445,7 +445,7 @@ xf86MapLegacyIO(struct pci_device *dev)
PCIIOC_MMAP_IS_IO);
}
else { /* legacy_io file exists, encode fd */
- DomainMmappedIO[domain] = (pointer)(fd << 24);
+ DomainMmappedIO[domain] = (pointer)(intptr_t)(fd << 24);
}
}