mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 10:14:52 +00:00
Xi: use x_rpcbuf_t in ProcXListDeviceProperties() and ProcXIListProperties()
x_rpcbuf_t allows easy accumulation of payload data and doing byteswap (when necessary) at the same time. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
f0341145f0
commit
79ca3103f7
@@ -847,8 +847,6 @@ XISetDevicePropertyDeletable(DeviceIntPtr dev, Atom property, Bool deletable)
|
||||
int
|
||||
ProcXListDeviceProperties(ClientPtr client)
|
||||
{
|
||||
Atom *atoms;
|
||||
int natoms;
|
||||
DeviceIntPtr dev;
|
||||
int rc = Success;
|
||||
|
||||
@@ -859,10 +857,19 @@ ProcXListDeviceProperties(ClientPtr client)
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
|
||||
Atom *atoms = NULL;
|
||||
int natoms;
|
||||
rc = list_atoms(dev, &natoms, &atoms);
|
||||
if (rc != Success)
|
||||
return rc;
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped, .err_clear = TRUE };
|
||||
x_rpcbuf_write_CARD32s(&rpcbuf, atoms, natoms);
|
||||
free(atoms);
|
||||
|
||||
if (rpcbuf.error)
|
||||
return BadAlloc;
|
||||
|
||||
xListDevicePropertiesReply rep = {
|
||||
.repType = X_Reply,
|
||||
.RepType = X_ListDeviceProperties,
|
||||
@@ -877,12 +884,8 @@ ProcXListDeviceProperties(ClientPtr client)
|
||||
swaps(&rep.nAtoms);
|
||||
}
|
||||
WriteToClient(client, sizeof(xListDevicePropertiesReply), &rep);
|
||||
if (natoms) {
|
||||
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
||||
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
|
||||
free(atoms);
|
||||
}
|
||||
return rc;
|
||||
WriteRpcbufToClient(client, &rpcbuf);
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -1094,13 +1097,18 @@ ProcXIListProperties(ClientPtr client)
|
||||
swapl(&rep.length);
|
||||
swaps(&rep.num_properties);
|
||||
}
|
||||
|
||||
x_rpcbuf_t rpcbuf = { .swapped = client->swapped };
|
||||
x_rpcbuf_write_CARD32s(&rpcbuf, atoms, natoms);
|
||||
|
||||
free(atoms);
|
||||
|
||||
if (rpcbuf.error)
|
||||
return BadAlloc;
|
||||
|
||||
WriteToClient(client, sizeof(xXIListPropertiesReply), &rep);
|
||||
if (natoms) {
|
||||
client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write;
|
||||
WriteSwappedDataToClient(client, natoms * sizeof(Atom), atoms);
|
||||
free(atoms);
|
||||
}
|
||||
return rc;
|
||||
WriteRpcbufToClient(client, &rpcbuf);
|
||||
return Success;
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user