summaryrefslogtreecommitdiff
path: root/hw/xfree86/dixmods/extmod
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/dixmods/extmod')
-rw-r--r--hw/xfree86/dixmods/extmod/xf86dga2.c18
-rw-r--r--hw/xfree86/dixmods/extmod/xf86vmode.c16
2 files changed, 16 insertions, 18 deletions
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 868fb0624..46aa8b882 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -420,6 +420,7 @@ static int
ProcXDGAInstallColormap(ClientPtr client)
{
ColormapPtr cmap;
+ int rc;
REQUEST(xXDGAInstallColormapReq);
if (stuff->screen > screenInfo.numScreens)
@@ -430,13 +431,13 @@ ProcXDGAInstallColormap(ClientPtr client)
REQUEST_SIZE_MATCH(xXDGAInstallColormapReq);
- cmap = (ColormapPtr)LookupIDByType(stuff->cmap, RT_COLORMAP);
- if (cmap) {
+ rc = dixLookupResourceByType((pointer *)&cmap, stuff->cmap, RT_COLORMAP,
+ client, DixInstallAccess);
+ if (rc == Success) {
DGAInstallCmap(cmap);
return (client->noClientException);
} else {
- client->errorValue = stuff->cmap;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
return (client->noClientException);
@@ -858,6 +859,7 @@ static int
ProcXF86DGAInstallColormap(ClientPtr client)
{
ColormapPtr pcmp;
+ int rc;
REQUEST(xXF86DGAInstallColormapReq);
if (stuff->screen > screenInfo.numScreens)
@@ -871,13 +873,13 @@ ProcXF86DGAInstallColormap(ClientPtr client)
if (!DGAActive(stuff->screen))
return (DGAErrorBase + XF86DGADirectNotActivated);
- pcmp = (ColormapPtr )LookupIDByType(stuff->id, RT_COLORMAP);
- if (pcmp) {
+ rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP,
+ client, DixInstallAccess);
+ if (rc == Success) {
DGAInstallCmap(pcmp);
return (client->noClientException);
} else {
- client->errorValue = stuff->id;
- return (BadColor);
+ return (rc == BadValue) ? BadColor : rc;
}
}
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index ea8089e94..10b9ed370 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -1541,6 +1541,7 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
{
CARD16 *ramp = NULL;
int n, length, i;
+ size_t ramplen;
xXF86VidModeGetGammaRampReply rep;
REQUEST(xXF86VidModeGetGammaRampReq);
@@ -1555,7 +1556,8 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
length = (stuff->size + 1) & ~1;
if(stuff->size) {
- if(!(ramp = xalloc(length * 3 * sizeof(CARD16))))
+ ramplen = length * 3 * sizeof(CARD16);
+ if (!(ramp = xalloc(ramplen)))
return BadAlloc;
if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
@@ -1573,13 +1575,12 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
swaps(&rep.sequenceNumber, n);
swapl(&rep.length, n);
swaps(&rep.size, n);
- for(i = 0; i < length * 3; i++)
- swaps(&ramp[i],n);
+ SwapShorts(ramp, length * 3);
}
WriteToClient(client, sizeof(xXF86VidModeGetGammaRampReply), (char *)&rep);
if(stuff->size) {
- WriteToClient(client, rep.length << 2, (char*)ramp);
+ WriteToClient(client, ramplen, (char*)ramp);
xfree(ramp);
}
@@ -2060,7 +2061,6 @@ SProcXF86VidModeGetGamma(ClientPtr client)
static int
SProcXF86VidModeSetGammaRamp(ClientPtr client)
{
- CARD16 *ramp;
int length, n;
REQUEST(xXF86VidModeSetGammaRampReq);
swaps(&stuff->length, n);
@@ -2069,11 +2069,7 @@ SProcXF86VidModeSetGammaRamp(ClientPtr client)
swaps(&stuff->screen, n);
length = ((stuff->size + 1) & ~1) * 6;
REQUEST_FIXED_SIZE(xXF86VidModeSetGammaRampReq, length);
- ramp = (CARD16*)&stuff[1];
- while(length--) {
- swaps(ramp, n);
- ramp++;
- }
+ SwapRestS(stuff);
return ProcXF86VidModeSetGammaRamp(client);
}