mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 01:34:11 +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
56
dbe/dbe.c
56
dbe/dbe.c
@@ -112,7 +112,7 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens)
|
|||||||
static int
|
static int
|
||||||
ProcDbeGetVersion(ClientPtr client)
|
ProcDbeGetVersion(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST_SIZE_MATCH(xDbeGetVersionReq);
|
X_REQUEST_HEAD_STRUCT(xDbeGetVersionReq);
|
||||||
|
|
||||||
xDbeGetVersionReply reply = {
|
xDbeGetVersionReply reply = {
|
||||||
.majorVersion = DBE_MAJOR_VERSION,
|
.majorVersion = DBE_MAJOR_VERSION,
|
||||||
@@ -148,13 +148,9 @@ ProcDbeGetVersion(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDbeAllocateBackBufferName(ClientPtr client)
|
ProcDbeAllocateBackBufferName(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDbeAllocateBackBufferNameReq);
|
X_REQUEST_HEAD_STRUCT(xDbeAllocateBackBufferNameReq);
|
||||||
REQUEST_SIZE_MATCH(xDbeAllocateBackBufferNameReq);
|
X_REQUEST_FIELD_CARD32(window);
|
||||||
|
X_REQUEST_FIELD_CARD32(buffer);
|
||||||
if (client->swapped) {
|
|
||||||
swapl(&stuff->window);
|
|
||||||
swapl(&stuff->buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The window must be valid. */
|
/* The window must be valid. */
|
||||||
WindowPtr pWin;
|
WindowPtr pWin;
|
||||||
@@ -355,11 +351,8 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDbeDeallocateBackBufferName(ClientPtr client)
|
ProcDbeDeallocateBackBufferName(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDbeDeallocateBackBufferNameReq);
|
X_REQUEST_HEAD_STRUCT(xDbeDeallocateBackBufferNameReq);
|
||||||
REQUEST_SIZE_MATCH(xDbeDeallocateBackBufferNameReq);
|
X_REQUEST_FIELD_CARD32(buffer);
|
||||||
|
|
||||||
if (client->swapped)
|
|
||||||
swapl(&stuff->buffer);
|
|
||||||
|
|
||||||
DbeWindowPrivPtr pDbeWindowPriv;
|
DbeWindowPrivPtr pDbeWindowPriv;
|
||||||
|
|
||||||
@@ -426,17 +419,18 @@ ProcDbeDeallocateBackBufferName(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDbeSwapBuffers(ClientPtr client)
|
ProcDbeSwapBuffers(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDbeSwapBuffersReq);
|
X_REQUEST_HEAD_AT_LEAST(xDbeSwapBuffersReq);
|
||||||
REQUEST_AT_LEAST_SIZE(xDbeSwapBuffersReq);
|
X_REQUEST_FIELD_CARD32(n);
|
||||||
|
|
||||||
if (client->swapped) {
|
if (stuff->n == 0)
|
||||||
xDbeSwapInfo *pSwapInfo;
|
return Success;
|
||||||
|
|
||||||
swapl(&stuff->n);
|
|
||||||
if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec))
|
if (stuff->n > UINT32_MAX / sizeof(DbeSwapInfoRec))
|
||||||
return BadLength;
|
return BadLength;
|
||||||
REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo));
|
REQUEST_FIXED_SIZE(xDbeSwapBuffersReq, stuff->n * sizeof(xDbeSwapInfo));
|
||||||
|
|
||||||
|
if (client->swapped) {
|
||||||
|
xDbeSwapInfo *pSwapInfo;
|
||||||
if (stuff->n != 0) {
|
if (stuff->n != 0) {
|
||||||
pSwapInfo = (xDbeSwapInfo *) stuff + 1;
|
pSwapInfo = (xDbeSwapInfo *) stuff + 1;
|
||||||
|
|
||||||
@@ -453,15 +447,6 @@ ProcDbeSwapBuffers(ClientPtr client)
|
|||||||
|
|
||||||
unsigned int nStuff = stuff->n; /* use local variable for performance. */
|
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. */
|
/* Get to the swap info appended to the end of the request. */
|
||||||
xDbeSwapInfo* dbeSwapInfo = (xDbeSwapInfo *) &stuff[1];
|
xDbeSwapInfo* dbeSwapInfo = (xDbeSwapInfo *) &stuff[1];
|
||||||
|
|
||||||
@@ -559,13 +544,9 @@ ProcDbeSwapBuffers(ClientPtr client)
|
|||||||
static int
|
static int
|
||||||
ProcDbeGetVisualInfo(ClientPtr client)
|
ProcDbeGetVisualInfo(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDbeGetVisualInfoReq);
|
X_REQUEST_HEAD_AT_LEAST(xDbeGetVisualInfoReq);
|
||||||
REQUEST_AT_LEAST_SIZE(xDbeGetVisualInfoReq);
|
X_REQUEST_FIELD_CARD32(n);
|
||||||
|
X_REQUEST_REST_CARD32();
|
||||||
if (client->swapped) {
|
|
||||||
swapl(&stuff->n);
|
|
||||||
SwapRestL(stuff);
|
|
||||||
}
|
|
||||||
|
|
||||||
DbeScreenPrivPtr pDbeScreenPriv;
|
DbeScreenPrivPtr pDbeScreenPriv;
|
||||||
Drawable *drawables;
|
Drawable *drawables;
|
||||||
@@ -675,11 +656,8 @@ clearRpcBuf:
|
|||||||
static int
|
static int
|
||||||
ProcDbeGetBackBufferAttributes(ClientPtr client)
|
ProcDbeGetBackBufferAttributes(ClientPtr client)
|
||||||
{
|
{
|
||||||
REQUEST(xDbeGetBackBufferAttributesReq);
|
X_REQUEST_HEAD_STRUCT(xDbeGetBackBufferAttributesReq);
|
||||||
REQUEST_SIZE_MATCH(xDbeGetBackBufferAttributesReq);
|
X_REQUEST_FIELD_CARD32(buffer);
|
||||||
|
|
||||||
if (client->swapped)
|
|
||||||
swapl(&stuff->buffer);
|
|
||||||
|
|
||||||
DbeWindowPrivPtr pDbeWindowPriv;
|
DbeWindowPrivPtr pDbeWindowPriv;
|
||||||
int rc;
|
int rc;
|
||||||
|
|||||||
Reference in New Issue
Block a user