Bug Summary

File:glx/single2swap.c
Location:line 185, column 13
Description:Value stored to 'nitems' is never read

Annotated Source Code

1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 *
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
29 */
30
31#ifdef HAVE_DIX_CONFIG_H1
32#include <dix-config.h>
33#endif
34
35#include "glxserver.h"
36#include "glxutil.h"
37#include "glxext.h"
38#include "indirect_dispatch.h"
39#include "unpack.h"
40
41int
42__glXDispSwap_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc)
43{
44 ClientPtr client = cl->client;
45 GLsizei size;
46 GLenum type;
47
48 __GLX_DECLARE_SWAP_VARIABLESGLbyte sw;
49 __GLXcontext *cx;
50 int error;
51
52 REQUEST_FIXED_SIZE(xGLXSingleReq, 8)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((8) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (8) + 3) >> 2) != (uint64_t) client
->req_len)) return(16)
;
53
54 __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag)sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3] = sw; sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2] = sw;
;
55 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
56 if (!cx) {
57 return error;
58 }
59
60 pc += __GLX_SINGLE_HDR_SIZE8;
61 __GLX_SWAP_INT(pc + 0)sw = ((GLbyte *)(pc + 0))[0]; ((GLbyte *)(pc + 0))[0] = ((GLbyte
*)(pc + 0))[3]; ((GLbyte *)(pc + 0))[3] = sw; sw = ((GLbyte *
)(pc + 0))[1]; ((GLbyte *)(pc + 0))[1] = ((GLbyte *)(pc + 0))
[2]; ((GLbyte *)(pc + 0))[2] = sw;
;
62 __GLX_SWAP_INT(pc + 4)sw = ((GLbyte *)(pc + 4))[0]; ((GLbyte *)(pc + 4))[0] = ((GLbyte
*)(pc + 4))[3]; ((GLbyte *)(pc + 4))[3] = sw; sw = ((GLbyte *
)(pc + 4))[1]; ((GLbyte *)(pc + 4))[1] = ((GLbyte *)(pc + 4))
[2]; ((GLbyte *)(pc + 4))[2] = sw;
;
63 size = *(GLsizei *) (pc + 0);
64 type = *(GLenum *) (pc + 4);
65 if (cx->feedbackBufSize < size) {
66 cx->feedbackBuf = reallocarrayxreallocarray(cx->feedbackBuf,
67 (size_t) size, __GLX_SIZE_FLOAT324);
68 if (!cx->feedbackBuf) {
69 cl->client->errorValue = size;
70 return BadAlloc11;
71 }
72 cx->feedbackBufSize = size;
73 }
74 glFeedbackBuffer(size, type, cx->feedbackBuf);
75 return Success0;
76}
77
78int
79__glXDispSwap_SelectBuffer(__GLXclientState * cl, GLbyte * pc)
80{
81 ClientPtr client = cl->client;
82 __GLXcontext *cx;
83 GLsizei size;
84
85 __GLX_DECLARE_SWAP_VARIABLESGLbyte sw;
86 int error;
87
88 REQUEST_FIXED_SIZE(xGLXSingleReq, 4)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((4) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (4) + 3) >> 2) != (uint64_t) client
->req_len)) return(16)
;
89
90 __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag)sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3] = sw; sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2] = sw;
;
91 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
92 if (!cx) {
93 return error;
94 }
95
96 pc += __GLX_SINGLE_HDR_SIZE8;
97 __GLX_SWAP_INT(pc + 0)sw = ((GLbyte *)(pc + 0))[0]; ((GLbyte *)(pc + 0))[0] = ((GLbyte
*)(pc + 0))[3]; ((GLbyte *)(pc + 0))[3] = sw; sw = ((GLbyte *
)(pc + 0))[1]; ((GLbyte *)(pc + 0))[1] = ((GLbyte *)(pc + 0))
[2]; ((GLbyte *)(pc + 0))[2] = sw;
;
98 size = *(GLsizei *) (pc + 0);
99 if (cx->selectBufSize < size) {
100 cx->selectBuf = reallocarrayxreallocarray(cx->selectBuf,
101 (size_t) size, __GLX_SIZE_CARD324);
102 if (!cx->selectBuf) {
103 cl->client->errorValue = size;
104 return BadAlloc11;
105 }
106 cx->selectBufSize = size;
107 }
108 glSelectBuffer(size, cx->selectBuf);
109 return Success0;
110}
111
112int
113__glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc)
114{
115 ClientPtr client = cl->client;
116 __GLXcontext *cx;
117 xGLXRenderModeReply reply;
118 GLint nitems = 0, retBytes = 0, retval, newModeCheck;
119 GLubyte *retBuffer = NULL((void*)0);
120 GLenum newMode;
121
122 __GLX_DECLARE_SWAP_VARIABLESGLbyte sw;
123 __GLX_DECLARE_SWAP_ARRAY_VARIABLESGLbyte *swapPC; GLbyte *swapEnd;
124 int error;
125
126 REQUEST_FIXED_SIZE(xGLXSingleReq, 4)if (((sizeof(xGLXSingleReq) >> 2) > client->req_len
) || (((4) >> 2) >= client->req_len) || ((((uint64_t
) sizeof(xGLXSingleReq) + (4) + 3) >> 2) != (uint64_t) client
->req_len)) return(16)
;
127
128 __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag)sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3] = sw; sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2] = sw;
;
129 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
130 if (!cx) {
131 return error;
132 }
133
134 pc += __GLX_SINGLE_HDR_SIZE8;
135 __GLX_SWAP_INT(pc)sw = ((GLbyte *)(pc))[0]; ((GLbyte *)(pc))[0] = ((GLbyte *)(pc
))[3]; ((GLbyte *)(pc))[3] = sw; sw = ((GLbyte *)(pc))[1]; ((
GLbyte *)(pc))[1] = ((GLbyte *)(pc))[2]; ((GLbyte *)(pc))[2] =
sw;
;
136 newMode = *(GLenum *) pc;
137 retval = glRenderMode(newMode);
138
139 /* Check that render mode worked */
140 glGetIntegerv(GL_RENDER_MODE0x0C40, &newModeCheck);
141 if (newModeCheck != newMode) {
142 /* Render mode change failed. Bail */
143 newMode = newModeCheck;
144 goto noChangeAllowed;
145 }
146
147 /*
148 ** Render mode might have still failed if we get here. But in this
149 ** case we can't really tell, nor does it matter. If it did fail, it
150 ** will return 0, and thus we won't send any data across the wire.
151 */
152
153 switch (cx->renderMode) {
154 case GL_RENDER0x1C00:
155 cx->renderMode = newMode;
156 break;
157 case GL_FEEDBACK0x1C01:
158 if (retval < 0) {
159 /* Overflow happened. Copy the entire buffer */
160 nitems = cx->feedbackBufSize;
161 }
162 else {
163 nitems = retval;
164 }
165 retBytes = nitems * __GLX_SIZE_FLOAT324;
166 retBuffer = (GLubyte *) cx->feedbackBuf;
167 __GLX_SWAP_FLOAT_ARRAY((GLbyte *) retBuffer, nitems)swapPC = ((GLbyte *)((GLbyte *) retBuffer)); swapEnd = ((GLbyte
*)((GLbyte *) retBuffer)) + (nitems)*4; while (swapPC < swapEnd
) { sw = ((GLbyte *)(swapPC))[0]; ((GLbyte *)(swapPC))[0] = (
(GLbyte *)(swapPC))[3]; ((GLbyte *)(swapPC))[3] = sw; sw = ((
GLbyte *)(swapPC))[1]; ((GLbyte *)(swapPC))[1] = ((GLbyte *)(
swapPC))[2]; ((GLbyte *)(swapPC))[2] = sw;; swapPC += 4; }
;
168 cx->renderMode = newMode;
169 break;
170 case GL_SELECT0x1C02:
171 if (retval < 0) {
172 /* Overflow happened. Copy the entire buffer */
173 nitems = cx->selectBufSize;
174 }
175 else {
176 GLuint *bp = cx->selectBuf;
177 GLint i;
178
179 /*
180 ** Figure out how many bytes of data need to be sent. Parse
181 ** the selection buffer to determine this fact as the
182 ** return value is the number of hits, not the number of
183 ** items in the buffer.
184 */
185 nitems = 0;
Value stored to 'nitems' is never read
186 i = retval;
187 while (--i >= 0) {
188 GLuint n;
189
190 /* Parse select data for this hit */
191 n = *bp;
192 bp += 3 + n;
193 }
194 nitems = bp - cx->selectBuf;
195 }
196 retBytes = nitems * __GLX_SIZE_CARD324;
197 retBuffer = (GLubyte *) cx->selectBuf;
198 __GLX_SWAP_INT_ARRAY((GLbyte *) retBuffer, nitems)swapPC = ((GLbyte *)((GLbyte *) retBuffer)); swapEnd = ((GLbyte
*)((GLbyte *) retBuffer)) + (nitems)*4; while (swapPC < swapEnd
) { sw = ((GLbyte *)(swapPC))[0]; ((GLbyte *)(swapPC))[0] = (
(GLbyte *)(swapPC))[3]; ((GLbyte *)(swapPC))[3] = sw; sw = ((
GLbyte *)(swapPC))[1]; ((GLbyte *)(swapPC))[1] = ((GLbyte *)(
swapPC))[2]; ((GLbyte *)(swapPC))[2] = sw;; swapPC += 4; }
;
199 cx->renderMode = newMode;
200 break;
201 }
202
203 /*
204 ** First reply is the number of elements returned in the feedback or
205 ** selection array, as per the API for glRenderMode itself.
206 */
207 noChangeAllowed:;
208 reply = (xGLXRenderModeReply) {
209 .type = X_Reply1,
210 .sequenceNumber = client->sequence,
211 .length = nitems,
212 .retval = retval,
213 .size = nitems,
214 .newMode = newMode
215 };
216 __GLX_SWAP_SHORT(&reply.sequenceNumber)sw = ((GLbyte *)(&reply.sequenceNumber))[0]; ((GLbyte *)(
&reply.sequenceNumber))[0] = ((GLbyte *)(&reply.sequenceNumber
))[1]; ((GLbyte *)(&reply.sequenceNumber))[1] = sw;
;
217 __GLX_SWAP_INT(&reply.length)sw = ((GLbyte *)(&reply.length))[0]; ((GLbyte *)(&reply
.length))[0] = ((GLbyte *)(&reply.length))[3]; ((GLbyte *
)(&reply.length))[3] = sw; sw = ((GLbyte *)(&reply.length
))[1]; ((GLbyte *)(&reply.length))[1] = ((GLbyte *)(&
reply.length))[2]; ((GLbyte *)(&reply.length))[2] = sw;
;
218 __GLX_SWAP_INT(&reply.retval)sw = ((GLbyte *)(&reply.retval))[0]; ((GLbyte *)(&reply
.retval))[0] = ((GLbyte *)(&reply.retval))[3]; ((GLbyte *
)(&reply.retval))[3] = sw; sw = ((GLbyte *)(&reply.retval
))[1]; ((GLbyte *)(&reply.retval))[1] = ((GLbyte *)(&
reply.retval))[2]; ((GLbyte *)(&reply.retval))[2] = sw;
;
219 __GLX_SWAP_INT(&reply.size)sw = ((GLbyte *)(&reply.size))[0]; ((GLbyte *)(&reply
.size))[0] = ((GLbyte *)(&reply.size))[3]; ((GLbyte *)(&
reply.size))[3] = sw; sw = ((GLbyte *)(&reply.size))[1]; (
(GLbyte *)(&reply.size))[1] = ((GLbyte *)(&reply.size
))[2]; ((GLbyte *)(&reply.size))[2] = sw;
;
220 __GLX_SWAP_INT(&reply.newMode)sw = ((GLbyte *)(&reply.newMode))[0]; ((GLbyte *)(&reply
.newMode))[0] = ((GLbyte *)(&reply.newMode))[3]; ((GLbyte
*)(&reply.newMode))[3] = sw; sw = ((GLbyte *)(&reply
.newMode))[1]; ((GLbyte *)(&reply.newMode))[1] = ((GLbyte
*)(&reply.newMode))[2]; ((GLbyte *)(&reply.newMode))
[2] = sw;
;
221 WriteToClient(client, sz_xGLXRenderModeReply32, &reply);
222 if (retBytes) {
223 WriteToClient(client, retBytes, retBuffer);
224 }
225 return Success0;
226}
227
228int
229__glXDispSwap_Flush(__GLXclientState * cl, GLbyte * pc)
230{
231 ClientPtr client = cl->client;
232 __GLXcontext *cx;
233 int error;
234
235 __GLX_DECLARE_SWAP_VARIABLESGLbyte sw;
236
237 REQUEST_SIZE_MATCH(xGLXSingleReq)if ((sizeof(xGLXSingleReq) >> 2) != client->req_len)
return(16)
;
238
239 __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag)sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3] = sw; sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2] = sw;
;
240 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
241 if (!cx) {
242 return error;
243 }
244
245 glFlush();
246 return Success0;
247}
248
249int
250__glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc)
251{
252 ClientPtr client = cl->client;
253 __GLXcontext *cx;
254 int error;
255
256 __GLX_DECLARE_SWAP_VARIABLESGLbyte sw;
257
258 REQUEST_SIZE_MATCH(xGLXSingleReq)if ((sizeof(xGLXSingleReq) >> 2) != client->req_len)
return(16)
;
259
260 __GLX_SWAP_INT(&((xGLXSingleReq *) pc)->contextTag)sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag))
[0] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag)
)[3] = sw; sw = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[1] = ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2]; ((GLbyte *)(&((xGLXSingleReq *) pc)->contextTag
))[2] = sw;
;
261 cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error);
262 if (!cx) {
263 return error;
264 }
265
266 /* Do a local glFinish */
267 glFinish();
268
269 /* Send empty reply packet to indicate finish is finished */
270 __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply
.type = 1; __glXReply.sequenceNumber = client->sequence;
;
271 __GLX_PUT_RETVAL(0)__glXReply.retval = (0);;
272 __GLX_SWAP_REPLY_HEADER()sw = ((GLbyte *)(&__glXReply.sequenceNumber))[0]; ((GLbyte
*)(&__glXReply.sequenceNumber))[0] = ((GLbyte *)(&__glXReply
.sequenceNumber))[1]; ((GLbyte *)(&__glXReply.sequenceNumber
))[1] = sw;; sw = ((GLbyte *)(&__glXReply.length))[0]; ((
GLbyte *)(&__glXReply.length))[0] = ((GLbyte *)(&__glXReply
.length))[3]; ((GLbyte *)(&__glXReply.length))[3] = sw; sw
= ((GLbyte *)(&__glXReply.length))[1]; ((GLbyte *)(&
__glXReply.length))[1] = ((GLbyte *)(&__glXReply.length))
[2]; ((GLbyte *)(&__glXReply.length))[2] = sw;;
;
273 __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);;
274
275 return Success0;
276}
277
278int
279__glXDispSwap_GetString(__GLXclientState * cl, GLbyte * pc)
280{
281 return DoGetString(cl, pc, GL_TRUE0x1);
282}