File: | src/xkb/XKBleds.c |
Location: | line 109, column 9 |
Description: | Value stored to 'left' is never read |
1 | /************************************************************ |
2 | Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. |
3 | |
4 | Permission to use, copy, modify, and distribute this |
5 | software and its documentation for any purpose and without |
6 | fee is hereby granted, provided that the above copyright |
7 | notice appear in all copies and that both that copyright |
8 | notice and this permission notice appear in supporting |
9 | documentation, and that the name of Silicon Graphics not be |
10 | used in advertising or publicity pertaining to distribution |
11 | of the software without specific prior written permission. |
12 | Silicon Graphics makes no representation about the suitability |
13 | of this software for any purpose. It is provided "as is" |
14 | without any express or implied warranty. |
15 | |
16 | SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
17 | SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY |
18 | AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON |
19 | GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
20 | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
21 | DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
22 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
23 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
24 | |
25 | ********************************************************/ |
26 | |
27 | #define NEED_MAP_READERS |
28 | #ifdef HAVE_CONFIG_H1 |
29 | #include <config.h> |
30 | #endif |
31 | #include "Xlibint.h" |
32 | #include <X11/extensions/XKBproto.h> |
33 | #include "XKBlibint.h" |
34 | |
35 | Statusint |
36 | XkbGetIndicatorState(Display *dpy, unsigned deviceSpec, unsigned *pStateRtrn) |
37 | { |
38 | register xkbGetIndicatorStateReq *req; |
39 | xkbGetIndicatorStateReply rep; |
40 | XkbInfoPtr xkbi; |
41 | Boolint ok; |
42 | |
43 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
44 | (!dpy->xkb_info && !XkbUseExtension(dpy, NULL((void*)0), NULL((void*)0)))) |
45 | return BadAccess10; |
46 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
47 | xkbi = dpy->xkb_info; |
48 | GetReq(kbGetIndicatorState, req)req = (xkbGetIndicatorStateReq *) _XGetRequest(dpy, 12, 8); |
49 | req->reqType = xkbi->codes->major_opcode; |
50 | req->xkbReqType = X_kbGetIndicatorState12; |
51 | req->deviceSpec = deviceSpec; |
52 | ok = _XReply(dpy, (xReply *) &rep, 0, xFalse0); |
53 | if (ok && (pStateRtrn != NULL((void*)0))) |
54 | *pStateRtrn = rep.state; |
55 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
56 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
57 | return (ok ? Success0 : BadImplementation17); |
58 | } |
59 | |
60 | Statusint |
61 | _XkbReadGetIndicatorMapReply(Display *dpy, |
62 | xkbGetIndicatorMapReply *rep, |
63 | XkbDescPtr xkb, |
64 | int *nread_rtrn) |
65 | { |
66 | XkbIndicatorPtr leds; |
67 | XkbReadBufferRec buf; |
68 | |
69 | if ((!xkb->indicators) && (XkbAllocIndicatorMaps(xkb) != Success0)) |
70 | return BadAlloc11; |
71 | leds = xkb->indicators; |
72 | |
73 | leds->phys_indicators = rep->realIndicators; |
74 | if (rep->length > 0) { |
75 | register int left; |
76 | |
77 | if (!_XkbInitReadBuffer(dpy, &buf, (int) rep->length * 4)) |
78 | return BadAlloc11; |
79 | if (nread_rtrn) |
80 | *nread_rtrn = (int) rep->length * 4; |
81 | if (rep->which) { |
82 | register int i, bit; |
83 | |
84 | left = (int) rep->which; |
85 | for (i = 0, bit = 1; (i < XkbNumIndicators32) && (left); |
86 | i++, bit <<= 1) { |
87 | if (left & bit) { |
88 | xkbIndicatorMapWireDesc *wire; |
89 | |
90 | wire = (xkbIndicatorMapWireDesc *) |
91 | _XkbGetReadBufferPtr(&buf, |
92 | SIZEOF(xkbIndicatorMapWireDesc)12); |
93 | if (wire == NULL((void*)0)) { |
94 | _XkbFreeReadBuffer(&buf); |
95 | return BadAlloc11; |
96 | } |
97 | leds->maps[i].flags = wire->flags; |
98 | leds->maps[i].which_groups = wire->whichGroups; |
99 | leds->maps[i].groups = wire->groups; |
100 | leds->maps[i].which_mods = wire->whichMods; |
101 | leds->maps[i].mods.mask = wire->mods; |
102 | leds->maps[i].mods.real_mods = wire->realMods; |
103 | leds->maps[i].mods.vmods = wire->virtualMods; |
104 | leds->maps[i].ctrls = wire->ctrls; |
105 | left &= ~bit; |
106 | } |
107 | } |
108 | } |
109 | left = _XkbFreeReadBuffer(&buf); |
Value stored to 'left' is never read | |
110 | } |
111 | return Success0; |
112 | } |
113 | |
114 | Boolint |
115 | XkbGetIndicatorMap(Display *dpy, unsigned long which, XkbDescPtr xkb) |
116 | { |
117 | register xkbGetIndicatorMapReq *req; |
118 | xkbGetIndicatorMapReply rep; |
119 | XkbInfoPtr xkbi; |
120 | Statusint status; |
121 | |
122 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
123 | (!dpy->xkb_info && !XkbUseExtension(dpy, NULL((void*)0), NULL((void*)0)))) |
124 | return BadAccess10; |
125 | if ((!which) || (!xkb)) |
126 | return BadValue2; |
127 | |
128 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
129 | xkbi = dpy->xkb_info; |
130 | if (!xkb->indicators) { |
131 | xkb->indicators = _XkbTypedCalloc(1, XkbIndicatorRec)((XkbIndicatorRec *)calloc((((1)) == 0 ? 1 : ((1))), (sizeof( XkbIndicatorRec)))); |
132 | if (!xkb->indicators) { |
133 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
134 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
135 | return BadAlloc11; |
136 | } |
137 | } |
138 | GetReq(kbGetIndicatorMap, req)req = (xkbGetIndicatorMapReq *) _XGetRequest(dpy, 13, 12); |
139 | req->reqType = xkbi->codes->major_opcode; |
140 | req->xkbReqType = X_kbGetIndicatorMap13; |
141 | req->deviceSpec = xkb->device_spec; |
142 | req->which = (CARD32) which; |
143 | if (!_XReply(dpy, (xReply *) &rep, 0, xFalse0)) { |
144 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
145 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
146 | return BadValue2; |
147 | } |
148 | status = _XkbReadGetIndicatorMapReply(dpy, &rep, xkb, NULL((void*)0)); |
149 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
150 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
151 | return status; |
152 | } |
153 | |
154 | Boolint |
155 | XkbSetIndicatorMap(Display *dpy, unsigned long which, XkbDescPtr xkb) |
156 | { |
157 | register xkbSetIndicatorMapReq *req; |
158 | register int i, bit; |
159 | int nMaps; |
160 | xkbIndicatorMapWireDesc *wire; |
161 | XkbInfoPtr xkbi; |
162 | |
163 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
164 | (!dpy->xkb_info && !XkbUseExtension(dpy, NULL((void*)0), NULL((void*)0)))) |
165 | return False0; |
166 | if ((!xkb) || (!which) || (!xkb->indicators)) |
167 | return False0; |
168 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
169 | xkbi = dpy->xkb_info; |
170 | GetReq(kbSetIndicatorMap, req)req = (xkbSetIndicatorMapReq *) _XGetRequest(dpy, 14, 12); |
171 | req->reqType = xkbi->codes->major_opcode; |
172 | req->xkbReqType = X_kbSetIndicatorMap14; |
173 | req->deviceSpec = xkb->device_spec; |
174 | req->which = (CARD32) which; |
175 | for (i = nMaps = 0, bit = 1; i < 32; i++, bit <<= 1) { |
176 | if (which & bit) |
177 | nMaps++; |
178 | } |
179 | req->length += (nMaps * sizeof(XkbIndicatorMapRec)) / 4; |
180 | BufAlloc(xkbIndicatorMapWireDesc *, wire,if (dpy->bufptr + ((nMaps * 12)) > dpy->bufmax) _XFlush (dpy); wire = (xkbIndicatorMapWireDesc *) dpy->bufptr; __builtin___memset_chk (wire, '\0', (nMaps * 12), __builtin_object_size (wire, 0)); dpy->bufptr += ((nMaps * 12)); |
181 | (nMaps * SIZEOF(xkbIndicatorMapWireDesc)))if (dpy->bufptr + ((nMaps * 12)) > dpy->bufmax) _XFlush (dpy); wire = (xkbIndicatorMapWireDesc *) dpy->bufptr; __builtin___memset_chk (wire, '\0', (nMaps * 12), __builtin_object_size (wire, 0)); dpy->bufptr += ((nMaps * 12));; |
182 | for (i = 0, bit = 1; i < 32; i++, bit <<= 1) { |
183 | if (which & bit) { |
184 | wire->flags = xkb->indicators->maps[i].flags; |
185 | wire->whichGroups = xkb->indicators->maps[i].which_groups; |
186 | wire->groups = xkb->indicators->maps[i].groups; |
187 | wire->whichMods = xkb->indicators->maps[i].which_mods; |
188 | wire->mods = xkb->indicators->maps[i].mods.real_mods; |
189 | wire->virtualMods = xkb->indicators->maps[i].mods.vmods; |
190 | wire->ctrls = xkb->indicators->maps[i].ctrls; |
191 | wire++; |
192 | } |
193 | } |
194 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
195 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
196 | return True1; |
197 | } |
198 | |
199 | Boolint |
200 | XkbGetNamedDeviceIndicator(Display *dpy, |
201 | unsigned device, |
202 | unsigned class, |
203 | unsigned id, |
204 | Atom name, |
205 | int *pNdxRtrn, |
206 | Boolint *pStateRtrn, |
207 | XkbIndicatorMapPtr pMapRtrn, |
208 | Boolint *pRealRtrn) |
209 | { |
210 | register xkbGetNamedIndicatorReq *req; |
211 | xkbGetNamedIndicatorReply rep; |
212 | XkbInfoPtr xkbi; |
213 | |
214 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || (name == None0L) || |
215 | (!dpy->xkb_info && !XkbUseExtension(dpy, NULL((void*)0), NULL((void*)0)))) |
216 | return False0; |
217 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
218 | xkbi = dpy->xkb_info; |
219 | GetReq(kbGetNamedIndicator, req)req = (xkbGetNamedIndicatorReq *) _XGetRequest(dpy, 15, 16); |
220 | req->reqType = xkbi->codes->major_opcode; |
221 | req->xkbReqType = X_kbGetNamedIndicator15; |
222 | req->deviceSpec = device; |
223 | req->ledClass = class; |
224 | req->ledID = id; |
225 | req->indicator = (CARD32) name; |
226 | if (!_XReply(dpy, (xReply *) &rep, 0, xFalse0)) { |
227 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
228 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
229 | return False0; |
230 | } |
231 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
232 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
233 | if ((!rep.found) || (!rep.supported)) |
234 | return False0; |
235 | if (pNdxRtrn != NULL((void*)0)) |
236 | *pNdxRtrn = rep.ndx; |
237 | if (pStateRtrn != NULL((void*)0)) |
238 | *pStateRtrn = rep.on; |
239 | if (pMapRtrn != NULL((void*)0)) { |
240 | pMapRtrn->flags = rep.flags; |
241 | pMapRtrn->which_groups = rep.whichGroups; |
242 | pMapRtrn->groups = rep.groups; |
243 | pMapRtrn->which_mods = rep.whichMods; |
244 | pMapRtrn->mods.mask = rep.mods; |
245 | pMapRtrn->mods.real_mods = rep.realMods; |
246 | pMapRtrn->mods.vmods = rep.virtualMods; |
247 | pMapRtrn->ctrls = rep.ctrls; |
248 | } |
249 | if (pRealRtrn != NULL((void*)0)) |
250 | *pRealRtrn = rep.realIndicator; |
251 | return True1; |
252 | } |
253 | |
254 | Boolint |
255 | XkbGetNamedIndicator(Display *dpy, |
256 | Atom name, |
257 | int *pNdxRtrn, |
258 | Boolint *pStateRtrn, |
259 | XkbIndicatorMapPtr pMapRtrn, |
260 | Boolint *pRealRtrn) |
261 | { |
262 | return XkbGetNamedDeviceIndicator(dpy, XkbUseCoreKbd0x0100, |
263 | XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
264 | name, pNdxRtrn, pStateRtrn, |
265 | pMapRtrn, pRealRtrn); |
266 | } |
267 | |
268 | Boolint |
269 | XkbSetNamedDeviceIndicator(Display *dpy, |
270 | unsigned device, |
271 | unsigned class, |
272 | unsigned id, |
273 | Atom name, |
274 | Boolint changeState, |
275 | Boolint state, |
276 | Boolint createNewMap, |
277 | XkbIndicatorMapPtr pMap) |
278 | { |
279 | register xkbSetNamedIndicatorReq *req; |
280 | XkbInfoPtr xkbi; |
281 | |
282 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || (name == None0L) || |
283 | (!dpy->xkb_info && !XkbUseExtension(dpy, NULL((void*)0), NULL((void*)0)))) |
284 | return False0; |
285 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
286 | xkbi = dpy->xkb_info; |
287 | GetReq(kbSetNamedIndicator, req)req = (xkbSetNamedIndicatorReq *) _XGetRequest(dpy, 16, 32); |
288 | req->reqType = xkbi->codes->major_opcode; |
289 | req->xkbReqType = X_kbSetNamedIndicator16; |
290 | req->deviceSpec = device; |
291 | req->ledClass = class; |
292 | req->ledID = id; |
293 | req->indicator = (CARD32) name; |
294 | req->setState = changeState; |
295 | if (req->setState) |
296 | req->on = state; |
297 | else |
298 | req->on = False0; |
299 | if (pMap != NULL((void*)0)) { |
300 | req->setMap = True1; |
301 | req->createMap = createNewMap; |
302 | req->flags = pMap->flags; |
303 | req->whichGroups = pMap->which_groups; |
304 | req->groups = pMap->groups; |
305 | req->whichMods = pMap->which_mods; |
306 | req->realMods = pMap->mods.real_mods; |
307 | req->virtualMods = pMap->mods.vmods; |
308 | req->ctrls = pMap->ctrls; |
309 | } |
310 | else { |
311 | req->setMap = False0; |
312 | req->createMap = False0; |
313 | req->flags = 0; |
314 | req->whichGroups = 0; |
315 | req->groups = 0; |
316 | req->whichMods = 0; |
317 | req->realMods = 0; |
318 | req->virtualMods = 0; |
319 | req->ctrls = 0; |
320 | } |
321 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
322 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
323 | return True1; |
324 | } |
325 | |
326 | Boolint |
327 | XkbSetNamedIndicator(Display *dpy, |
328 | Atom name, |
329 | Boolint changeState, |
330 | Boolint state, |
331 | Boolint createNewMap, |
332 | XkbIndicatorMapPtr pMap) |
333 | { |
334 | return XkbSetNamedDeviceIndicator(dpy, XkbUseCoreKbd0x0100, |
335 | XkbDfltXIClass0x0300, XkbDfltXIId0x0400, |
336 | name, changeState, state, |
337 | createNewMap, pMap); |
338 | } |