Text  |   XML   |   Visible Warnings:

Irssi : Irssi analysis 1 : Redundant Condition  at net-nonblock.c:172

Categories: LANG.STRUCT.RC CWE:570 CWE:571
Warning ID: 2122.2123
Procedure: net_gethostbyname_return
Trace: View
Modified: Wed Sep 2 11:51:22 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/net-nonblock.c
   Enter net_gethostbyname_return
 152 int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec) 
 153 {
 154         int len;
 155  
 156         rec->error = -1;
 157         rec->errorstr = NULL;
 158         rec->host4 = NULL;
 159         rec->host6 = NULL;
 160  
 161 #ifndef WIN32 
 162         fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
 163 #endif 
 164  
 165         /* get ip+error */ 
 166         if (g_io_channel_read_block(pipe, rec, sizeof(*rec)) == -1) {
 167                 rec->errorstr = g_strdup_printf("Host name lookup: %s",
 168                                                 g_strerror(errno));
 169                 return -1;
 170         }
 171  
Always True: rec->error != 0172         if (rec->error) {     /* Redundant Condition */
 173                 /* read error string, if we can't read everything for some 
 174                    reason, just ignore it. */ 
 175                 rec->errorstr = g_malloc0(rec->errlen+1);
 176                 g_io_channel_read_block(pipe, rec->errorstr, rec->errlen);
 177         } else {
 178                 if (rec->host4) {   /* Unreachable Call (ID: 2123.2124) */
 179                         g_io_channel_read_block(pipe, &len, sizeof(int));
 180                         rec->host4 = g_malloc0(len);
 181                         g_io_channel_read_block(pipe, rec->host4, len);
 182                 }
 183                 if (rec->host6) {
 184                         g_io_channel_read_block(pipe, &len, sizeof(int));
 185                         rec->host6 = g_malloc0(len);
 186                         g_io_channel_read_block(pipe, rec->host6, len);
 187                 }
 188         }
 189  
 190         return 0;
 191 




Change Warning 2122.2123 : Redundant Condition

Priority:
State:
Finding:
Owner:
Note: