Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Unreachable Computation  at imalloc.c:437

Categories: LANG.STRUCT.UC CWE:561
Warning ID: 200.28830
Similar Warnings: 200.28829, 200.28831, 200.28832
Procedure: i_realloc
Trace: view
Modified: Thu Nov 26 11:28:11 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
  /kat0/fletcher/SATE/2010/pvm3/src/imalloc.c
  Enter i_realloc
359 char* 
360 i_realloc(loc, len) 
361         char *loc;                      /* old buffer */ 
362         unsigned len;           /* length of new buffer */ 
363 {
364         struct glob *ob;        /* freeing this object */ 
365         struct glob *preob;     /* object before in chain */ 
366         int rs;                         /* reproduced random seqn */ 
367         char *ptr = loc;        /* gp */ 
368         struct glob **he;       /* hash tbl entry */ 
369         int i;                          /* gp */ 
370  
371         /* sanity check */ 
372  
373         if (firsttime) {
374                 char *s = "i_realloc: called before i_malloc?\n";
375                 SWRITE(debfd, s);
376                 i_choke();
377                 return (char*)0;   /* Unreachable Computation (ID: 200.28831) */
378         }
379  
380         /* check req length */ 
381  
382 #if LET0BE1 > 0 
383         if (!len)
384                 len = 1;
385 #endif 
386         if (len < 1 || len > lengthlimit) {
387                 (void)sprintf(msbuf, "i_realloc: bogus len=%d\n", len);
388                 (void)SWRITE(debfd, msbuf);
389                 i_choke();
390                 return (char*)0;   /* Unreachable Computation (ID: 200.28829) */
391         }
392  
393         /* delete from hash tbl */ 
394  
395         he = &hashtbl[HASH(loc)];
396         for (preob = 0, ob = *he; ob && ob->base != loc; preob = ob, ob = ob->next);
397         if (!ob) {
398                 (void)sprintf(msbuf, "i_realloc: bogus loc=0x%lx\n",
399                         (long) loc);
400                 (void)SWRITE(debfd, msbuf);
401                 i_choke();
402                 return (char*)0;   /* Unreachable Computation (ID: 200.28832) */
403         }
404         rs = ob->rst;
405  
406         /* check head and tail pads */ 
407  
408         for (i = ob->lop, ptr -= i; i > 0; i--)
409                 if ((0xff & (int)(*ptr++)) != (0xff & NEXTRN(rs))) {
410                         (void)sprintf(msbuf, "i_realloc: scribbled in 0x%lx[%d]\n",
411                                 (long) loc, -i);
412                         (void)SWRITE(debfd, msbuf);
413                         i_choke();
414                 }
415         for (i = ob->hip, ptr += ob->len; i > 0; i--)
416                 if ((0xff & (int)(*ptr++)) != (0xff & NEXTRN(rs))) {
417                         (void)sprintf(msbuf,
418                                 "i_realloc: scribbled in 0x%lx[%d+%d]\n",
419                                 (long) loc, ob->len, ob->hip - i);
420                         (void)SWRITE(debfd, msbuf);
421                         i_choke();
422                 }
423  
424         /* remove descriptor */ 
425  
426         if (preob)
427                 preob->next = ob->next;
428         else 
429                 *he = ob->next;
430  
431         /* realloc */ 
432  
433         if (!(ptr = (char*)realloc(loc - ob->lop, len + lopad + hipad))) {
434                 (void)sprintf(msbuf, "i_realloc: malloc failed len=%d\n", len);
435                 (void)SWRITE(debfd, msbuf);
436                 i_choke();
437                 return (char*)0;     /* Unreachable Computation */
438         }
439  
440         /* rewrite descriptor, write head and tail pads */ 
441  
442         totlnbyts += len - ob->len;
443         ob->flg = OBREALLOC;
444         ob->id = ++globid;      /* XXX ? */ 
445         ob->len = len;
446         ob->lop = lopad;
447         ob->hip = hipad;
448         ob->rst = rnstate;
449         for (i = lopad; i-- > 0; *ptr++ = NEXTRN(rnstate));
450         ob->base = ptr;
451         he = &hashtbl[HASH(ptr)];
452         for (i = hipad, ptr += len; i-- > 0; *ptr++ = NEXTRN(rnstate));
453         ob->next = *he;
454         *he = ob;
455         return ob->base;
456 } 




Change Warning 200.28830 : Unreachable Computation

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