Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Redundant Condition  at pvmlog.c:391

Categories: LANG.STRUCT.RC CWE:570 CWE:571
Warning ID: 20.28602
Procedure: vpvmlogprintf
Trace: view
Modified: Thu Nov 26 11:27:03 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     
ProblemLineSource
   /kat0/fletcher/SATE/2010/pvm3/src/pvmlog.c
   Enter vpvmlogprintf
 368 vpvmlogprintf(fmt, ap) 
 369         char *fmt;
 370         va_list ap;
 371 {
 372         char vtmp[1024];
 373         char *truncated;
 374         int cnt = 0;
 375         int cc;
 376  
 377 #ifdef  TIMESTAMPLOG 
 378         time_t now;
 379         struct tm *tmp;
 380  
 381         time(&now);
 382         tmp = localtime(&now);
 383 #endif  /*TIMESTAMPLOG*/ 
 384  
 385         /* snag var arg string, in case re-use whacks it... */ 
 386         /* (thank you very much x86_64...  :-Q */ 
 387         /* damn, also need to prevent buffer overflows... */ 
 388         /* (thanks to Lasse Makholm <lasse.makholm@nokia.com> */ 
 389         /* for this patch...) */ 
 390         cc = vsnprintf(vtmp, sizeof(vtmp), fmt, ap);   /* Null Pointer Dereference (ID: 22037.28696) */  /* Null Pointer Dereference (ID: 22092.28939) */
Always True: cc >= 0391         truncated = ( cc >= 0 && cc < sizeof(vtmp) )     /* Redundant Condition */
 392                         ? "" : "[...]\n";
 393  
 394         if (log_how & 1) {
 395                 if (atnewline) {
 396                         if (pvmmytid)
 397                                 fprintf(stderr, "[t%x] ", pvmmytid);
 398                         else 
 399                                 fprintf(stderr, "[pvmd pid%d] ", pvmmyupid);
 400  
 401 #ifdef  TIMESTAMPLOG 
 402                         fprintf(stderr, "%02d/%02d %02d:%02d:%02d ",
 403                                                 tmp->tm_mon + 1,
 404                                                 tmp->tm_mday,
 405                                                 tmp->tm_hour,
 406                                                 tmp->tm_min,
 407                                                 tmp->tm_sec);
 408 #endif  /*TIMESTAMPLOG*/ 
 409                 }
 410                 /* cc = vfprintf(stderr, fmt, ap); */ 
 411                 cc = fprintf(stderr, "%s%s", vtmp, truncated);
 412                 cnt = ( cc >= 0 ) ? cnt + cc : cc;
 413                 fflush(stderr);
 414         }
 415  
 416         if (log_how & 2) {
 417                 if (log_alrdy < pvmdlogmax) {
 418                         if (atnewline) {
 419                                 if (pvmmytid)
 420                                         fprintf(log_ff, "[t%x] ", pvmmytid);
 421                                 else 
 422                                         fprintf(log_ff, "[pvmd pid%d] ", pvmmyupid);
 423  
 424 #ifdef  TIMESTAMPLOG 
 425                                 fprintf(log_ff, "%02d/%02d %02d:%02d:%02d ",
 426                                                 tmp->tm_mon + 1,
 427                                                 tmp->tm_mday,
 428                                                 tmp->tm_hour,
 429                                                 tmp->tm_min,
 430                                                 tmp->tm_sec);
 431 #endif  /*TIMESTAMPLOG*/ 
 432                         }
 433  
 434                         /* cc = vfprintf(log_ff, fmt, ap); */ 
 435                         cc = fprintf(log_ff, "%s%s", vtmp, truncated);
 436                         cnt = ( cnt >= 0 ) ? ( ( cc >= 0 ) ? cnt + cc : cc ) : cnt;
 437                         fflush(log_ff);
 438  
 439                         if ((log_alrdy += cnt) >= pvmdlogmax)
 440                                 (void)write(log_fd, toomuch, strlen(toomuch));
 441                 }
 442         }
 443  
 444         atnewline = (fmt[strlen(fmt) - 1] == '\n') ? 1 : 0;   /* Buffer Underrun (ID: 22036.28695) */  /* Buffer Underrun (ID: 22091.28938) */
 445  
 446 /*
 447         if ((log_how & 4) && hosts->ht_local != hosts->ht_cons) {
 448 XXX send error-log message to console host 
 449         }
 450 */ 
 451  
 452         return(cnt);
 453 } 




Change Warning 20.28602 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: