Text   |  XML   |  ReML   |   Visible Warnings:

Unreachable Control Flow  at filters.c:490

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

save_filter_list

(/home/sate/Testcases/c/cve/wireshark-1.2.0/filters.c)expand/collapse
Show more  
 463  save_filter_list(filter_list_type_t list_type, char **pref_path_return,
 464      int *errno_return)
 465  {
 466    const gchar *ff_name;
 467    gchar      *ff_path, *ff_path_new;
 468    GList      *fl;
 469    GList      *flpp;
 470    filter_def *filt;
 471    FILE       *ff;
 472    guchar     *p, c;
 473   
 474    *pref_path_return = NULL;     /* assume no error */
 475   
 476    switch (list_type) {
 477   
 478    case CFILTER_LIST:
 479      ff_name = CFILTER_FILE_NAME;
 480      fl = capture_filters;
 481      break;
 482   
 483    case DFILTER_LIST:
 484      ff_name = DFILTER_FILE_NAME;
 485      fl = display_filters;
 486      break;
 487   
 488    default:
 489      g_assert_not_reached();
 490      return;
 491    }
 492   
 493    ff_path = get_persconffile_path(ff_name, TRUE, TRUE);
 494   
 495    /* Write to "XXX.new", and rename if that succeeds.
 496       That means we don't trash the file if we fail to write it out
 497       completely. */
 498    ff_path_new = g_strdup_printf("%s.new", ff_path);
 499   
 500    if ((ff = ws_fopen(ff_path_new, "w")) == NULL) {
 501      *pref_path_return = ff_path;
 502      *errno_return = errno;
 503      g_free(ff_path_new);
 504      return;
 505    }
 506    flpp = g_list_first(fl);
 507    while (flpp) {
 508      filt = (filter_def *) flpp->data;
 509   
 510      /* Write out the filter name as a quoted string; escape any quotes 
 511         or backslashes. */
 512      putc('"', ff);
 513      for (p = (guchar *)filt->name; (c = *p) != '\0'; p++) {
 514        if (c == '"' || c == '\\')
 515          putc('\\', ff);
 516        putc(c, ff);
 517      }
 518      putc('"', ff);
 519   
 520      /* Separate the filter name and value with a space. */
 521      putc(' ', ff);
 522   
 523      /* Write out the filter expression and a newline. */
 524      fprintf(ff, "%s\n", filt->strval);
 525      if (ferror(ff)) {
 526        *pref_path_return = ff_path;
 527        *errno_return = errno;
 528        fclose(ff);
 529        ws_unlink(ff_path_new);
 530        g_free(ff_path_new);
 531        return;
 532      }
 533      flpp = flpp->next;
 534    }
 535    if (fclose(ff) == EOF) {
 536      *pref_path_return = ff_path;
 537      *errno_return = errno;
 538      ws_unlink(ff_path_new);
 539      g_free(ff_path_new);
 540      return;
 541    }
 542   
 543  #ifdef _WIN32 
 544    /* ANSI C doesn't say whether "rename()" removes the target if it 
 545       exists; the Win32 call to rename files doesn't do so, which I
 546       infer is the reason why the MSVC++ "rename()" doesn't do so.
 547       We must therefore remove the target file first, on Windows. */
 548    if (ws_remove(ff_path) < 0 && errno != ENOENT) {
 549      /* It failed for some reason other than "it's not there"; if 
 550         it's not there, we don't need to remove it, so we just 
 551         drive on. */
 552      *pref_path_return = ff_path;
 553      *errno_return = errno;
 554      ws_unlink(ff_path_new);
 555      g_free(ff_path_new);
 556      return;
 557    }
 558  #endif
 559   
 560    if (ws_rename(ff_path_new, ff_path) < 0) {
 561      *pref_path_return = ff_path;
 562      *errno_return = errno;
 563      ws_unlink(ff_path_new);
 564      g_free(ff_path_new);
 565      return;
 566    }
 567    g_free(ff_path_new);
 568    g_free(ff_path);
 569  }
Show more  




Change Warning 4065.30379 : Unreachable Control Flow

Priority:
State:
Finding:
Owner:
Note: