Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Unreachable Computation  at imalloc.c:248

Categories: LANG.STRUCT.UC CWE:561
Warning ID: 2615.2651
Similar Warnings: 2615.2649, 2615.2650
Procedure: i_malloc
Trace: View
Modified: Wed Sep 2 12:42:16 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
LineSource
  /u1/paul/SATE/2010/c/pvm/pvm3/src/imalloc.c
  Enter i_malloc
182 char* 
183 i_malloc(len, tag) 
184         unsigned len;   /* number of bytes */ 
185         char *tag;              /* content description */ 
186 {
187         char *ptr;
188         struct glob *ob;        /* hash tbl entry */ 
189         struct glob **he;
190         int i;                          /* gp */ 
191  
192         if (firsttime) {
193                 firsttime = 0;
194                 BZERO((char*)hashtbl, sizeof(hashtbl));
195  
196 #if     STATICGLOBS > 0 
197         /* initialize the glob freelist */ 
198                 ob = 0;
199                 for (i = STATICGLOBS-1; i >= 0; i--) {
200                         globheap[i].next = ob;
201                         ob = &globheap[i];
202                 }
203                 globfl = ob; 
204 #endif 
205         }
206  
207         /* check req length */ 
208  
209 #if LET0BE1 > 0 
210         if (!len)
211                 len = 1;
212 #endif 
213         if (len < 1 || len > lengthlimit) {
214                 (void)sprintf(msbuf, "i_malloc: bogus len=%d\n", len);
215                 (void)SWRITE(debfd, msbuf);
216                 i_choke();
217                 return (char*)0;   /* Unreachable Computation (ID: 2615.2649) */
218         }
219  
220         /* do actual malloc */ 
221  
222         if (!(ptr = (char*)malloc(len + lopad + hipad))) {
223                 (void)sprintf(msbuf, "i_malloc: malloc failed len=%d\n", len);
224                 (void)SWRITE(debfd, msbuf);
225                 i_choke();
226                 return (char*)0;   /* Unreachable Computation (ID: 2615.2650) */
227         }
228  
229         /* get descriptor */ 
230  
231 #if STATICGLOBS > 0 
232         if (ob = globfl) {
233                 globfl = globfl->next;
234                 globavail--;
235  
236         } else {
237                 (void)sprintf(msbuf, "i_malloc: glob allocate failed (max %d)\n",
238                         STATICGLOBS);
239                 (void)SWRITE(debfd, msbuf);
240                 i_choke();
241                 return (char*)0;
242         } 
243 #else 
244         if (!(ob = (struct glob*)malloc(sizeof(struct glob)))) {
245                 (void)sprintf(msbuf, "i_malloc: malloc failed for glob\n");
246                 (void)SWRITE(debfd, msbuf);
247                 i_choke();
248                 return (char*)0;     /* Unreachable Computation */
249         }
250 #endif 
251  
252         /* enter descriptor, write head and tail pads */ 
253  
254         ob->flg = OBALLOC;
255         ob->id = ++globid;
256         ob->tag[0] = 0;
257         if (tag)
258                 strncpy(ob->tag, tag, 4);
259         ob->len = len;
260         ob->lop = lopad;
261         ob->hip = hipad;
262         ob->rst = rnstate;
263         for (i = lopad; i-- > 0; *ptr++ = NEXTRN(rnstate));
264         ob->base = ptr;
265         he = &hashtbl[HASH(ptr)];
266         for (i = hipad, ptr += len; i-- > 0; *ptr++ = NEXTRN(rnstate));
267         ob->next = *he;
268         *he = ob;
269         totlnbyts += len;
270         return ob->base;
271 




Change Warning 2615.2651 : Unreachable Computation

Because they are very similar, this warning shares annotations with warnings 2615.2649 and 2615.2650.
CodeSonar has selected warning 2615.2649 to represent this group of similar warnings. In order to edit this group, you must edit warning 2615.2649.