Text  |   XML   |   Visible Warnings:

irssi-0.8.14 : irssi-0.8.14 analysis 2 : Redundant Condition  at log.c:214

Categories: LANG.STRUCT.RC CWE:570 CWE:571
Warning ID: 5519.28262
Procedure: log_write_rec
Trace: view
Modified: Thu Nov 26 11:08:24 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/irssi-0.8.14/src/core/log.c
   Enter log_write_rec
 194 void log_write_rec(LOG_REC *log, const char *str, int level) 
 195 {
 196         char *colorstr;
 197         struct tm *tm;
 198         time_t now;
 199         int hour, day;
 200  
 201         g_return_if_fail(log != NULL);
 202         g_return_if_fail(str != NULL);
 203  
 204         if (log->handle == -1)
 205                 return;
 206  
 207         now = time(NULL);
 208         tm = localtime(&now);
 209         hour = tm->tm_hour;
 210         day = tm->tm_mday;
 211  
 212         tm = localtime(&log->last);   /* Useless Assignment (ID: 5517.28261) */
 213         day -= tm->tm_mday; /* tm breaks in log_rotate_check() .. */ 
Never True: tm->tm_hour != hour214         if (tm->tm_hour != hour) {     /* Redundant Condition */
 215                 /* hour changed, check if we need to rotate log file */ 
 216                 log_rotate_check(log);   /* Unreachable Call (ID: 5521.28263) */
 217         }
 218  
 219         if (day != 0) {
 220                 /* day changed */ 
 221                 log_write_timestamp(log->handle,
 222                                     settings_get_str("log_day_changed"),
 223                                     "\n", now);
 224         }
 225  
 226         log->last = now;
 227  
 228         if (log->colorizer == NULL)
 229                 colorstr = NULL;
 230         else 
 231                 str = colorstr = log->colorizer(str);
 232  
 233         if ((level & MSGLEVEL_LASTLOG) == 0)
 234                 log_write_timestamp(log->handle, log_timestamp, str, now);
 235         else 
 236                 write_buffer(log->handle, str, strlen(str));
 237         write_buffer(log->handle, "\n", 1);
 238  
 239         signal_emit("log written", 2, log, str);
 240  
 241         g_free_not_null(colorstr);
 242 } 




Change Warning 5519.28262 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: