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