| File: | src/xkb/XKBGetByName.c |
| Location: | line 195, column 2 |
| Description: | Value stored to 'extraLen' 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 | /***====================================================================***/ |
| 36 | |
| 37 | XkbDescPtr |
| 38 | XkbGetKeyboardByName( Display * dpy, |
| 39 | unsigned deviceSpec, |
| 40 | XkbComponentNamesPtr names, |
| 41 | unsigned want, |
| 42 | unsigned need, |
| 43 | Boolint load) |
| 44 | { |
| 45 | register xkbGetKbdByNameReq * req; |
| 46 | xkbGetKbdByNameReply rep; |
| 47 | int len,extraLen; |
| 48 | char * str; |
| 49 | XkbDescPtr xkb; |
| 50 | int mapLen,codesLen,typesLen,compatLen; |
| 51 | int symsLen,geomLen; |
| 52 | XkbInfoPtr xkbi; |
| 53 | |
| 54 | if ( (dpy==NULL((void*)0)) || (dpy->flags & XlibDisplayNoXkb(1L << 2)) || |
| 55 | (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0))) ) |
| 56 | return NULL((void*)0); |
| 57 | |
| 58 | xkbi= dpy->xkb_info; |
| 59 | xkb = (XkbDescRec *)_XkbCalloc(1,sizeof(XkbDescRec))calloc((((1)) == 0 ? 1 : ((1))), ((sizeof(XkbDescRec)))); |
| 60 | if (!xkb) |
| 61 | return NULL((void*)0); |
| 62 | xkb->device_spec = deviceSpec; |
| 63 | xkb->map = (XkbClientMapRec *)_XkbCalloc(1,sizeof(XkbClientMapRec))calloc((((1)) == 0 ? 1 : ((1))), ((sizeof(XkbClientMapRec)))); |
| 64 | xkb->dpy = dpy; |
| 65 | |
| 66 | LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display )(dpy); |
| 67 | GetReq(kbGetKbdByName, req)req = (xkbGetKbdByNameReq *) _XGetRequest(dpy, 23, 12); |
| 68 | req->reqType = xkbi->codes->major_opcode; |
| 69 | req->xkbReqType = X_kbGetKbdByName23; |
| 70 | req->deviceSpec = xkb->device_spec; |
| 71 | req->want= want; |
| 72 | req->need= need; |
| 73 | req->load= load; |
| 74 | |
| 75 | mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0; |
| 76 | if (names) { |
| 77 | if (names->keymap) |
| 78 | mapLen= (int)strlen(names->keymap); |
| 79 | if (names->keycodes) |
| 80 | codesLen= (int)strlen(names->keycodes); |
| 81 | if (names->types) |
| 82 | typesLen= (int)strlen(names->types); |
| 83 | if (names->compat) |
| 84 | compatLen= (int)strlen(names->compat); |
| 85 | if (names->symbols) |
| 86 | symsLen= (int)strlen(names->symbols); |
| 87 | if (names->geometry) |
| 88 | geomLen= (int)strlen(names->geometry); |
| 89 | if (mapLen>255) mapLen= 255; |
| 90 | if (codesLen>255) codesLen= 255; |
| 91 | if (typesLen>255) typesLen= 255; |
| 92 | if (compatLen>255) compatLen= 255; |
| 93 | if (symsLen>255) symsLen= 255; |
| 94 | if (geomLen>255) geomLen= 255; |
| 95 | } |
| 96 | else mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0; |
| 97 | |
| 98 | len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6; |
| 99 | len= XkbPaddedSize(len)((((unsigned int)(len)+3) >> 2) << 2); |
| 100 | req->length+= len/4; |
| 101 | BufAlloc(char *,str,len)if (dpy->bufptr + (len) > dpy->bufmax) _XFlush (dpy) ; str = (char *) dpy->bufptr; memset(str, '\0', len); dpy-> bufptr += (len);; |
| 102 | *str++= mapLen; |
| 103 | if (mapLen>0) { |
| 104 | memcpy(str,names->keymap,mapLen); |
| 105 | str+= mapLen; |
| 106 | } |
| 107 | *str++= codesLen; |
| 108 | if (codesLen>0) { |
| 109 | memcpy(str,names->keycodes,codesLen); |
| 110 | str+= codesLen; |
| 111 | } |
| 112 | *str++= typesLen; |
| 113 | if (typesLen>0) { |
| 114 | memcpy(str,names->types,typesLen); |
| 115 | str+= typesLen; |
| 116 | } |
| 117 | *str++= compatLen; |
| 118 | if (compatLen>0) { |
| 119 | memcpy(str,names->compat,compatLen); |
| 120 | str+= compatLen; |
| 121 | } |
| 122 | *str++= symsLen; |
| 123 | if (symsLen>0) { |
| 124 | memcpy(str,names->symbols,symsLen); |
| 125 | str+= symsLen; |
| 126 | } |
| 127 | *str++= geomLen; |
| 128 | if (geomLen>0) { |
| 129 | memcpy(str,names->geometry,geomLen); |
| 130 | str+= geomLen; |
| 131 | } |
| 132 | if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse0))||(!rep.reported)) |
| 133 | goto BAILOUT; |
| 134 | extraLen= (int)rep.length*4; |
| 135 | |
| 136 | xkb->device_spec= rep.deviceID; |
| 137 | xkb->min_key_code = rep.minKeyCode; |
| 138 | xkb->max_key_code = rep.maxKeyCode; |
| 139 | if (rep.reported&(XkbGBN_SymbolsMask((1L << 2)|(1L << 3))|XkbGBN_TypesMask(1L << 0))) { |
| 140 | xkbGetMapReply mrep; |
| 141 | Statusint status; |
| 142 | int nread= 0; |
| 143 | |
| 144 | _XRead(dpy, (char *)&mrep, SIZEOF(xkbGetMapReply)40); |
| 145 | extraLen-= SIZEOF(xkbGetMapReply)40; |
| 146 | status= _XkbReadGetMapReply(dpy,&mrep,xkb,&nread); |
| 147 | extraLen-= nread; |
| 148 | if (status!=Success0) |
| 149 | goto BAILOUT; |
| 150 | } |
| 151 | if (rep.reported&XkbGBN_CompatMapMask(1L << 1)) { |
| 152 | xkbGetCompatMapReply crep; |
| 153 | Statusint status; |
| 154 | int nread= 0; |
| 155 | |
| 156 | _XRead(dpy, (char *)&crep, SIZEOF(xkbGetCompatMapReply)32); |
| 157 | extraLen-= SIZEOF(xkbGetCompatMapReply)32; |
| 158 | status= _XkbReadGetCompatMapReply(dpy,&crep,xkb,&nread); |
| 159 | extraLen-= nread; |
| 160 | if (status!=Success0) |
| 161 | goto BAILOUT; |
| 162 | } |
| 163 | if (rep.reported&XkbGBN_IndicatorMapMask(1L << 4)) { |
| 164 | xkbGetIndicatorMapReply irep; |
| 165 | Statusint status; |
| 166 | int nread= 0; |
| 167 | |
| 168 | _XRead(dpy, (char *)&irep, SIZEOF(xkbGetIndicatorMapReply)32); |
| 169 | extraLen-= SIZEOF(xkbGetIndicatorMapReply)32; |
| 170 | status= _XkbReadGetIndicatorMapReply(dpy,&irep,xkb,&nread); |
| 171 | extraLen-= nread; |
| 172 | if (status!=Success0) |
| 173 | goto BAILOUT; |
| 174 | } |
| 175 | if (rep.reported&(XkbGBN_KeyNamesMask(1L << 5)|XkbGBN_OtherNamesMask(1L << 7))) { |
| 176 | xkbGetNamesReply nrep; |
| 177 | Statusint status; |
| 178 | int nread= 0; |
| 179 | |
| 180 | _XRead(dpy, (char *)&nrep, SIZEOF(xkbGetNamesReply)32); |
| 181 | extraLen-= SIZEOF(xkbGetNamesReply)32; |
| 182 | status= _XkbReadGetNamesReply(dpy,&nrep,xkb,&nread); |
| 183 | extraLen-= nread; |
| 184 | if (status!=Success0) |
| 185 | goto BAILOUT; |
| 186 | } |
| 187 | if (rep.reported&XkbGBN_GeometryMask(1L << 6)) { |
| 188 | xkbGetGeometryReply grep; |
| 189 | Statusint status; |
| 190 | int nread= 0; |
| 191 | |
| 192 | _XRead(dpy, (char *)&grep, SIZEOF(xkbGetGeometryReply)32); |
| 193 | extraLen-= SIZEOF(xkbGetGeometryReply)32; |
| 194 | status= _XkbReadGetGeometryReply(dpy,&grep,xkb,&nread); |
| 195 | extraLen-= nread; |
Value stored to 'extraLen' is never read | |
| 196 | if (status!=Success0) |
| 197 | goto BAILOUT; |
| 198 | } |
| 199 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 200 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 201 | return xkb; |
| 202 | BAILOUT: |
| 203 | if (xkb!=NULL((void*)0)) |
| 204 | XkbFreeKeyboard(xkb,XkbAllComponentsMask(0x7f),xTrue1); |
| 205 | UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display )(dpy); |
| 206 | SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy); |
| 207 | return NULL((void*)0); |
| 208 | } |
| 209 | |
| 210 | XkbDescPtr |
| 211 | XkbGetKeyboard(Display *dpy,unsigned which,unsigned deviceSpec) |
| 212 | { |
| 213 | return XkbGetKeyboardByName(dpy,deviceSpec,NULL((void*)0),which,which,False0); |
| 214 | } |