Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Redundant Condition  at gui-readline.c:402

Categories: LANG.STRUCT.RC CWE:570 CWE:571
Warning ID: 2369.2380
Procedure: check_pasting
Trace: View
Modified: Wed Sep 2 12:22:05 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
   /u1/paul/SATE/2010/c/irssi/irssi-0.8.14/src/fe-text/gui-readline.c
   Enter check_pasting
 381 static int check_pasting(unichar key, int diff) 
 382 {
 383         if (paste_state < 0)
 384                 return FALSE;
 385  
 386         if (paste_state == 0) {
 387                 /* two keys hit together quick. possibly pasting */ 
 388                 if (diff > paste_detect_time)
 389                         return FALSE;
 390  
 391                 g_free(paste_entry);
 392                 paste_entry = gui_entry_get_text(active_entry);
 393                 paste_entry_pos = gui_entry_get_pos(active_entry);
 394  
 395                 paste_state++;
 396                 paste_line_count = 0;
 397                 paste_keycount = 0;
 398                 g_array_set_size(paste_buffer, 0);
 399                 if (prev_key != '\r' && prev_key != '\n') {
 400                         paste_keycount++;
 401                 }
Always True: paste_state > 0402         } else if (paste_state > 0 && diff > paste_detect_time &&     /* Redundant Condition */
 403                    paste_line_count == 0) {
 404                 /* reset paste state */ 
 405                 paste_state = 0;
 406                 return FALSE;
 407         }
 408  
 409         /* continuing quick hits */ 
 410         if (paste_prompt) {
 411                 if (key == 11 || key == 3)
 412                         paste_flush(key == 11);
 413                 return TRUE;
 414         }
 415  
 416         g_array_append_val(paste_buffer, key);
 417         if ((key == '\r' || key == '\n') &&
 418             (prev_key != '\r' && prev_key != '\n')) {
 419                 if (paste_state == 1) {
 420                         if (paste_keycount < paste_detect_keycount) {
 421                                 /* not enough keypresses to determine if this is 
 422                                    pasting or not. don't reset paste_keycount, but 
 423                                    send this line as non-pasted */ 
 424                                 g_array_set_size(paste_buffer, 0);
 425                                 *paste_entry = '\0';
 426                                 return FALSE;
 427                         }
 428  
 429                         /* newline - assume this line was pasted */ 
 430                         paste_state = 2;
 431                         gui_entry_set_text(active_entry, paste_entry);
 432                         gui_entry_set_pos(active_entry, paste_entry_pos);
 433                         if (paste_verify_line_count > 0)
 434                                 g_timeout_add(100, paste_timeout, NULL);
 435                 }
 436  
 437                 if (paste_verify_line_count <= 0) {
 438                         /* paste previous line */ 
 439                         paste_send();
 440                         g_array_set_size(paste_buffer, 0);
 441                 } else {
 442                         paste_line_count++;
 443                 }
 444         }
 445  
 446         return paste_state == 2;
 447 




Change Warning 2369.2380 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: