aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/glx/glxcmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/glx/glxcmds.c')
-rw-r--r--xorg-server/glx/glxcmds.c127
1 files changed, 65 insertions, 62 deletions
diff --git a/xorg-server/glx/glxcmds.c b/xorg-server/glx/glxcmds.c
index efa4aecb2..fc2bb35bd 100644
--- a/xorg-server/glx/glxcmds.c
+++ b/xorg-server/glx/glxcmds.c
@@ -31,6 +31,7 @@
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
+#include "glheader.h"
#include <string.h>
#include <assert.h>
@@ -496,7 +497,7 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client,
return NULL;
}
- if (pDraw->pScreen != glxc->pGlxScreen->pScreen) {
+ if (!glxc || pDraw->pScreen != glxc->pGlxScreen->pScreen) {
client->errorValue = pDraw->pScreen->myNum;
*error = BadMatch;
return NULL;
@@ -509,9 +510,11 @@ __glXGetDrawable(__GLXcontext * glxc, GLXDrawable drawId, ClientPtr client,
pDraw, drawId,
GLX_DRAWABLE_WINDOW,
drawId, glxc->config);
- if (!pGlxDraw) {
- *error = BadAlloc;
- return NULL;
+ if (!pGlxDraw)
+ {
+ client->errorValue = drawId;
+ *error = BadMatch;
+ return NULL;
}
/* since we are creating the drawablePrivate, drawId should be new */
@@ -651,12 +654,12 @@ DoMakeCurrent(__GLXclientState * cl,
StopUsingContext(prevglxc);
- reply = (xGLXMakeCurrentReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .contextTag = 0
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = 0;
+ reply.contextTag = 0;
+
if (glxc) {
StartUsingContext(cl, glxc);
@@ -722,12 +725,12 @@ __glXDisp_IsDirect(__GLXclientState * cl, GLbyte * pc)
if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
return err;
- reply = (xGLXIsDirectReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .isDirect = glxc->isDirect
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = 0;
+ reply.isDirect = glxc->isDirect;
+
if (client->swapped) {
__glXSwapIsDirectReply(client, &reply);
@@ -759,13 +762,13 @@ __glXDisp_QueryVersion(__GLXclientState * cl, GLbyte * pc)
** client if it wants to work with older clients; however, in this
** implementation the server just returns its version number.
*/
- reply = (xGLXQueryVersionReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = 0,
- .majorVersion = glxMajorVersion,
- .minorVersion = glxMinorVersion
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = 0;
+ reply.majorVersion = glxMajorVersion;
+ reply.minorVersion = glxMinorVersion;
+
if (client->swapped) {
__glXSwapQueryVersionReply(client, &reply);
@@ -939,14 +942,14 @@ __glXDisp_GetVisualConfigs(__GLXclientState * cl, GLbyte * pc)
if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
return err;
- reply = (xGLXGetVisualConfigsReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = (pGlxScreen->numVisuals *
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = (pGlxScreen->numVisuals *
__GLX_SIZE_CARD32 * GLX_VIS_CONFIG_TOTAL) >> 2,
- .numVisuals = pGlxScreen->numVisuals,
- .numProps = GLX_VIS_CONFIG_TOTAL
- };
+ reply.numVisuals = pGlxScreen->numVisuals;
+ reply.numProps = GLX_VIS_CONFIG_TOTAL;
+
if (client->swapped) {
__GLX_SWAP_SHORT(&reply.sequenceNumber);
@@ -1054,13 +1057,13 @@ DoGetFBConfigs(__GLXclientState * cl, unsigned screen)
if (!validGlxScreen(cl->client, screen, &pGlxScreen, &err))
return err;
- reply = (xGLXGetFBConfigsReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs,
- .numFBConfigs = pGlxScreen->numFBConfigs,
- .numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = __GLX_FBCONFIG_ATTRIBS_LENGTH * pGlxScreen->numFBConfigs;
+ reply.numFBConfigs = pGlxScreen->numFBConfigs;
+ reply.numAttribs = __GLX_TOTAL_FBCONFIG_ATTRIBS;
+
if (client->swapped) {
__GLX_SWAP_SHORT(&reply.sequenceNumber);
@@ -1697,7 +1700,7 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
ClientPtr client = cl->client;
__GLXcontext *ctx;
xGLXQueryContextInfoEXTReply reply;
- int nProps = 3;
+ #define nProps 3
int sendBuf[nProps * 2];
int nReplyBytes;
int err;
@@ -1705,12 +1708,12 @@ DoQueryContext(__GLXclientState * cl, GLXContextID gcId)
if (!validGlxContext(cl->client, gcId, DixReadAccess, &ctx, &err))
return err;
- reply = (xGLXQueryContextInfoEXTReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = nProps << 1,
- .n = nProps
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = nProps << 1;
+ reply.n = nProps;
+
nReplyBytes = reply.length << 2;
sendBuf[0] = GLX_SHARE_CONTEXT_EXT;
@@ -1932,12 +1935,12 @@ DoGetDrawableAttributes(__GLXclientState * cl, XID drawId)
numAttribs++;
}
- reply = (xGLXGetDrawableAttributesReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = numAttribs << 1,
- .numAttribs = numAttribs
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = numAttribs << 1;
+ reply.numAttribs = numAttribs;
+
if (client->swapped) {
__glXSwapGetDrawableAttributesReply(client, &reply, attributes);
@@ -2362,12 +2365,12 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc)
n = strlen(pGlxScreen->GLXextensions) + 1;
length = __GLX_PAD(n) >> 2;
- reply = (xGLXQueryExtensionsStringReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = length,
- .n = n
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = n;
+
/* Allocate buffer to make sure it's a multiple of 4 bytes big. */
buf = calloc(length, 4);
@@ -2425,12 +2428,12 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc)
n = strlen(ptr) + 1;
length = __GLX_PAD(n) >> 2;
- reply = (xGLXQueryServerStringReply) {
- .type = X_Reply,
- .sequenceNumber = client->sequence,
- .length = length,
- .n = n
- };
+
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ reply.length = length;
+ reply.n = n;
+
buf = calloc(length, 4);
if (buf == NULL) {