Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at ringbuffer.c:190

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

ringbuf_init

(/home/sate/Testcases/c/cve/wireshark-1.2.0/ringbuffer.c)expand/collapse
Show more  
 139  ringbuf_init(const char *capfile_name, guint num_files)
 140  {
 141    unsigned int i;
 142    char        *pfx, *last_pathsep;
 143    gchar       *save_file;
 144   
 145    rb_data.files = NULL;
 146    rb_data.curr_file_num = 0;
 147    rb_data.fprefix = NULL;
 148    rb_data.fsuffix = NULL;
 149    rb_data.unlimited = FALSE;
 150    rb_data.fd = -1;
 151    rb_data.pdh = NULL;
 152   
 153    /* just to be sure ... */
 154    if (num_files <= RINGBUFFER_MAX_NUM_FILES) {
 155      rb_data.num_files = num_files;
 156    } else {
 157      rb_data.num_files = RINGBUFFER_MAX_NUM_FILES;
 158    }
 159   
 160    /* Check file name */
 161    if (capfile_name == NULL) {
 162      /* ringbuffer does not work with temporary files! */
 163      return -1;
 164    }
 165   
 166    /* set file name prefix/suffix */
 167   
 168    save_file = g_strdup(capfile_name);
 169    last_pathsep = strrchr(save_file, G_DIR_SEPARATOR);
 170    pfx = strrchr(save_file,'.');
 171    if (pfx != NULL && (last_pathsep == NULL || pfx > last_pathsep)) {
 172      /* The pathname has a "." in it, and it's in the last component
 173         of the pathname (because there is either only one component,
 174         i.e. last_pathsep is null as there are no path separators,
 175         or the "." is after the path separator before the last
 176         component.
 177   
 178         Treat it as a separator between the rest of the file name and
 179         the file name suffix, and arrange that the names given to the
 180         ring buffer files have the specified suffix, i.e. put the
 181         changing part of the name *before* the suffix. */
 182      pfx[0] = '\0';
 183      rb_data.fprefix = g_strdup(save_file);
 184      pfx[0] = '.'; /* restore capfile_name */
 185      rb_data.fsuffix = g_strdup(pfx);
 186    } else {
 187      /* Either there's no "." in the pathname, or it's in a directory 
 188         component, so the last component has no suffix. */
 189      rb_data.fprefix = g_strdup(save_file);
 190      rb_data.fsuffix = NULL;
 191    }
 192    g_free(save_file);
 193    save_file = NULL;
 194   
 195    /* allocate rb_file structures (only one if unlimited since there is no 
 196       need to save all file names in that case) */
 197   
 198    if (num_files == RINGBUFFER_UNLIMITED_FILES) {
 199      rb_data.unlimited = TRUE;
 200      rb_data.num_files = 1;
 201    }
 202   
 203    rb_data.files = g_malloc(rb_data.num_files * sizeof(rb_file));
 204    if (rb_data.files == NULL) {
 205      return -1;
 206    }
 207   
 208    for (i=0; i < rb_data.num_files; i++) {
 209      rb_data.files[i].name = NULL;
 210    }
 211   
 212    /* create the first file */
 213    if (ringbuf_open_file(&rb_data.files[0], NULL) == -1) {
 214      ringbuf_error_cleanup();
 215      return -1;
 216    }
 217   
 218    return rb_data.fd;
 219  }
Show more  




Change Warning 5028.30231 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: