mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-23 23:30:02 +00:00
dbe: use REQUEST_HEAD_STRUCT and REQUEST_FIELD_* macros
Use the new macros to make request struct parsing / field swapping much easier. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
b8ca69d8b7
commit
08e62055ce
62
dbe/dbe.c
62
dbe/dbe.c
@@ -112,7 +112,7 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens)
|
||||
static int
|
||||
ProcDbeGetVersion(ClientPtr client)
|
||||
{
|
||||
REQUEST_SIZE_MATCH(xDbeGetVersionReq);
|
||||
X_REQUEST_HEAD_STRUCT(xDbeGetVersionReq);
|
||||
|
||||
xDbeGetVersionReply reply = {
|
||||
.majorVersion = DBE_MAJOR_VERSION,
|
||||
@@ -148,13 +148,9 @@ ProcDbeGetVersion(ClientPtr client)
|
||||
static int
|
||||
ProcDbeAllocateBackBufferName(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDbeAllocateBackBufferNameReq);
|
||||
REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
|
||||
|
||||
if (client->swapped) {
|
||||
swapl(&stuff->window);
|
||||
swapl(&stuff->buffer);
|
||||
}
|
||||
X_REQUEST_HEAD_STRUCT(xDbeAllocateBackBufferNameReq);
|
||||
X_REQUEST_FIELD_CARD32(window);
|
||||
X_REQUEST_FIELD_CARD32(buffer);
|
||||
|
||||
/* The window must be valid. */
|
||||
WindowPtr pWin;
|
||||
@@ -355,11 +351,8 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
|
||||
static int
|
||||
ProcDbeDeallocateBackBufferName(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDbeDeallocateBackBufferNameReq);
|
||||
REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
|
||||
|
||||
if (client->swapped)
|
||||
swapl(&stuff->buffer);
|
||||
X_REQUEST_HEAD_STRUCT(xDbeDeallocateBackBufferNameReq);
|
||||
X_REQUEST_FIELD_CARD32(buffer);
|
||||
|
||||
DbeWindowPrivPtr pDbeWindowPriv;
|
||||
|
||||
@@ -426,17 +419,18 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
|
||||
static int
|
||||
ProcDbeSwapBuffers(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDbeSwapBuffersReq);
|
||||
REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
|
||||
X_REQUEST_HEAD_AT_LEAST(xDbeSwapBuffersReq);
|
||||
X_REQUEST_FIELD_CARD32(n);
|
||||
|
||||
if (stuff->n == 0)
|
||||
return Success;
|
||||
|
||||
if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec))
|
||||
return BadLength;
|
||||
REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo));
|
||||
|
||||
if (client->swapped) {
|
||||
xDbeSwapInfo *pSwapInfo;
|
||||
|
||||
swapl(&stuff->n);
|
||||
if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec))
|
||||
return BadLength;
|
||||
REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo));
|
||||
|
||||
if (stuff->n != 0) {
|
||||
pSwapInfo = (xDbeSwapInfo *) stuff + 1;
|
||||
|
||||
@@ -453,15 +447,6 @@ ProcDbeSwapBuffers(ClientPtr client)
|
||||
|
||||
unsigned int nStuff = stuff->n; /* use local variable for performance. */
|
||||
|
||||
if (nStuff == 0) {
|
||||
REQUEST_SIZE_MATCH(xDbeSwapBuffersReq);
|
||||
return Success;
|
||||
}
|
||||
|
||||
if (nStuff > UINT32_MAX / sizeof(DbeSwapInfoRec))
|
||||
return BadAlloc;
|
||||
REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, nStuff * sizeof(xDbeSwapInfo));
|
||||
|
||||
/* Get to the swap info appended to the end of the request. */
|
||||
xDbeSwapInfo* dbeSwapInfo = (xDbeSwapInfo *) &stuff[1];
|
||||
|
||||
@@ -559,13 +544,9 @@ ProcDbeSwapBuffers(ClientPtr client)
|
||||
static int
|
||||
ProcDbeGetVisualInfo(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDbeGetVisualInfoReq);
|
||||
REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
|
||||
|
||||
if (client->swapped) {
|
||||
swapl(&stuff->n);
|
||||
SwapRestL(stuff);
|
||||
}
|
||||
X_REQUEST_HEAD_AT_LEAST(xDbeGetVisualInfoReq);
|
||||
X_REQUEST_FIELD_CARD32(n);
|
||||
X_REQUEST_REST_CARD32();
|
||||
|
||||
DbeScreenPrivPtr pDbeScreenPriv;
|
||||
Drawable *drawables;
|
||||
@@ -675,11 +656,8 @@ clearRpcBuf:
|
||||
static int
|
||||
ProcDbeGetBackBufferAttributes(ClientPtr client)
|
||||
{
|
||||
REQUEST(xDbeGetBackBufferAttributesReq);
|
||||
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
|
||||
|
||||
if (client->swapped)
|
||||
swapl(&stuff->buffer);
|
||||
X_REQUEST_HEAD_STRUCT(xDbeGetBackBufferAttributesReq);
|
||||
X_REQUEST_FIELD_CARD32(buffer);
|
||||
|
||||
DbeWindowPrivPtr pDbeWindowPriv;
|
||||
int rc;
|
||||
|
||||
Reference in New Issue
Block a user