(!1601) Xext: xres: use static initialization
* use static initialization where applicable * drop unneeded setting of zero values Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
parent
fe804dfc1c
commit
5743c16b3b
54
Xext/xres.c
54
Xext/xres.c
|
@ -195,16 +195,15 @@ DestroyConstructResourceBytesCtx(ConstructResourceBytesCtx *ctx)
|
||||||
static int
|
static int
|
||||||
ProcXResQueryVersion(ClientPtr client)
|
ProcXResQueryVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
|
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
|
||||||
|
|
||||||
xXResQueryVersionReply rep = {
|
xXResQueryVersionReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = 0,
|
|
||||||
.server_major = SERVER_XRES_MAJOR_VERSION,
|
.server_major = SERVER_XRES_MAJOR_VERSION,
|
||||||
.server_minor = SERVER_XRES_MINOR_VERSION
|
.server_minor = SERVER_XRES_MINOR_VERSION
|
||||||
};
|
};
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXResQueryVersionReq);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps(&rep.sequenceNumber);
|
swaps(&rep.sequenceNumber);
|
||||||
swapl(&rep.length);
|
swapl(&rep.length);
|
||||||
|
@ -218,16 +217,13 @@ ProcXResQueryVersion(ClientPtr client)
|
||||||
static int
|
static int
|
||||||
ProcXResQueryClients(ClientPtr client)
|
ProcXResQueryClients(ClientPtr client)
|
||||||
{
|
{
|
||||||
/* REQUEST(xXResQueryClientsReq); */
|
|
||||||
xXResQueryClientsReply rep;
|
|
||||||
int *current_clients;
|
int *current_clients;
|
||||||
int i, num_clients;
|
int i, num_clients = 0;
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
|
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
|
||||||
|
|
||||||
current_clients = xallocarray(currentMaxClients, sizeof(int));
|
current_clients = xallocarray(currentMaxClients, sizeof(int));
|
||||||
|
|
||||||
num_clients = 0;
|
|
||||||
for (i = 0; i < currentMaxClients; i++) {
|
for (i = 0; i < currentMaxClients; i++) {
|
||||||
if (clients[i]) {
|
if (clients[i]) {
|
||||||
current_clients[num_clients] = i;
|
current_clients[num_clients] = i;
|
||||||
|
@ -235,7 +231,7 @@ ProcXResQueryClients(ClientPtr client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rep = (xXResQueryClientsReply) {
|
xXResQueryClientsReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = bytes_to_int32(num_clients * sz_xXResClient),
|
.length = bytes_to_int32(num_clients * sz_xXResClient),
|
||||||
|
@ -298,12 +294,11 @@ static int
|
||||||
ProcXResQueryClientResources(ClientPtr client)
|
ProcXResQueryClientResources(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xXResQueryClientResourcesReq);
|
REQUEST(xXResQueryClientResourcesReq);
|
||||||
xXResQueryClientResourcesReply rep;
|
|
||||||
int i, clientID, num_types;
|
|
||||||
int *counts;
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
|
REQUEST_SIZE_MATCH(xXResQueryClientResourcesReq);
|
||||||
|
|
||||||
|
int i, clientID, num_types = 0;
|
||||||
|
int *counts;
|
||||||
|
|
||||||
clientID = CLIENT_ID(stuff->xid);
|
clientID = CLIENT_ID(stuff->xid);
|
||||||
|
|
||||||
if ((clientID >= currentMaxClients) || !clients[clientID]) {
|
if ((clientID >= currentMaxClients) || !clients[clientID]) {
|
||||||
|
@ -315,14 +310,12 @@ ProcXResQueryClientResources(ClientPtr client)
|
||||||
|
|
||||||
FindAllClientResources(clients[clientID], ResFindAllRes, counts);
|
FindAllClientResources(clients[clientID], ResFindAllRes, counts);
|
||||||
|
|
||||||
num_types = 0;
|
|
||||||
|
|
||||||
for (i = 0; i <= lastResourceType; i++) {
|
for (i = 0; i <= lastResourceType; i++) {
|
||||||
if (counts[i])
|
if (counts[i])
|
||||||
num_types++;
|
num_types++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rep = (xXResQueryClientResourcesReply) {
|
xXResQueryClientResourcesReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = bytes_to_int32(num_types * sz_xXResType),
|
.length = bytes_to_int32(num_types * sz_xXResType),
|
||||||
|
@ -374,12 +367,11 @@ static int
|
||||||
ProcXResQueryClientPixmapBytes(ClientPtr client)
|
ProcXResQueryClientPixmapBytes(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xXResQueryClientPixmapBytesReq);
|
REQUEST(xXResQueryClientPixmapBytesReq);
|
||||||
xXResQueryClientPixmapBytesReply rep;
|
|
||||||
int clientID;
|
|
||||||
unsigned long bytes;
|
|
||||||
|
|
||||||
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
|
REQUEST_SIZE_MATCH(xXResQueryClientPixmapBytesReq);
|
||||||
|
|
||||||
|
int clientID;
|
||||||
|
unsigned long bytes = 0;
|
||||||
|
|
||||||
clientID = CLIENT_ID(stuff->xid);
|
clientID = CLIENT_ID(stuff->xid);
|
||||||
|
|
||||||
if ((clientID >= currentMaxClients) || !clients[clientID]) {
|
if ((clientID >= currentMaxClients) || !clients[clientID]) {
|
||||||
|
@ -387,20 +379,15 @@ ProcXResQueryClientPixmapBytes(ClientPtr client)
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = 0;
|
|
||||||
|
|
||||||
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
|
FindAllClientResources(clients[clientID], ResFindResourcePixmaps,
|
||||||
(void *) (&bytes));
|
(void *) (&bytes));
|
||||||
|
|
||||||
rep = (xXResQueryClientPixmapBytesReply) {
|
xXResQueryClientPixmapBytesReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = 0,
|
|
||||||
.bytes = bytes,
|
.bytes = bytes,
|
||||||
#ifdef _XSERVER64
|
#ifdef _XSERVER64
|
||||||
.bytes_overflow = bytes >> 32
|
.bytes_overflow = bytes >> 32
|
||||||
#else
|
|
||||||
.bytes_overflow = 0
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
|
@ -459,9 +446,10 @@ static Bool
|
||||||
ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
|
ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
|
||||||
ConstructClientIdCtx *ctx)
|
ConstructClientIdCtx *ctx)
|
||||||
{
|
{
|
||||||
xXResClientIdValue rep;
|
xXResClientIdValue rep = {
|
||||||
|
.spec.client = client->clientAsMask,
|
||||||
|
};
|
||||||
|
|
||||||
rep.spec.client = client->clientAsMask;
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swapl (&rep.spec.client);
|
swapl (&rep.spec.client);
|
||||||
}
|
}
|
||||||
|
@ -473,7 +461,6 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
|
||||||
}
|
}
|
||||||
|
|
||||||
rep.spec.mask = X_XResClientXIDMask;
|
rep.spec.mask = X_XResClientXIDMask;
|
||||||
rep.length = 0;
|
|
||||||
if (sendClient->swapped) {
|
if (sendClient->swapped) {
|
||||||
swapl (&rep.spec.mask);
|
swapl (&rep.spec.mask);
|
||||||
/* swapl (&rep.length, n); - not required for rep.length = 0 */
|
/* swapl (&rep.length, n); - not required for rep.length = 0 */
|
||||||
|
@ -502,9 +489,6 @@ ConstructClientIdValue(ClientPtr sendClient, ClientPtr client, CARD32 mask,
|
||||||
if (sendClient->swapped) {
|
if (sendClient->swapped) {
|
||||||
swapl (&rep.spec.mask);
|
swapl (&rep.spec.mask);
|
||||||
swapl (&rep.length);
|
swapl (&rep.length);
|
||||||
}
|
|
||||||
|
|
||||||
if (sendClient->swapped) {
|
|
||||||
swapl (value);
|
swapl (value);
|
||||||
}
|
}
|
||||||
memcpy(ptr, &rep, sizeof(rep));
|
memcpy(ptr, &rep, sizeof(rep));
|
||||||
|
@ -587,15 +571,15 @@ ProcXResQueryClientIds (ClientPtr client)
|
||||||
rc = ConstructClientIds(client, stuff->numSpecs, specs, &ctx);
|
rc = ConstructClientIds(client, stuff->numSpecs, specs, &ctx);
|
||||||
|
|
||||||
if (rc == Success) {
|
if (rc == Success) {
|
||||||
xXResQueryClientIdsReply rep = {
|
assert((ctx.resultBytes & 3) == 0);
|
||||||
|
|
||||||
|
xXResQueryClientIdsReply rep = {
|
||||||
.type = X_Reply,
|
.type = X_Reply,
|
||||||
.sequenceNumber = client->sequence,
|
.sequenceNumber = client->sequence,
|
||||||
.length = bytes_to_int32(ctx.resultBytes),
|
.length = bytes_to_int32(ctx.resultBytes),
|
||||||
.numIds = ctx.numIds
|
.numIds = ctx.numIds
|
||||||
};
|
};
|
||||||
|
|
||||||
assert((ctx.resultBytes & 3) == 0);
|
|
||||||
|
|
||||||
if (client->swapped) {
|
if (client->swapped) {
|
||||||
swaps (&rep.sequenceNumber);
|
swaps (&rep.sequenceNumber);
|
||||||
swapl (&rep.length);
|
swapl (&rep.length);
|
||||||
|
@ -952,11 +936,11 @@ static int
|
||||||
ProcXResQueryResourceBytes (ClientPtr client)
|
ProcXResQueryResourceBytes (ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xXResQueryResourceBytesReq);
|
REQUEST(xXResQueryResourceBytesReq);
|
||||||
|
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
ConstructResourceBytesCtx ctx;
|
ConstructResourceBytesCtx ctx;
|
||||||
|
|
||||||
REQUEST_AT_LEAST_SIZE(xXResQueryResourceBytesReq);
|
|
||||||
if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
|
if (stuff->numSpecs > UINT32_MAX / sizeof(ctx.specs[0]))
|
||||||
return BadLength;
|
return BadLength;
|
||||||
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
|
REQUEST_FIXED_SIZE(xXResQueryResourceBytesReq,
|
||||||
|
|
Loading…
Reference in New Issue