Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at visual.c:204

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

visual_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/visual.c)expand/collapse
Show more  
 180  int visual_open(wtap *wth, int *err, gchar **err_info)
 181  {
 182      int bytes_read;
 183      char magic[sizeof visual_magic];
 184      struct visual_file_hdr vfile_hdr;
 185      struct visual_read_info * visual;
 186      int encap;
 187   
 188      /* Check the magic string at the start of the file */
 189      errno = WTAP_ERR_CANT_READ;
 190      bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
 191      if (bytes_read != sizeof magic)
 192      {
 193          *err = file_error(wth->fh);
 194          if (*err != 0)
 195              return -1;
 196          return 0;
 197      }
 198      if (memcmp(magic, visual_magic, sizeof visual_magic) != 0)
 199      {
 200          return 0;
 201      }
 202   
 203      /* Read the rest of the file header. */
 204      errno = WTAP_ERR_CANT_READ;
 205      bytes_read = file_read(&vfile_hdr, 1, sizeof vfile_hdr, wth->fh);
 206      if (bytes_read != sizeof vfile_hdr)
 207      {
 208          *err = file_error(wth->fh);
 209          if (*err != 0)
 210              return -1;
 211          return 0;
 212      }
 213   
 214      /* Verify the file version is known */
 215      vfile_hdr.file_version = pletohs(&vfile_hdr.file_version);
 216      if (vfile_hdr.file_version != 1)
 217      {
 218          *err = WTAP_ERR_UNSUPPORTED;
 219          *err_info = g_strdup_printf("visual: file version %u unsupported", vfile_hdr.file_version);
 220          return -1;
 221      }
 222   
 223      /* Translate the encapsulation type; these values are SNMP ifType 
 224         values, as found in http://www.iana.org/assignments/smi-numbers.
 225   
 226         Note that a file with media type 22 ("propPointToPointSerial") may 
 227         contain Cisco HDLC or PPP over HDLC.  This will get sorted out after 
 228         the first packet is read.
 229   
 230         XXX - should we use WTAP_ENCAP_PER_PACKET for that? */
 231      switch (pletohs(&vfile_hdr.media_type))
 232      {
 233      case  6:    /* ethernet-csmacd */
 234          encap = WTAP_ENCAP_ETHERNET;
 235          break;
 236   
 237      case  9:    /* IEEE802.5 */
 238          encap = WTAP_ENCAP_TOKEN_RING;
 239          break;
 240   
 241      case 16:    /* lapb */
 242          encap = WTAP_ENCAP_LAPB;
 243          break;
 244   
 245      case 22:    /* propPointToPointSerial */
 246      case 118:   /* HDLC */
 247          encap = WTAP_ENCAP_CHDLC_WITH_PHDR;
 248          break;
 249   
 250      case 32:    /* frame-relay */
 251          encap = WTAP_ENCAP_FRELAY_WITH_PHDR;
 252          break;
 253   
 254      case 37:    /* ATM */
 255         encap = WTAP_ENCAP_ATM_PDUS;
 256         break;
 257   
 258      default:
 259          *err = WTAP_ERR_UNSUPPORTED_ENCAP;
 260          *err_info = g_strdup_printf("visual: network type %u unknown or unsupported",
 261                                       vfile_hdr.media_type);
 262          return -1;
 263      }
 264   
 265      /* Fill in the wiretap struct with data from the file header */
 266      wth->file_type = WTAP_FILE_VISUAL_NETWORKS;
 267      wth->file_encap = encap;
 268      wth->snapshot_length = pletohs(&vfile_hdr.max_length);
 269   
 270      /* Save the pointer to the beginning of the packet data so 
 271         that the later seek_reads work correctly. */
 272      wth->data_offset = CAPTUREFILE_HEADER_SIZE;
 273   
 274      /* Set up the pointers to the handlers for this file type */
 275      wth->subtype_read = visual_read;
 276      wth->subtype_seek_read = visual_seek_read;
 277      wth->subtype_close = visual_close;
 278           wth->tsprecision = WTAP_FILE_TSPREC_USEC;
 279   
 280      /* Add Visual-specific information to the wiretap struct for later use. */
 281      visual = g_malloc(sizeof(struct visual_read_info));
 282      wth->capture.generic = visual;
 283      visual->num_pkts = pletohl(&vfile_hdr.num_pkts);
 284      visual->start_time = ((double) pletohl(&vfile_hdr.start_time)) * 1000000;
 285      visual->current_pkt = 1;
 286   
 287      return 1;
 288  }
Show more  




Change Warning 1059.29706 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: