diff options
Diffstat (limited to 'xorg-server/randr')
-rw-r--r-- | xorg-server/randr/randrstr.h | 9 | ||||
-rw-r--r-- | xorg-server/randr/rrcrtc.c | 56 | ||||
-rw-r--r-- | xorg-server/randr/rrinfo.c | 10 | ||||
-rw-r--r-- | xorg-server/randr/rrmode.c | 4 | ||||
-rw-r--r-- | xorg-server/randr/rrmonitor.c | 11 | ||||
-rw-r--r-- | xorg-server/randr/rroutput.c | 14 | ||||
-rw-r--r-- | xorg-server/randr/rrproperty.c | 12 | ||||
-rw-r--r-- | xorg-server/randr/rrproviderproperty.c | 6 | ||||
-rw-r--r-- | xorg-server/randr/rrscreen.c | 7 | ||||
-rw-r--r-- | xorg-server/randr/rrtransform.c | 2 |
10 files changed, 70 insertions, 61 deletions
diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h index 438a52aeb..03974fd4f 100644 --- a/xorg-server/randr/randrstr.h +++ b/xorg-server/randr/randrstr.h @@ -1016,6 +1016,15 @@ RRMonitorFreeList(RRMonitorPtr monitors, int nmon); void RRMonitorClose(ScreenPtr screen); +RRMonitorPtr +RRMonitorAlloc(int noutput); + +int +RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor); + +void +RRMonitorFree(RRMonitorPtr monitor); + int ProcRRGetMonitors(ClientPtr client); diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c index 69b3ecf0f..e95b049df 100644 --- a/xorg-server/randr/rrcrtc.c +++ b/xorg-server/randr/rrcrtc.c @@ -65,8 +65,8 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate) /* make space for the crtc pointer */ if (pScrPriv->numCrtcs) - crtcs = realloc(pScrPriv->crtcs, - (pScrPriv->numCrtcs + 1) * sizeof(RRCrtcPtr)); + crtcs = reallocarray(pScrPriv->crtcs, + pScrPriv->numCrtcs + 1, sizeof(RRCrtcPtr)); else crtcs = malloc(sizeof(RRCrtcPtr)); if (!crtcs) @@ -176,10 +176,10 @@ RRCrtcNotify(RRCrtcPtr crtc, if (numOutputs) { if (crtc->numOutputs) - newoutputs = realloc(crtc->outputs, - numOutputs * sizeof(RROutputPtr)); + newoutputs = reallocarray(crtc->outputs, + numOutputs, sizeof(RROutputPtr)); else - newoutputs = malloc(numOutputs * sizeof(RROutputPtr)); + newoutputs = xallocarray(numOutputs, sizeof(RROutputPtr)); if (!newoutputs) return FALSE; } @@ -394,7 +394,7 @@ rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height, Bool ret; int depth; PixmapPtr mscreenpix; - PixmapPtr protopix = crtc->pScreen->current_master->GetScreenPixmap(crtc->pScreen->current_master); + PixmapPtr protopix = master->GetScreenPixmap(master); rrScrPriv(crtc->pScreen); /* create a pixmap on the master screen, @@ -428,7 +428,7 @@ rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height, ret = pScrPriv->rrCrtcSetScanoutPixmap(crtc, spix); if (ret == FALSE) { - ErrorF("failed to set shadow slave pixmap\n"); + ErrorF("randr: failed to set shadow slave pixmap\n"); return FALSE; } @@ -457,18 +457,20 @@ rrCheckPixmapBounding(ScreenPtr pScreen, /* have to iterate all the crtcs of the attached gpu masters and all their output slaves */ for (c = 0; c < pScrPriv->numCrtcs; c++) { - if (pScrPriv->crtcs[c] == rr_crtc) { + RRCrtcPtr crtc = pScrPriv->crtcs[c]; + + if (crtc == rr_crtc) { newbox.x1 = x; newbox.x2 = x + w; newbox.y1 = y; newbox.y2 = y + h; } else { - if (!pScrPriv->crtcs[c]->mode) + if (!crtc->mode) continue; - newbox.x1 = pScrPriv->crtcs[c]->x; - newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width; - newbox.y1 = pScrPriv->crtcs[c]->y; - newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height; + newbox.x1 = crtc->x; + newbox.x2 = crtc->x + crtc->mode->mode.width; + newbox.y1 = crtc->y; + newbox.y2 = crtc->y + crtc->mode->mode.height; } RegionInit(&new_crtc_region, &newbox, 1); RegionUnion(&total_region, &total_region, &new_crtc_region); @@ -477,19 +479,21 @@ rrCheckPixmapBounding(ScreenPtr pScreen, xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) { rrScrPrivPtr slave_priv = rrGetScrPriv(slave); for (c = 0; c < slave_priv->numCrtcs; c++) { - if (slave_priv->crtcs[c] == rr_crtc) { + RRCrtcPtr slave_crtc = slave_priv->crtcs[c]; + + if (slave_crtc == rr_crtc) { newbox.x1 = x; newbox.x2 = x + w; newbox.y1 = y; newbox.y2 = y + h; } else { - if (!slave_priv->crtcs[c]->mode) + if (!slave_crtc->mode) continue; - newbox.x1 = slave_priv->crtcs[c]->x; - newbox.x2 = slave_priv->crtcs[c]->x + slave_priv->crtcs[c]->mode->mode.width; - newbox.y1 = slave_priv->crtcs[c]->y; - newbox.y2 = slave_priv->crtcs[c]->y + slave_priv->crtcs[c]->mode->mode.height; + newbox.x1 = slave_crtc->x; + newbox.x2 = slave_crtc->x + slave_crtc->mode->mode.width; + newbox.y1 = slave_crtc->y; + newbox.y2 = slave_crtc->y + slave_crtc->mode->mode.height; } RegionInit(&new_crtc_region, &newbox, 1); RegionUnion(&total_region, &total_region, &new_crtc_region); @@ -502,7 +506,6 @@ rrCheckPixmapBounding(ScreenPtr pScreen, if (new_width == screen_pixmap->drawable.width && new_height == screen_pixmap->drawable.height) { - ErrorF("adjust shatters %d %d\n", newsize->x1, newsize->x2); } else { pScrPriv->rrScreenSetSize(pScreen, new_width, new_height, 0, 0); } @@ -557,7 +560,6 @@ RRCrtcSet(RRCrtcPtr crtc, width = mode->mode.width; height = mode->mode.height; } - ErrorF("have a master to look out for\n"); ret = rrCheckPixmapBounding(master, crtc, x, y, width, height); if (!ret) @@ -565,8 +567,6 @@ RRCrtcSet(RRCrtcPtr crtc, if (pScreen->current_master) { ret = rrCreateSharedPixmap(crtc, width, height, x, y); - ErrorF("need to create shared pixmap %d", ret); - } } #if RANDR_12_INTERFACE @@ -798,7 +798,7 @@ RRCrtcGammaSetSize(RRCrtcPtr crtc, int size) if (size == crtc->gammaSize) return TRUE; if (size) { - gamma = malloc(size * 3 * sizeof(CARD16)); + gamma = xallocarray(size, 3 * sizeof(CARD16)); if (!gamma) return FALSE; } @@ -1027,7 +1027,7 @@ ProcRRSetCrtcConfig(ClientPtr client) return BadMatch; } if (numOutputs) { - outputs = malloc(numOutputs * sizeof(RROutputPtr)); + outputs = xallocarray(numOutputs, sizeof(RROutputPtr)); if (!outputs) return BadAlloc; } @@ -1575,7 +1575,8 @@ ProcRRGetCrtcTransform(ClientPtr client) return Success; } -static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y) +static Bool +check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y) { rrScrPriv(pScreen); int i; @@ -1595,7 +1596,8 @@ static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y) return FALSE; } -static Bool constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y) +static Bool +constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y) { rrScrPriv(pScreen); int i; diff --git a/xorg-server/randr/rrinfo.c b/xorg-server/randr/rrinfo.c index fc57bd408..24245b7b6 100644 --- a/xorg-server/randr/rrinfo.c +++ b/xorg-server/randr/rrinfo.c @@ -55,8 +55,8 @@ RROldModeAdd(RROutputPtr output, RRScreenSizePtr size, int refresh) } if (output->numModes) - modes = realloc(output->modes, - (output->numModes + 1) * sizeof(RRModePtr)); + modes = reallocarray(output->modes, + output->numModes + 1, sizeof(RRModePtr)); else modes = malloc(sizeof(RRModePtr)); if (!modes) { @@ -266,8 +266,8 @@ RRRegisterSize(ScreenPtr pScreen, for (i = 0; i < pScrPriv->nSizes; i++) if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i])) return &pScrPriv->pSizes[i]; - pNew = realloc(pScrPriv->pSizes, - (pScrPriv->nSizes + 1) * sizeof(RRScreenSize)); + pNew = reallocarray(pScrPriv->pSizes, + pScrPriv->nSizes + 1, sizeof(RRScreenSize)); if (!pNew) return 0; pNew[pScrPriv->nSizes++] = tmp; @@ -289,7 +289,7 @@ RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate) if (pSize->pRates[i].rate == rate) return TRUE; - pNew = realloc(pSize->pRates, (pSize->nRates + 1) * sizeof(RRScreenRate)); + pNew = reallocarray(pSize->pRates, pSize->nRates + 1, sizeof(RRScreenRate)); if (!pNew) return FALSE; pRate = &pNew[pSize->nRates++]; diff --git a/xorg-server/randr/rrmode.c b/xorg-server/randr/rrmode.c index befac4741..a7aa43320 100644 --- a/xorg-server/randr/rrmode.c +++ b/xorg-server/randr/rrmode.c @@ -79,7 +79,7 @@ RRModeCreate(xRRModeInfo * modeInfo, const char *name, ScreenPtr userScreen) mode->userScreen = userScreen; if (num_modes) - newModes = realloc(modes, (num_modes + 1) * sizeof(RRModePtr)); + newModes = reallocarray(modes, num_modes + 1, sizeof(RRModePtr)); else newModes = malloc(sizeof(RRModePtr)); @@ -166,7 +166,7 @@ RRModesForScreen(ScreenPtr pScreen, int *num_ret) RRModePtr *screen_modes; int num_screen_modes = 0; - screen_modes = malloc((num_modes ? num_modes : 1) * sizeof(RRModePtr)); + screen_modes = xallocarray((num_modes ? num_modes : 1), sizeof(RRModePtr)); if (!screen_modes) return NULL; diff --git a/xorg-server/randr/rrmonitor.c b/xorg-server/randr/rrmonitor.c index fbdd352f6..05285ddfd 100644 --- a/xorg-server/randr/rrmonitor.c +++ b/xorg-server/randr/rrmonitor.c @@ -389,13 +389,13 @@ RRMonitorCountList(ScreenPtr screen) return nmon; } -static void +void RRMonitorFree(RRMonitorPtr monitor) { free(monitor); } -static RRMonitorPtr +RRMonitorPtr RRMonitorAlloc(int noutput) { RRMonitorPtr monitor; @@ -451,7 +451,7 @@ RRMonitorMatchesOutputName(ScreenPtr screen, Atom name) return FALSE; } -static int +int RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor) { rrScrPrivPtr pScrPriv = rrGetScrPriv(screen); @@ -494,8 +494,9 @@ RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor) * needs to not have any side-effects on failure */ if (pScrPriv->numMonitors) - monitors = realloc(pScrPriv->monitors, - (pScrPriv->numMonitors + 1) * sizeof (RRMonitorPtr)); + monitors = reallocarray(pScrPriv->monitors, + pScrPriv->numMonitors + 1, + sizeof (RRMonitorPtr)); else monitors = malloc(sizeof (RRMonitorPtr)); diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c index 548e07d1d..10df4da95 100644 --- a/xorg-server/randr/rroutput.c +++ b/xorg-server/randr/rroutput.c @@ -60,8 +60,8 @@ RROutputCreate(ScreenPtr pScreen, pScrPriv = rrGetScrPriv(pScreen); if (pScrPriv->numOutputs) - outputs = realloc(pScrPriv->outputs, - (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr)); + outputs = reallocarray(pScrPriv->outputs, + pScrPriv->numOutputs + 1, sizeof(RROutputPtr)); else outputs = malloc(sizeof(RROutputPtr)); if (!outputs) @@ -124,7 +124,7 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones) return TRUE; } if (numClones) { - newClones = malloc(numClones * sizeof(RROutputPtr)); + newClones = xallocarray(numClones, sizeof(RROutputPtr)); if (!newClones) return FALSE; } @@ -157,7 +157,7 @@ RROutputSetModes(RROutputPtr output, } if (numModes) { - newModes = malloc(numModes * sizeof(RRModePtr)); + newModes = xallocarray(numModes, sizeof(RRModePtr)); if (!newModes) return FALSE; } @@ -200,8 +200,8 @@ RROutputAddUserMode(RROutputPtr output, RRModePtr mode) return BadMatch; if (output->userModes) - newModes = realloc(output->userModes, - (output->numUserModes + 1) * sizeof(RRModePtr)); + newModes = reallocarray(output->userModes, + output->numUserModes + 1, sizeof(RRModePtr)); else newModes = malloc(sizeof(RRModePtr)); if (!newModes) @@ -256,7 +256,7 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs) return TRUE; } if (numCrtcs) { - newCrtcs = malloc(numCrtcs * sizeof(RRCrtcPtr)); + newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr)); if (!newCrtcs) return FALSE; } diff --git a/xorg-server/randr/rrproperty.c b/xorg-server/randr/rrproperty.c index e385e15ab..e56626cd2 100644 --- a/xorg-server/randr/rrproperty.c +++ b/xorg-server/randr/rrproperty.c @@ -140,7 +140,6 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, RRPropertyPtr prop; rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen); int size_in_bytes; - int total_size; unsigned long total_len; RRPropertyValuePtr prop_value; RRPropertyValueRec new_value; @@ -180,9 +179,8 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type, if (mode == PropModeReplace || len > 0) { void *new_data = NULL, *old_data = NULL; - total_size = total_len * size_in_bytes; - new_value.data = (void *) malloc(total_size); - if (!new_value.data && total_size) { + new_value.data = xallocarray(total_len, size_in_bytes); + if (!new_value.data && total_len && size_in_bytes) { if (add) RRDestroyOutputProperty(prop); return BadAlloc; @@ -350,7 +348,7 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property, return BadMatch; } - new_values = malloc(num_values * sizeof(INT32)); + new_values = xallocarray(num_values, sizeof(INT32)); if (!new_values && num_values) { if (add) RRDestroyOutputProperty(prop); @@ -400,7 +398,7 @@ ProcRRListOutputProperties(ClientPtr client) for (prop = output->properties; prop; prop = prop->next) numProps++; if (numProps) - if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom)))) + if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) return BadAlloc; rep = (xRRListOutputPropertiesReply) { @@ -447,7 +445,7 @@ ProcRRQueryOutputProperty(ClientPtr client) return BadName; if (prop->num_valid) { - extra = malloc(prop->num_valid * sizeof(INT32)); + extra = xallocarray(prop->num_valid, sizeof(INT32)); if (!extra) return BadAlloc; } diff --git a/xorg-server/randr/rrproviderproperty.c b/xorg-server/randr/rrproviderproperty.c index ff2c614d0..b79c17f9b 100644 --- a/xorg-server/randr/rrproviderproperty.c +++ b/xorg-server/randr/rrproviderproperty.c @@ -350,7 +350,7 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property, return BadMatch; } - new_values = malloc(num_values * sizeof(INT32)); + new_values = xallocarray(num_values, sizeof(INT32)); if (!new_values && num_values) { if (add) RRDestroyProviderProperty(prop); @@ -400,7 +400,7 @@ ProcRRListProviderProperties(ClientPtr client) for (prop = provider->properties; prop; prop = prop->next) numProps++; if (numProps) - if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom)))) + if (!(pAtoms = xallocarray(numProps, sizeof(Atom)))) return BadAlloc; rep = (xRRListProviderPropertiesReply) { @@ -445,7 +445,7 @@ ProcRRQueryProviderProperty(ClientPtr client) return BadName; if (prop->num_valid) { - extra = malloc(prop->num_valid * sizeof(INT32)); + extra = xallocarray(prop->num_valid, sizeof(INT32)); if (!extra) return BadAlloc; } diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c index e7ea49ddf..d0ca91e0e 100644 --- a/xorg-server/randr/rrscreen.c +++ b/xorg-server/randr/rrscreen.c @@ -400,8 +400,6 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen) update_totals(iter, pScrPriv); } - ErrorF("reporting %d %d %d %d\n", total_crtcs, total_outputs, total_modes, total_name_len); - pScrPriv = rrGetScrPriv(pScreen); rep = (xRRGetScreenResourcesReply) { .type = X_Reply, @@ -415,8 +413,9 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen) .nbytesNames = total_name_len }; - rep.length = (total_crtcs + total_outputs + total_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + - bytes_to_int32(rep.nbytesNames)); + rep.length = (total_crtcs + total_outputs + + total_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + + bytes_to_int32(total_name_len)); extraLen = rep.length << 2; if (extraLen) { diff --git a/xorg-server/randr/rrtransform.c b/xorg-server/randr/rrtransform.c index c8a27498f..6137f8587 100644 --- a/xorg-server/randr/rrtransform.c +++ b/xorg-server/randr/rrtransform.c @@ -70,7 +70,7 @@ RRTransformSetFilter(RRTransformPtr dst, xFixed *new_params; if (nparams) { - new_params = malloc(nparams * sizeof(xFixed)); + new_params = xallocarray(nparams, sizeof(xFixed)); if (!new_params) return FALSE; memcpy(new_params, params, nparams * sizeof(xFixed)); |