Bug Summary

File:src/xkb/XKBList.c
Location:line 175, column 3
Description:Value stored to 'str' is never read

Annotated Source Code

1/************************************************************
2Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
3
4Permission to use, copy, modify, and distribute this
5software and its documentation for any purpose and without
6fee is hereby granted, provided that the above copyright
7notice appear in all copies and that both that copyright
8notice and this permission notice appear in supporting
9documentation, and that the name of Silicon Graphics not be
10used in advertising or publicity pertaining to distribution
11of the software without specific prior written permission.
12Silicon Graphics makes no representation about the suitability
13of this software for any purpose. It is provided "as is"
14without any express or implied warranty.
15
16SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
23THE 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
37static void
38_FreeComponentNames(int num,XkbComponentNamePtr names)
39{
40int i;
41XkbComponentNamePtr tmp;
42
43 if ((num<1)||(names==NULL((void*)0)))
44 return;
45 for (i=0,tmp=names;i<num;i++,tmp++) {
46 if (tmp->name) {
47 _XkbFree(tmp->name)free((tmp->name));
48 tmp->name= NULL((void*)0);
49 }
50 }
51 _XkbFree(names)free((names));
52 return;
53}
54
55/***====================================================================***/
56
57static XkbComponentNamePtr
58_ReadListing(XkbReadBufferPtr buf,int count,Statusint *status_rtrn)
59{
60XkbComponentNamePtr first,this;
61register int i;
62CARD16 * flags;
63int slen,wlen;
64char * str;
65
66 if (count<1)
67 return NULL((void*)0);
68 first= _XkbTypedCalloc(count,XkbComponentNameRec)((XkbComponentNameRec *)calloc((((count)) == 0 ? 1 : ((count)
)), (sizeof(XkbComponentNameRec))))
;
69 if (!first)
70 return NULL((void*)0);
71 for (this=first,i=0;i<count;i++,this++) {
72 flags= (CARD16 *)_XkbGetReadBufferPtr(buf,2*sizeof(CARD16));
73 if (!flags)
74 goto BAILOUT;
75 this->flags= flags[0];
76 slen= flags[1];
77 wlen= ((slen+1)/2)*2; /* pad to 2 byte boundary */
78 this->name= _XkbTypedCalloc(slen+1,char)((char *)calloc((((slen+1)) == 0 ? 1 : ((slen+1))), (sizeof(char
))))
;
79 if (!this->name)
80 goto BAILOUT;
81 str= (char *)_XkbGetReadBufferPtr(buf,wlen);
82 if (!str)
83 goto BAILOUT;
84 memcpy(this->name,str,slen);
85 }
86 return first;
87BAILOUT:
88 *status_rtrn= BadAlloc11;
89 _FreeComponentNames(i,first);
90 return NULL((void*)0);
91}
92
93/***====================================================================***/
94
95XkbComponentListPtr
96XkbListComponents( Display * dpy,
97 unsigned deviceSpec,
98 XkbComponentNamesPtr ptrns,
99 int * max_inout)
100{
101register xkbListComponentsReq* req;
102xkbListComponentsReply rep;
103XkbInfoPtr xkbi;
104XkbComponentListPtr list;
105XkbReadBufferRec buf;
106int left;
107char * str;
108int extraLen,len,mapLen,codesLen,typesLen,compatLen,symsLen,geomLen;
109
110 if ( (dpy==NULL((void*)0)) || (dpy->flags & XlibDisplayNoXkb(1L << 2)) ||
111 (!dpy->xkb_info && !XkbUseExtension(dpy,NULL((void*)0),NULL((void*)0))) ||
112 (ptrns==NULL((void*)0)) || (max_inout==NULL((void*)0)))
113 return NULL((void*)0);
114
115 xkbi= dpy->xkb_info;
116 LockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->lock_display
)(dpy)
;
117 GetReq(kbListComponents, req)req = (xkbListComponentsReq *) _XGetRequest(dpy, 22, 8);
118 req->reqType = xkbi->codes->major_opcode;
119 req->xkbReqType = X_kbListComponents22;
120 req->deviceSpec = deviceSpec;
121 req->maxNames = *max_inout;
122
123 mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
124 if (ptrns->keymap)
125 mapLen= (int)strlen(ptrns->keymap);
126 if (ptrns->keycodes)
127 codesLen= (int)strlen(ptrns->keycodes);
128 if (ptrns->types)
129 typesLen= (int)strlen(ptrns->types);
130 if (ptrns->compat)
131 compatLen= (int)strlen(ptrns->compat);
132 if (ptrns->symbols)
133 symsLen= (int)strlen(ptrns->symbols);
134 if (ptrns->geometry)
135 geomLen= (int)strlen(ptrns->geometry);
136 if (mapLen>255) mapLen= 255;
137 if (codesLen>255) codesLen= 255;
138 if (typesLen>255) typesLen= 255;
139 if (compatLen>255) compatLen= 255;
140 if (symsLen>255) symsLen= 255;
141 if (geomLen>255) geomLen= 255;
142
143 len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
144 len= XkbPaddedSize(len)((((unsigned int)(len)+3) >> 2) << 2);
145 req->length+= len/4;
146 BufAlloc(char *,str,len)if (dpy->bufptr + (len) > dpy->bufmax) _XFlush (dpy)
; str = (char *) dpy->bufptr; memset(str, '\0', len); dpy->
bufptr += (len);
;
147 *str++= mapLen;
148 if (mapLen>0) {
149 memcpy(str,ptrns->keymap,mapLen);
150 str+= mapLen;
151 }
152 *str++= codesLen;
153 if (codesLen>0) {
154 memcpy(str,ptrns->keycodes,codesLen);
155 str+= codesLen;
156 }
157 *str++= typesLen;
158 if (typesLen>0) {
159 memcpy(str,ptrns->types,typesLen);
160 str+= typesLen;
161 }
162 *str++= compatLen;
163 if (compatLen>0) {
164 memcpy(str,ptrns->compat,compatLen);
165 str+= compatLen;
166 }
167 *str++= symsLen;
168 if (symsLen>0) {
169 memcpy(str,ptrns->symbols,symsLen);
170 str+= symsLen;
171 }
172 *str++= geomLen;
173 if (geomLen>0) {
174 memcpy(str,ptrns->geometry,geomLen);
175 str+= geomLen;
Value stored to 'str' is never read
176 }
177 if (!_XReply(dpy, (xReply *)&rep, 0, xFalse0))
178 goto BAILOUT;
179 extraLen= (int)rep.length*4;
180 *max_inout= rep.extra;
181 if (extraLen==0) { /* no matches, but we don't want to report a failure */
182 list= _XkbTypedCalloc(1,XkbComponentListRec)((XkbComponentListRec *)calloc((((1)) == 0 ? 1 : ((1))), (sizeof
(XkbComponentListRec))))
;
183 UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display
)(dpy)
;
184 SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy);
185 return list;
186 }
187 if (_XkbInitReadBuffer(dpy,&buf,extraLen)) {
188 Statusint status;
189
190 status= Success0;
191 list= _XkbTypedCalloc(1,XkbComponentListRec)((XkbComponentListRec *)calloc((((1)) == 0 ? 1 : ((1))), (sizeof
(XkbComponentListRec))))
;
192 if (!list) {
193 _XkbFreeReadBuffer(&buf);
194 goto BAILOUT;
195 }
196 list->num_keymaps= rep.nKeymaps;
197 list->num_keycodes= rep.nKeycodes;
198 list->num_types= rep.nTypes;
199 list->num_compat= rep.nCompatMaps;
200 list->num_symbols= rep.nSymbols;
201 list->num_geometry= rep.nGeometries;
202 if ((status==Success0)&&(list->num_keymaps>0))
203 list->keymaps= _ReadListing(&buf,list->num_keymaps,&status);
204 if ((status==Success0)&&(list->num_keycodes>0))
205 list->keycodes= _ReadListing(&buf,list->num_keycodes,&status);
206 if ((status==Success0)&&(list->num_types>0))
207 list->types= _ReadListing(&buf,list->num_types,&status);
208 if ((status==Success0)&&(list->num_compat>0))
209 list->compat= _ReadListing(&buf,list->num_compat,&status);
210 if ((status==Success0)&&(list->num_symbols>0))
211 list->symbols= _ReadListing(&buf,list->num_symbols,&status);
212 if ((status==Success0)&&(list->num_geometry>0))
213 list->geometry= _ReadListing(&buf,list->num_geometry,&status);
214 left= _XkbFreeReadBuffer(&buf);
215 if ((status!=Success0)||(buf.error)||(left>2)) {
216 XkbFreeComponentList(list);
217 goto BAILOUT;
218 }
219 UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display
)(dpy)
;
220 SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy);
221 return list;
222 }
223BAILOUT:
224 UnlockDisplay(dpy)if ((dpy)->lock_fns) (*(dpy)->lock_fns->unlock_display
)(dpy)
;
225 SyncHandle()if (dpy->synchandler) (*dpy->synchandler)(dpy);
226 return NULL((void*)0);
227}
228
229void
230XkbFreeComponentList(XkbComponentListPtr list)
231{
232 if (list) {
233 if (list->keymaps)
234 _FreeComponentNames(list->num_keymaps,list->keymaps);
235 if (list->keycodes)
236 _FreeComponentNames(list->num_keycodes,list->keycodes);
237 if (list->types)
238 _FreeComponentNames(list->num_types,list->types);
239 if (list->compat)
240 _FreeComponentNames(list->num_compat,list->compat);
241 if (list->symbols)
242 _FreeComponentNames(list->num_symbols,list->symbols);
243 if (list->geometry)
244 _FreeComponentNames(list->num_geometry,list->geometry);
245 bzero((char *)list,sizeof(XkbComponentListRec))memset((char *)list,0,sizeof(XkbComponentListRec));
246 _XkbFree(list)free((list));
247 }
248 return;
249}