| File: | src/xkb/XKBleds.c |
| Location: | line 105, column 2 |
| 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 | if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) |
| 77 | return BadAlloc11; |
| 78 | if (nread_rtrn) |
| 79 | *nread_rtrn= (int)rep->length*4; |
| 80 | if (rep->which) { |
| 81 | register int i,bit; |
| 82 | left= (int)rep->which; |
| 83 | for (i=0,bit=1;(i<XkbNumIndicators32)&&(left);i++,bit<<=1) { |
| 84 | if (left&bit) { |
| 85 | xkbIndicatorMapWireDesc *wire; |
| 86 | wire= (xkbIndicatorMapWireDesc *) |
| 87 | _XkbGetReadBufferPtr(&buf, |
| 88 | SIZEOF(xkbIndicatorMapWireDesc)12); |
| 89 | if (wire==NULL((void*)0)) { |
| 90 | _XkbFreeReadBuffer(&buf); |
| 91 | return BadAlloc11; |
| 92 | } |
| 93 | leds->maps[i].flags= wire->flags; |
| 94 | leds->maps[i].which_groups= wire->whichGroups; |
| 95 | leds->maps[i].groups= wire->groups; |
| 96 | leds->maps[i].which_mods= wire->whichMods; |
| 97 | leds->maps[i].mods.mask= wire->mods; |
| 98 | leds->maps[i].mods.real_mods= wire->realMods; |
| 99 | leds->maps[i].mods.vmods= wire->virtualMods; |
| 100 | leds->maps[i].ctrls= wire->ctrls; |
| 101 | left&= ~bit; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | left= _XkbFreeReadBuffer(&buf); |
Value stored to 'left' is never read | |
| 106 | } |
| 107 | return Success0; |
| 108 | } |
| 109 | |
| 110 | Boolint |
| 111 | XkbGetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb) |
| 112 | { |
| 113 | register xkbGetIndicatorMapReq * req; |
| 114 | xkbGetIndicatorMapReply rep; |
| 115 | XkbInfoPtr xkbi; |
| 116 | Statusint status; |
| 117 | |
| 118 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
| 119 | (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0)))) |
| 120 | return BadAccess10; |
| 121 | if ((!which)||(!xkb)) |
| 122 | return BadValue2; |
| 123 | |
| 124 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 125 | xkbi = dpy->xkb_info; |
| 126 | if (!xkb->indicators) { |
| 127 | xkb->indicators = _XkbTypedCalloc(1,XkbIndicatorRec)((XkbIndicatorRec *)calloc((((1)) == 0 ? 1 : ((1))), (sizeof( XkbIndicatorRec)))); |
| 128 | if (!xkb->indicators) { |
| 129 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 130 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 131 | return BadAlloc11; |
| 132 | } |
| 133 | } |
| 134 | GetReq(kbGetIndicatorMap, req)req = (xkbGetIndicatorMapReq *) _XGetRequest(dpy, 13, 12); |
| 135 | req->reqType = xkbi->codes->major_opcode; |
| 136 | req->xkbReqType = X_kbGetIndicatorMap13; |
| 137 | req->deviceSpec = xkb->device_spec; |
| 138 | req->which = (CARD32)which; |
| 139 | if (!_XReply(dpy, (xReply *)&rep, 0, xFalse0)) { |
| 140 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 141 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 142 | return BadValue2; |
| 143 | } |
| 144 | status= _XkbReadGetIndicatorMapReply(dpy,&rep,xkb,NULL((void*)0)); |
| 145 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 146 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 147 | return status; |
| 148 | } |
| 149 | |
| 150 | Boolint |
| 151 | XkbSetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb) |
| 152 | { |
| 153 | register xkbSetIndicatorMapReq *req; |
| 154 | register int i,bit; |
| 155 | int nMaps; |
| 156 | xkbIndicatorMapWireDesc *wire; |
| 157 | XkbInfoPtr xkbi; |
| 158 | |
| 159 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
| 160 | (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0)))) |
| 161 | return False0; |
| 162 | if ((!xkb)||(!which)||(!xkb->indicators)) |
| 163 | return False0; |
| 164 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 165 | xkbi = dpy->xkb_info; |
| 166 | GetReq(kbSetIndicatorMap, req)req = (xkbSetIndicatorMapReq *) _XGetRequest(dpy, 14, 12); |
| 167 | req->reqType = xkbi->codes->major_opcode; |
| 168 | req->xkbReqType = X_kbSetIndicatorMap14; |
| 169 | req->deviceSpec = xkb->device_spec; |
| 170 | req->which = (CARD32)which; |
| 171 | for (i=nMaps=0,bit=1;i<32;i++,bit<<=1) { |
| 172 | if (which&bit) |
| 173 | nMaps++; |
| 174 | } |
| 175 | req->length+= (nMaps*sizeof(XkbIndicatorMapRec))/4; |
| 176 | BufAlloc(xkbIndicatorMapWireDesc *,wire,if (dpy->bufptr + ((nMaps*12)) > dpy->bufmax) _XFlush (dpy); wire = (xkbIndicatorMapWireDesc *) dpy->bufptr; memset (wire, '\0', (nMaps*12)); dpy->bufptr += ((nMaps*12)); |
| 177 | (nMaps*SIZEOF(xkbIndicatorMapWireDesc)))if (dpy->bufptr + ((nMaps*12)) > dpy->bufmax) _XFlush (dpy); wire = (xkbIndicatorMapWireDesc *) dpy->bufptr; memset (wire, '\0', (nMaps*12)); dpy->bufptr += ((nMaps*12));; |
| 178 | for (i=0,bit=1;i<32;i++,bit<<=1) { |
| 179 | if (which&bit) { |
| 180 | wire->flags= xkb->indicators->maps[i].flags; |
| 181 | wire->whichGroups= xkb->indicators->maps[i].which_groups; |
| 182 | wire->groups= xkb->indicators->maps[i].groups; |
| 183 | wire->whichMods= xkb->indicators->maps[i].which_mods; |
| 184 | wire->mods= xkb->indicators->maps[i].mods.real_mods; |
| 185 | wire->virtualMods= xkb->indicators->maps[i].mods.vmods; |
| 186 | wire->ctrls= xkb->indicators->maps[i].ctrls; |
| 187 | wire++; |
| 188 | } |
| 189 | } |
| 190 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 191 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 192 | return True1; |
| 193 | } |
| 194 | |
| 195 | Boolint |
| 196 | XkbGetNamedDeviceIndicator( Display * dpy, |
| 197 | unsigned device, |
| 198 | unsigned class, |
| 199 | unsigned id, |
| 200 | Atom name, |
| 201 | int * pNdxRtrn, |
| 202 | Boolint * pStateRtrn, |
| 203 | XkbIndicatorMapPtr pMapRtrn, |
| 204 | Boolint * pRealRtrn) |
| 205 | { |
| 206 | register xkbGetNamedIndicatorReq *req; |
| 207 | xkbGetNamedIndicatorReply rep; |
| 208 | XkbInfoPtr xkbi; |
| 209 | |
| 210 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || (name==None0L) || |
| 211 | (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0)))) |
| 212 | return False0; |
| 213 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 214 | xkbi = dpy->xkb_info; |
| 215 | GetReq(kbGetNamedIndicator, req)req = (xkbGetNamedIndicatorReq *) _XGetRequest(dpy, 15, 16); |
| 216 | req->reqType = xkbi->codes->major_opcode; |
| 217 | req->xkbReqType = X_kbGetNamedIndicator15; |
| 218 | req->deviceSpec = device; |
| 219 | req->ledClass = class; |
| 220 | req->ledID = id; |
| 221 | req->indicator = (CARD32)name; |
| 222 | if (!_XReply(dpy, (xReply *)&rep, 0, xFalse0)) { |
| 223 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 224 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 225 | return False0; |
| 226 | } |
| 227 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 228 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 229 | if ((!rep.found)||(!rep.supported)) |
| 230 | return False0; |
| 231 | if (pNdxRtrn!=NULL((void*)0)) |
| 232 | *pNdxRtrn= rep.ndx; |
| 233 | if (pStateRtrn!=NULL((void*)0)) |
| 234 | *pStateRtrn= rep.on; |
| 235 | if (pMapRtrn!=NULL((void*)0)) { |
| 236 | pMapRtrn->flags= rep.flags; |
| 237 | pMapRtrn->which_groups= rep.whichGroups; |
| 238 | pMapRtrn->groups= rep.groups; |
| 239 | pMapRtrn->which_mods= rep.whichMods; |
| 240 | pMapRtrn->mods.mask= rep.mods; |
| 241 | pMapRtrn->mods.real_mods= rep.realMods; |
| 242 | pMapRtrn->mods.vmods= rep.virtualMods; |
| 243 | pMapRtrn->ctrls= rep.ctrls; |
| 244 | } |
| 245 | if (pRealRtrn!=NULL((void*)0)) |
| 246 | *pRealRtrn= rep.realIndicator; |
| 247 | return True1; |
| 248 | } |
| 249 | |
| 250 | Boolint |
| 251 | XkbGetNamedIndicator( Display * dpy, |
| 252 | Atom name, |
| 253 | int * pNdxRtrn, |
| 254 | Boolint * pStateRtrn, |
| 255 | XkbIndicatorMapPtr pMapRtrn, |
| 256 | Boolint * pRealRtrn) |
| 257 | { |
| 258 | return XkbGetNamedDeviceIndicator(dpy,XkbUseCoreKbd0x0100, |
| 259 | XkbDfltXIClass0x0300,XkbDfltXIId0x0400, |
| 260 | name,pNdxRtrn,pStateRtrn, |
| 261 | pMapRtrn,pRealRtrn); |
| 262 | } |
| 263 | |
| 264 | Boolint |
| 265 | XkbSetNamedDeviceIndicator( Display * dpy, |
| 266 | unsigned device, |
| 267 | unsigned class, |
| 268 | unsigned id, |
| 269 | Atom name, |
| 270 | Boolint changeState, |
| 271 | Boolint state, |
| 272 | Boolint createNewMap, |
| 273 | XkbIndicatorMapPtr pMap) |
| 274 | { |
| 275 | register xkbSetNamedIndicatorReq *req; |
| 276 | XkbInfoPtr xkbi; |
| 277 | |
| 278 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || (name==None0L) || |
| 279 | (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0)))) |
| 280 | return False0; |
| 281 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 282 | xkbi = dpy->xkb_info; |
| 283 | GetReq(kbSetNamedIndicator, req)req = (xkbSetNamedIndicatorReq *) _XGetRequest(dpy, 16, 32); |
| 284 | req->reqType = xkbi->codes->major_opcode; |
| 285 | req->xkbReqType = X_kbSetNamedIndicator16; |
| 286 | req->deviceSpec = device; |
| 287 | req->ledClass = class; |
| 288 | req->ledID = id; |
| 289 | req->indicator= (CARD32)name; |
| 290 | req->setState= changeState; |
| 291 | if (req->setState) |
| 292 | req->on= state; |
| 293 | else req->on= False0; |
| 294 | if (pMap!=NULL((void*)0)) { |
| 295 | req->setMap= True1; |
| 296 | req->createMap= createNewMap; |
| 297 | req->flags= pMap->flags; |
| 298 | req->whichGroups= pMap->which_groups; |
| 299 | req->groups= pMap->groups; |
| 300 | req->whichMods= pMap->which_mods; |
| 301 | req->realMods= pMap->mods.real_mods; |
| 302 | req->virtualMods= pMap->mods.vmods; |
| 303 | req->ctrls= pMap->ctrls; |
| 304 | } |
| 305 | else { |
| 306 | req->setMap= False0; |
| 307 | req->createMap= False0; |
| 308 | req->flags= 0; |
| 309 | req->whichGroups= 0; |
| 310 | req->groups= 0; |
| 311 | req->whichMods= 0; |
| 312 | req->realMods= 0; |
| 313 | req->virtualMods= 0; |
| 314 | req->ctrls= 0; |
| 315 | } |
| 316 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 317 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 318 | return True1; |
| 319 | } |
| 320 | |
| 321 | Boolint |
| 322 | XkbSetNamedIndicator( Display * dpy, |
| 323 | Atom name, |
| 324 | Boolint changeState, |
| 325 | Boolint state, |
| 326 | Boolint createNewMap, |
| 327 | XkbIndicatorMapPtr pMap) |
| 328 | { |
| 329 | return XkbSetNamedDeviceIndicator(dpy,XkbUseCoreKbd0x0100, |
| 330 | XkbDfltXIClass0x0300,XkbDfltXIId0x0400, |
| 331 | name,changeState,state, |
| 332 | createNewMap,pMap); |
| 333 | } |