Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Unreachable Data Flow  at imalloc.c:295

Categories: LANG.STRUCT.UC CWE:561
Warning ID: 2616.2653
Similar Warnings: 2616.2652
Procedure: i_free
Trace: View
Modified: Wed Sep 2 12:42:17 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_free
279 i_free(loc) 
280         char *loc;              /* ptr to buffer */ 
281 {
282         struct glob *ob;        /* freeing this object */ 
283         struct glob *preob;     /* object before in chain */ 
284         int rs;                         /* reproduced random seqn */ 
285         char *ptr = loc;        /* gp */ 
286         struct glob **he;       /* hash tbl entry */ 
287         int i;                          /* gp */ 
288  
289         /* sanity check */ 
290  
291         if (firsttime) {
292                 char *s = "i_free: called before i_malloc?\n";
293                 SWRITE(debfd, s);
294                 i_choke();
295                 return 0;     /* Unreachable Data Flow */
296         }
297  
298         /* delete from hash tbl */ 
299  
300         he = &hashtbl[HASH(loc)];
301         for (preob = 0, ob = *he; ob && ob->base != loc; preob = ob, ob = ob->next);
302         if (!ob) {
303                 (void)sprintf(msbuf, "i_free: bogus loc=0x%lx\n", (long) loc);
304                 (void)SWRITE(debfd, msbuf);
305                 i_choke();
306                 return 0;   /* Unreachable Data Flow (ID: 2616.2652) */
307         }
308         rs = ob->rst;
309  
310         /* check head and tail pads */ 
311  
312         for (i = ob->lop, ptr -= i; i > 0; i--)
313                 if ((0xff & (int)(*ptr++)) != (0xff & NEXTRN(rs))) {
314                         (void)sprintf(msbuf, "i_free: scribbled in 0x%lx[%d]\n",
315                                 (long) loc, -i);
316                         (void)SWRITE(debfd, msbuf);
317                         i_choke();
318                 }
319         for (i = ob->hip, ptr += ob->len; i > 0; i--)
320                 if ((0xff & (int)(*ptr++)) != (0xff & NEXTRN(rs))) {
321                         (void)sprintf(msbuf, "i_free: scribbled in 0x%lx[%d+%d]\n",
322                                 (long) loc, ob->len, ob->hip - i);
323                         (void)SWRITE(debfd, msbuf);
324                         i_choke();
325                 }
326  
327         /* do actual free */ 
328  
329 #if     ZEROONFREE 
330         BZERO(loc - ob->lop, ob->len + ob->lop + ob->hip);
331 #endif 
332         free(loc - ob->lop);
333         totlnbyts -= ob->len;
334  
335         /* reclaim descriptor */ 
336  
337         if (preob)
338                 preob->next = ob->next;
339         else 
340                 *he = ob->next;
341 #if STATICGLOBS > 0 
342         ob->next = globfl;
343         globfl = ob;
344         globavail++; 
345 #else 
346         free((char*)ob);
347 #endif 
348         return 0;
349 




Change Warning 2616.2653 : Unreachable Data Flow

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