randr: simplify extra payload copying in ProcRRGetOutputInfo()
Make it a bit easier to understand how exactly the name string is copied into the reply payload: just do the little memcpy() right where the target position is decided any the rest of the payload is filled. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
b67dabef12
commit
6b5c64d273
|
@ -437,14 +437,12 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
REQUEST(xRRGetOutputInfoReq);
|
REQUEST(xRRGetOutputInfoReq);
|
||||||
xRRGetOutputInfoReply rep;
|
xRRGetOutputInfoReply rep;
|
||||||
RROutputPtr output;
|
RROutputPtr output;
|
||||||
CARD8 *extra;
|
|
||||||
unsigned long extraLen;
|
unsigned long extraLen;
|
||||||
ScreenPtr pScreen;
|
ScreenPtr pScreen;
|
||||||
rrScrPrivPtr pScrPriv;
|
rrScrPrivPtr pScrPriv;
|
||||||
RRCrtc *crtcs;
|
RRCrtc *crtcs;
|
||||||
RRMode *modes;
|
RRMode *modes;
|
||||||
RROutput *clones;
|
RROutput *clones;
|
||||||
char *name;
|
|
||||||
int i;
|
int i;
|
||||||
Bool leased;
|
Bool leased;
|
||||||
|
|
||||||
|
@ -456,6 +454,8 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
pScreen = output->pScreen;
|
pScreen = output->pScreen;
|
||||||
pScrPriv = rrGetScrPriv(pScreen);
|
pScrPriv = rrGetScrPriv(pScreen);
|
||||||
|
|
||||||
|
CARD8 *extra = NULL;
|
||||||
|
|
||||||
if (leased) {
|
if (leased) {
|
||||||
rep = (xRRGetOutputInfoReply) {
|
rep = (xRRGetOutputInfoReply) {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
|
@ -473,11 +473,8 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
extra = calloc(1, extraLen);
|
extra = calloc(1, extraLen);
|
||||||
if (!extra)
|
if (!extra)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
memcpy(extra, output->name, output->nameLength);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
extra = NULL;
|
|
||||||
|
|
||||||
name = (char *) extra;
|
|
||||||
} else {
|
} else {
|
||||||
rep = (xRRGetOutputInfoReply) {
|
rep = (xRRGetOutputInfoReply) {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
|
@ -506,13 +503,12 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
if (!extra)
|
if (!extra)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
extra = NULL;
|
|
||||||
|
|
||||||
crtcs = (RRCrtc *) extra;
|
crtcs = (RRCrtc *) extra;
|
||||||
modes = (RRMode *) (crtcs + output->numCrtcs);
|
modes = (RRMode *) (crtcs + output->numCrtcs);
|
||||||
clones = (RROutput *) (modes + output->numModes + output->numUserModes);
|
clones = (RROutput *) (modes + output->numModes + output->numUserModes);
|
||||||
name = (char *) (clones + output->numClones);
|
|
||||||
|
memcpy((clones + output->numClones), output->name, output->nameLength);
|
||||||
|
|
||||||
for (i = 0; i < output->numCrtcs; i++) {
|
for (i = 0; i < output->numCrtcs; i++) {
|
||||||
crtcs[i] = output->crtcs[i]->id;
|
crtcs[i] = output->crtcs[i]->id;
|
||||||
|
@ -533,7 +529,7 @@ ProcRRGetOutputInfo(ClientPtr client)
|
||||||
swapl(&clones[i]);
|
swapl(&clones[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memcpy(name, output->name, output->nameLength);
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
|
|
Loading…
Reference in New Issue