Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at disabled_protos.c:181

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

read_disabled_protos_list_file

(/home/sate/Testcases/c/cve/wireshark-1.2.0/disabled_protos.c)expand/collapse
Show more  
 166  read_disabled_protos_list_file(const char *ff_path, FILE *ff,
 167                                 GList **flp)
 168  {
 169    protocol_def *prot;
 170    int         c;
 171    char       *prot_name;
 172    int         prot_name_len;
 173    int         prot_name_index;
 174    int         line = 1;
 175   
 176   
 177    /* Allocate the protocol name buffer. */
 178    prot_name_len = INIT_BUF_SIZE;
 179    prot_name = g_malloc(prot_name_len + 1);
 180   
 181    for (line = 1; ; line++) {
 182      /* Lines in a disabled protocol file contain the "filter name" of 
 183         a protocol to be disabled. */
 184   
 185      /* Skip over leading white space, if any. */
 186      while ((c = getc(ff)) != EOF && isspace(c)) {
 187        if (c == '\n') {
 188          /* Blank line. */
 189          continue;
 190        }
 191      }
 192   
 193      if (c == EOF) {
 194        if (ferror(ff))
 195          goto error;     /* I/O error */
 196        else 
 197          break;  /* Nothing more to read */
 198      }
 199      ungetc(c, ff);      /* Unread the non-white-space character. */
 200   
 201      /* Get the name of the protocol. */
 202      prot_name_index = 0;
 203      for (;;) {
 204        c = getc(ff);
 205        if (c == EOF)
 206          break;  /* End of file, or I/O error */
 207        if (isspace(c))
 208          break;  /* Trailing white space, or end of line. */
 209        if (c == '#')
 210          break;  /* Start of comment, running to end of line. */
 211        /* Add this character to the protocol name string. */
 212        if (prot_name_index >= prot_name_len) {
 213          /* protocol name buffer isn't long enough; double its length. */
 214          prot_name_len *= 2;
 215          prot_name = g_realloc(prot_name, prot_name_len + 1);
 216        }
 217        prot_name[prot_name_index] = c;
 218        prot_name_index++;
 219      }
 220   
 221      if (isspace(c) && c != '\n') {
 222        /* Skip over trailing white space. */
 223        while ((c = getc(ff)) != EOF && c != '\n' && isspace(c))
 224          ;
 225        if (c != EOF && c != '\n' && c != '#') {
 226          /* Non-white-space after the protocol name; warn about it,
 227             in case we come up with a reason to use it. */
 228          g_warning("'%s' line %d has extra stuff after the protocol name.",
 229                    ff_path, line);
 230        }
 231      }
 232      if (c != EOF && c != '\n') {
 233        /* Skip to end of line. */
 234        while ((c = getc(ff)) != EOF && c != '\n')
 235          ;
 236      }
 237   
 238      if (c == EOF) {
 239        if (ferror(ff))
 240          goto error;     /* I/O error */
 241        else {
 242          /* EOF, not error; no newline seen before EOF */
 243          g_warning("'%s' line %d doesn't have a newline.", ff_path,
 244                    line);
 245        }
 246        break;    /* nothing more to read */
 247      }
 248   
 249      /* Null-terminate the protocol name. */
 250      if (prot_name_index >= prot_name_len) {
 251        /* protocol name buffer isn't long enough; double its length. */
 252        prot_name_len *= 2;
 253        prot_name = g_realloc(prot_name, prot_name_len + 1);
 254      }
 255      prot_name[prot_name_index] = '\0';
 256   
 257      /* Add the new protocol to the list of disabled protocols */
 258      prot         = (protocol_def *) g_malloc(sizeof(protocol_def));
 259      prot->name   = g_strdup(prot_name);
 260      *flp = g_list_append(*flp, prot);
 261    }
 262    g_free(prot_name);
 263    return 0;
 264   
 265  error:
 266    return errno;
 267  }
Show more  




Change Warning 4140.29913 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: