Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Redundant Condition  at ignore.c:135

Categories: LANG.STRUCT.RC CWE:570 CWE:571
Warning ID: 2112.2113
Procedure: ignore_check
Trace: View
Modified: Wed Sep 2 11:51: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     
ProblemLineSource
   /u1/paul/SATE/2010/c/irssi/irssi-0.8.14/src/core/ignore.c
   Enter ignore_check
 120 int ignore_check(SERVER_REC *server, const char *nick, const char *host,
 121                  const char *channel, const char *text, int level) 
 122 {
 123         CHANNEL_REC *chanrec;
 124         NICK_REC *nickrec;
 125         IGNORE_REC *rec;
 126         GSList *tmp;
 127         char *nickmask;
 128         int len, best_mask, best_match, best_patt;
 129  
 130         g_return_val_if_fail(server != NULL, 0);
 131         if (nick == NULL) nick = "";
 132  
 133         chanrec = server == NULL || channel == NULL ? NULL :   /* Redundant Condition (ID: 2111.2112) */
 134                 channel_find(server, channel);
Always True: nick != (void*)0135         if (chanrec != NULL && nick != NULL &&     /* Redundant Condition */
 136             (nickrec = nicklist_find(chanrec, nick)) != NULL) {
 137                 /* nick found - check only ignores in nickmatch cache */ 
 138                 if (nickrec->host == NULL)
 139                         nicklist_set_host(chanrec, nickrec, host);
 140  
 141                 tmp = nickmatch_find(nickmatch, nickrec);
 142                 nickmask = NULL;
 143         } else {
 144                 tmp = ignores;
 145                 nickmask = g_strconcat(nick, "!", host, NULL);
 146         }
 147  
 148         best_mask = best_patt = -1; best_match = FALSE;
 149         for (; tmp != NULL; tmp = tmp->next) {
 150                 int match = 1;
 151                 rec = tmp->data;
 152  
 153                 if (nickmask != NULL)
 154                         match = ignore_match_server(rec, server) && 
 155                                 ignore_match_channel(rec, channel) && 
 156                                 ignore_match_nickmask(rec, nick, nickmask);
 157                 if (match &&
 158                     ignore_match_level(rec, level) &&
 159                     ignore_match_pattern(rec, text)) {
 160                         len = rec->mask == NULL ? 0 : strlen(rec->mask);
 161                         if (len > best_mask) {
 162                                 best_mask = len;
 163                                 best_match = !rec->exception;
 164                         } else if (len == best_mask) {
 165                                 len = rec->pattern == NULL ? 0 : strlen(rec->pattern);
 166                                 if (len > best_patt) {
 167                                         best_patt = len;
 168                                         best_match = !rec->exception;
 169                                 } else if (len == best_patt && rec->exception)
 170                                         best_match = 0;
 171                         }
 172                 }
 173         }
 174         g_free(nickmask);
 175  
 176         if (best_match || (level & MSGLEVEL_PUBLIC) == 0)
 177                 return best_match;
 178  
 179         return ignore_check_replies(chanrec, text);
 180 




Change Warning 2112.2113 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: