| File: | src/xkb/XKBCompat.c |
| Location: | line 204, column 2 |
| Description: | Value stored to 'buf' 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 | #ifdef HAVE_CONFIG_H1 |
| 28 | #include <config.h> |
| 29 | #endif |
| 30 | #include <stdio.h> |
| 31 | #define NEED_MAP_READERS |
| 32 | #include "Xlibint.h" |
| 33 | #include <X11/extensions/XKBproto.h> |
| 34 | #include "XKBlibint.h" |
| 35 | |
| 36 | Statusint |
| 37 | _XkbReadGetCompatMapReply( Display * dpy, |
| 38 | xkbGetCompatMapReply * rep, |
| 39 | XkbDescPtr xkb, |
| 40 | int * nread_rtrn) |
| 41 | { |
| 42 | register int i; |
| 43 | XkbReadBufferRec buf; |
| 44 | |
| 45 | if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) |
| 46 | return BadAlloc11; |
| 47 | |
| 48 | if (nread_rtrn) |
| 49 | *nread_rtrn= (int)rep->length*4; |
| 50 | |
| 51 | i= rep->firstSI+rep->nSI; |
| 52 | if ((!xkb->compat)&& |
| 53 | (XkbAllocCompatMap(xkb,XkbAllCompatMask(0x3),i)!=Success0)) |
| 54 | return BadAlloc11; |
| 55 | |
| 56 | if (rep->nSI!=0) { |
| 57 | XkbSymInterpretRec *syms; |
| 58 | xkbSymInterpretWireDesc *wire; |
| 59 | |
| 60 | wire= (xkbSymInterpretWireDesc *)_XkbGetReadBufferPtr(&buf, |
| 61 | rep->nSI*SIZEOF(xkbSymInterpretWireDesc)16); |
| 62 | if (wire==NULL((void*)0)) |
| 63 | goto BAILOUT; |
| 64 | syms= &xkb->compat->sym_interpret[rep->firstSI]; |
| 65 | |
| 66 | for (i=0;i<rep->nSI;i++,syms++,wire++) { |
| 67 | syms->sym= wire->sym; |
| 68 | syms->mods= wire->mods; |
| 69 | syms->match= wire->match; |
| 70 | syms->virtual_mod= wire->virtualMod; |
| 71 | syms->flags= wire->flags; |
| 72 | syms->act= *((XkbAnyAction *)&wire->act); |
| 73 | } |
| 74 | xkb->compat->num_si+= rep->nSI; |
| 75 | } |
| 76 | |
| 77 | if (rep->groups&XkbAllGroupsMask(0xf)) { |
| 78 | register unsigned bit,nGroups; |
| 79 | xkbModsWireDesc * wire; |
| 80 | for (i=0,nGroups=0,bit=1;i<XkbNumKbdGroups4;i++,bit<<=1) { |
| 81 | if (rep->groups&bit) |
| 82 | nGroups++; |
| 83 | } |
| 84 | wire= (xkbModsWireDesc *)_XkbGetReadBufferPtr(&buf, |
| 85 | nGroups*SIZEOF(xkbModsWireDesc)4); |
| 86 | if (wire==NULL((void*)0)) |
| 87 | goto BAILOUT; |
| 88 | for (i=0,bit=1;i<XkbNumKbdGroups4;i++,bit<<=1) { |
| 89 | if ((rep->groups&bit)==0) |
| 90 | continue; |
| 91 | xkb->compat->groups[i].mask= wire->mask; |
| 92 | xkb->compat->groups[i].real_mods= wire->realMods; |
| 93 | xkb->compat->groups[i].vmods= wire->virtualMods; |
| 94 | wire++; |
| 95 | } |
| 96 | } |
| 97 | i= _XkbFreeReadBuffer(&buf); |
| 98 | if (i) |
| 99 | fprintf(stderrstderr,"CompatMapReply! Bad length (%d extra bytes)\n",i); |
| 100 | if (i || buf.error) |
| 101 | return BadLength16; |
| 102 | return Success0; |
| 103 | BAILOUT: |
| 104 | _XkbFreeReadBuffer(&buf); |
| 105 | return BadLength16; |
| 106 | } |
| 107 | |
| 108 | Statusint |
| 109 | XkbGetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb) |
| 110 | { |
| 111 | register xkbGetCompatMapReq *req; |
| 112 | xkbGetCompatMapReply rep; |
| 113 | Statusint status; |
| 114 | XkbInfoPtr xkbi; |
| 115 | |
| 116 | if ( (!dpy) || (!xkb) || (dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
| 117 | ((xkb->dpy!=NULL((void*)0))&&(xkb->dpy!=dpy)) || |
| 118 | (!dpy->xkb_info && (!XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0))))) |
| 119 | return BadAccess10; |
| 120 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 121 | xkbi = dpy->xkb_info; |
| 122 | GetReq(kbGetCompatMap, req)req = (xkbGetCompatMapReq *) _XGetRequest(dpy, 10, 12); |
| 123 | req->reqType = xkbi->codes->major_opcode; |
| 124 | req->xkbReqType = X_kbGetCompatMap10; |
| 125 | req->deviceSpec = xkb->device_spec; |
| 126 | if (which&XkbSymInterpMask(1<<0)) |
| 127 | req->getAllSI= True1; |
| 128 | else req->getAllSI= False0; |
| 129 | req->firstSI= req->nSI= 0; |
| 130 | |
| 131 | if (which&XkbGroupCompatMask(1<<1)) |
| 132 | req->groups= XkbAllGroupsMask(0xf); |
| 133 | else req->groups= 0; |
| 134 | |
| 135 | if (!_XReply(dpy, (xReply *)&rep, 0, xFalse0)) { |
| 136 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 137 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 138 | return BadLength16; |
| 139 | } |
| 140 | if (xkb->dpy==NULL((void*)0)) |
| 141 | xkb->dpy= dpy; |
| 142 | if (xkb->device_spec==XkbUseCoreKbd0x0100) |
| 143 | xkb->device_spec= rep.deviceID; |
| 144 | |
| 145 | status = _XkbReadGetCompatMapReply(dpy,&rep,xkb,NULL((void*)0)); |
| 146 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 147 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 148 | return status; |
| 149 | } |
| 150 | |
| 151 | static Boolint |
| 152 | _XkbWriteSetCompatMap(Display *dpy,xkbSetCompatMapReq *req,XkbDescPtr xkb) |
| 153 | { |
| 154 | CARD16 firstSI; |
| 155 | CARD16 nSI; |
| 156 | int size; |
| 157 | register int i,nGroups; |
| 158 | register unsigned bit; |
| 159 | unsigned groups; |
| 160 | char * buf; |
| 161 | |
| 162 | firstSI = req->firstSI; |
| 163 | nSI = req->nSI; |
| 164 | size= nSI*SIZEOF(xkbSymInterpretWireDesc)16; |
| 165 | nGroups= 0; |
| 166 | groups= req->groups; |
| 167 | if (groups&XkbAllGroupsMask(0xf)) { |
| 168 | for (i=0,bit=1;i<XkbNumKbdGroups4;i++,bit<<=1) { |
| 169 | if (groups&bit) |
| 170 | nGroups++; |
| 171 | } |
| 172 | size+= SIZEOF(xkbModsWireDesc)4*nGroups; |
| 173 | } |
| 174 | req->length+= size/4; |
| 175 | BufAlloc(char *,buf,size)if (dpy->bufptr + (size) > dpy->bufmax) _XFlush (dpy ); buf = (char *) dpy->bufptr; memset(buf, '\0', size); dpy ->bufptr += (size);; |
| 176 | if (!buf) |
| 177 | return False0; |
| 178 | |
| 179 | if (nSI) { |
| 180 | XkbSymInterpretPtr sym= &xkb->compat->sym_interpret[firstSI]; |
| 181 | xkbSymInterpretWireDesc *wire= (xkbSymInterpretWireDesc *)buf; |
| 182 | for (i=0;i<nSI;i++,wire++,sym++) { |
| 183 | wire->sym= (CARD32)sym->sym; |
| 184 | wire->mods= sym->mods; |
| 185 | wire->match= sym->match; |
| 186 | wire->flags= sym->flags; |
| 187 | wire->virtualMod= sym->virtual_mod; |
| 188 | memcpy(&wire->act,&sym->act,sz_xkbActionWireDesc8); |
| 189 | } |
| 190 | buf+= nSI*SIZEOF(xkbSymInterpretWireDesc)16; |
| 191 | } |
| 192 | if (groups&XkbAllGroupsMask(0xf)) { |
| 193 | xkbModsWireDesc * out; |
| 194 | |
| 195 | out= (xkbModsWireDesc *)buf; |
| 196 | for (i=0,bit=1;i<XkbNumKbdGroups4;i++,bit<<=1) { |
| 197 | if ((groups&bit)!=0) { |
| 198 | out->mask= xkb->compat->groups[i].mask; |
| 199 | out->realMods= xkb->compat->groups[i].real_mods; |
| 200 | out->virtualMods= xkb->compat->groups[i].vmods; |
| 201 | out++; |
| 202 | } |
| 203 | } |
| 204 | buf+= nGroups*SIZEOF(xkbModsWireDesc)4; |
Value stored to 'buf' is never read | |
| 205 | } |
| 206 | return True1; |
| 207 | } |
| 208 | |
| 209 | Boolint |
| 210 | XkbSetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb,Boolint updateActions) |
| 211 | { |
| 212 | register xkbSetCompatMapReq *req; |
| 213 | Statusint ok; |
| 214 | XkbInfoPtr xkbi; |
| 215 | |
| 216 | if ((dpy->flags & XlibDisplayNoXkb(1L << 2)) || (dpy!=xkb->dpy) || |
| 217 | (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0)))) |
| 218 | return False0; |
| 219 | if ((!xkb->compat) || |
| 220 | ((which&XkbSymInterpMask(1<<0))&&(!xkb->compat->sym_interpret))) |
| 221 | return False0; |
| 222 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 223 | xkbi = dpy->xkb_info; |
| 224 | GetReq(kbSetCompatMap, req)req = (xkbSetCompatMapReq *) _XGetRequest(dpy, 11, 16); |
| 225 | req->reqType = xkbi->codes->major_opcode; |
| 226 | req->xkbReqType = X_kbSetCompatMap11; |
| 227 | req->deviceSpec = xkb->device_spec; |
| 228 | req->recomputeActions = updateActions; |
| 229 | if (which&XkbSymInterpMask(1<<0)) { |
| 230 | req->truncateSI = True1; |
| 231 | req->firstSI= 0; |
| 232 | req->nSI= xkb->compat->num_si; |
| 233 | } |
| 234 | else { |
| 235 | req->truncateSI = False0; |
| 236 | req->firstSI= 0; |
| 237 | req->nSI= 0; |
| 238 | } |
| 239 | if (which&XkbGroupCompatMask(1<<1)) |
| 240 | req->groups= XkbAllGroupsMask(0xf); |
| 241 | else req->groups= 0; |
| 242 | ok= _XkbWriteSetCompatMap(dpy,req,xkb); |
| 243 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 244 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 245 | return ok; |
| 246 | } |
| 247 |