File: | glx/single2swap.c |
Location: | line 188, column 13 |
Description: | Value stored to 'nitems' is never read |
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 | |
41 | int |
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 = (GLfloat *) realloc(cx->feedbackBuf, |
67 | (size_t) size |
68 | * __GLX_SIZE_FLOAT324); |
69 | if (!cx->feedbackBuf) { |
70 | cl->client->errorValue = size; |
71 | return BadAlloc11; |
72 | } |
73 | cx->feedbackBufSize = size; |
74 | } |
75 | glFeedbackBuffer(size, type, cx->feedbackBuf); |
76 | cx->hasUnflushedCommands = GL_TRUE0x1; |
77 | return Success0; |
78 | } |
79 | |
80 | int |
81 | __glXDispSwap_SelectBuffer(__GLXclientState * cl, GLbyte * pc) |
82 | { |
83 | ClientPtr client = cl->client; |
84 | __GLXcontext *cx; |
85 | GLsizei size; |
86 | |
87 | __GLX_DECLARE_SWAP_VARIABLESGLbyte sw; |
88 | int error; |
89 | |
90 | 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); |
91 | |
92 | __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;; |
93 | cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error); |
94 | if (!cx) { |
95 | return error; |
96 | } |
97 | |
98 | pc += __GLX_SINGLE_HDR_SIZE8; |
99 | __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;; |
100 | size = *(GLsizei *) (pc + 0); |
101 | if (cx->selectBufSize < size) { |
102 | cx->selectBuf = (GLuint *) realloc(cx->selectBuf, |
103 | (size_t) size * __GLX_SIZE_CARD324); |
104 | if (!cx->selectBuf) { |
105 | cl->client->errorValue = size; |
106 | return BadAlloc11; |
107 | } |
108 | cx->selectBufSize = size; |
109 | } |
110 | glSelectBuffer(size, cx->selectBuf); |
111 | cx->hasUnflushedCommands = GL_TRUE0x1; |
112 | return Success0; |
113 | } |
114 | |
115 | int |
116 | __glXDispSwap_RenderMode(__GLXclientState * cl, GLbyte * pc) |
117 | { |
118 | ClientPtr client = cl->client; |
119 | __GLXcontext *cx; |
120 | xGLXRenderModeReply reply; |
121 | GLint nitems = 0, retBytes = 0, retval, newModeCheck; |
122 | GLubyte *retBuffer = NULL((void*)0); |
123 | GLenum newMode; |
124 | |
125 | __GLX_DECLARE_SWAP_VARIABLESGLbyte sw; |
126 | __GLX_DECLARE_SWAP_ARRAY_VARIABLESGLbyte *swapPC; GLbyte *swapEnd; |
127 | int error; |
128 | |
129 | 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); |
130 | |
131 | __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;; |
132 | cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error); |
133 | if (!cx) { |
134 | return error; |
135 | } |
136 | |
137 | pc += __GLX_SINGLE_HDR_SIZE8; |
138 | __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;; |
139 | newMode = *(GLenum *) pc; |
140 | retval = glRenderMode(newMode); |
141 | |
142 | /* Check that render mode worked */ |
143 | glGetIntegerv(GL_RENDER_MODE0x0C40, &newModeCheck); |
144 | if (newModeCheck != newMode) { |
145 | /* Render mode change failed. Bail */ |
146 | newMode = newModeCheck; |
147 | goto noChangeAllowed; |
148 | } |
149 | |
150 | /* |
151 | ** Render mode might have still failed if we get here. But in this |
152 | ** case we can't really tell, nor does it matter. If it did fail, it |
153 | ** will return 0, and thus we won't send any data across the wire. |
154 | */ |
155 | |
156 | switch (cx->renderMode) { |
157 | case GL_RENDER0x1C00: |
158 | cx->renderMode = newMode; |
159 | break; |
160 | case GL_FEEDBACK0x1C01: |
161 | if (retval < 0) { |
162 | /* Overflow happened. Copy the entire buffer */ |
163 | nitems = cx->feedbackBufSize; |
164 | } |
165 | else { |
166 | nitems = retval; |
167 | } |
168 | retBytes = nitems * __GLX_SIZE_FLOAT324; |
169 | retBuffer = (GLubyte *) cx->feedbackBuf; |
170 | __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; }; |
171 | cx->renderMode = newMode; |
172 | break; |
173 | case GL_SELECT0x1C02: |
174 | if (retval < 0) { |
175 | /* Overflow happened. Copy the entire buffer */ |
176 | nitems = cx->selectBufSize; |
177 | } |
178 | else { |
179 | GLuint *bp = cx->selectBuf; |
180 | GLint i; |
181 | |
182 | /* |
183 | ** Figure out how many bytes of data need to be sent. Parse |
184 | ** the selection buffer to determine this fact as the |
185 | ** return value is the number of hits, not the number of |
186 | ** items in the buffer. |
187 | */ |
188 | nitems = 0; |
Value stored to 'nitems' is never read | |
189 | i = retval; |
190 | while (--i >= 0) { |
191 | GLuint n; |
192 | |
193 | /* Parse select data for this hit */ |
194 | n = *bp; |
195 | bp += 3 + n; |
196 | } |
197 | nitems = bp - cx->selectBuf; |
198 | } |
199 | retBytes = nitems * __GLX_SIZE_CARD324; |
200 | retBuffer = (GLubyte *) cx->selectBuf; |
201 | __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; }; |
202 | cx->renderMode = newMode; |
203 | break; |
204 | } |
205 | |
206 | /* |
207 | ** First reply is the number of elements returned in the feedback or |
208 | ** selection array, as per the API for glRenderMode itself. |
209 | */ |
210 | noChangeAllowed:; |
211 | reply = (xGLXRenderModeReply) { |
212 | .type = X_Reply1, |
213 | .sequenceNumber = client->sequence, |
214 | .length = nitems, |
215 | .retval = retval, |
216 | .size = nitems, |
217 | .newMode = newMode |
218 | }; |
219 | __GLX_SWAP_SHORT(&reply.sequenceNumber)sw = ((GLbyte *)(&reply.sequenceNumber))[0]; ((GLbyte *)( &reply.sequenceNumber))[0] = ((GLbyte *)(&reply.sequenceNumber ))[1]; ((GLbyte *)(&reply.sequenceNumber))[1] = sw;; |
220 | __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;; |
221 | __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;; |
222 | __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;; |
223 | __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;; |
224 | WriteToClient(client, sz_xGLXRenderModeReply32, &reply); |
225 | if (retBytes) { |
226 | WriteToClient(client, retBytes, retBuffer); |
227 | } |
228 | return Success0; |
229 | } |
230 | |
231 | int |
232 | __glXDispSwap_Flush(__GLXclientState * cl, GLbyte * pc) |
233 | { |
234 | ClientPtr client = cl->client; |
235 | __GLXcontext *cx; |
236 | int error; |
237 | |
238 | __GLX_DECLARE_SWAP_VARIABLESGLbyte sw; |
239 | |
240 | REQUEST_SIZE_MATCH(xGLXSingleReq)if ((sizeof(xGLXSingleReq) >> 2) != client->req_len) return(16); |
241 | |
242 | __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;; |
243 | cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error); |
244 | if (!cx) { |
245 | return error; |
246 | } |
247 | |
248 | glFlush(); |
249 | cx->hasUnflushedCommands = GL_FALSE0x0; |
250 | return Success0; |
251 | } |
252 | |
253 | int |
254 | __glXDispSwap_Finish(__GLXclientState * cl, GLbyte * pc) |
255 | { |
256 | ClientPtr client = cl->client; |
257 | __GLXcontext *cx; |
258 | int error; |
259 | |
260 | __GLX_DECLARE_SWAP_VARIABLESGLbyte sw; |
261 | |
262 | REQUEST_SIZE_MATCH(xGLXSingleReq)if ((sizeof(xGLXSingleReq) >> 2) != client->req_len) return(16); |
263 | |
264 | __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;; |
265 | cx = __glXForceCurrent(cl, __GLX_GET_SINGLE_CONTEXT_TAG(pc)(((xGLXSingleReq*)pc)->contextTag), &error); |
266 | if (!cx) { |
267 | return error; |
268 | } |
269 | |
270 | /* Do a local glFinish */ |
271 | glFinish(); |
272 | cx->hasUnflushedCommands = GL_FALSE0x0; |
273 | |
274 | /* Send empty reply packet to indicate finish is finished */ |
275 | __GLX_BEGIN_REPLY(0)__glXReply.length = (((0)+3) & (GLuint)~3) >> 2; __glXReply .type = 1; __glXReply.sequenceNumber = client->sequence;; |
276 | __GLX_PUT_RETVAL(0)__glXReply.retval = (0);; |
277 | __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;;; |
278 | __GLX_SEND_HEADER()WriteToClient (client, 32, &__glXReply);; |
279 | |
280 | return Success0; |
281 | } |
282 | |
283 | int |
284 | __glXDispSwap_GetString(__GLXclientState * cl, GLbyte * pc) |
285 | { |
286 | return DoGetString(cl, pc, GL_TRUE0x1); |
287 | } |