Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at btsnoop.c:107

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

btsnoop_open

(/home/sate/Testcases/c/cve/wireshark-1.2.0/wiretap/btsnoop.c)expand/collapse
Show more  
 83  int btsnoop_open(wtap *wth, int *err, gchar **err_info _U_)
 84  {
 85          int bytes_read;
 86          char magic[sizeof btsnoop_magic];
 87          struct btsnoop_hdr hdr;
 88   
 89          int file_encap=WTAP_ENCAP_UNKNOWN;
 90   
 91          /* Read in the string that should be at the start of a "btsnoop" file */
 92          errno = WTAP_ERR_CANT_READ;
 93          bytes_read = file_read(magic, 1, sizeof magic, wth->fh);
 94          if (bytes_read != sizeof magic) {
 95                  *err = file_error(wth->fh);
 96                  if (*err != 0)
 97                          return -1;
 98                  return 0;
 99          }
 100          wth->data_offset += sizeof magic;
 101   
 102          if (memcmp(magic, btsnoop_magic, sizeof btsnoop_magic) != 0) {
 103                  return 0;
 104          }
 105   
 106          /* Read the rest of the header. */
 107          errno = WTAP_ERR_CANT_READ;
 108          bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
 109          if (bytes_read != sizeof hdr) {
 110                  *err = file_error(wth->fh);
 111                  if (*err != 0)
 112                          return -1;
 113                  return 0;
 114          }
 115          wth->data_offset += sizeof hdr;
 116   
 117          /*
 118           * Make sure it's a version we support.
 119           */
 120          hdr.version = g_ntohl(hdr.version);
 121          if (hdr.version != 1) {
 122                  *err = WTAP_ERR_UNSUPPORTED;
 123                  *err_info = g_strdup_printf("btsnoop: version %u unsupported", hdr.version);
 124                  return -1;
 125          }
 126   
 127          hdr.datalink = g_ntohl(hdr.datalink);
 128          switch (hdr.datalink) {
 129          case KHciLoggerDatalinkTypeH1:
 130                  file_encap=WTAP_ENCAP_BLUETOOTH_HCI;
 131                  break;
 132          case KHciLoggerDatalinkTypeBCSP:
 133          case KHciLoggerDatalinkTypeH5:
 134                  *err = WTAP_ERR_UNSUPPORTED;
 135                  *err_info = g_strdup_printf("btsnoop: BCSP/H5 capture logs %u unsupported", hdr.version);
 136                  return -1;
 137          case KHciLoggerDatalinkTypeH4:
 138                  file_encap=WTAP_ENCAP_BLUETOOTH_H4;
 139                  break;
 140          default:
 141                  *err = WTAP_ERR_UNSUPPORTED;
 142                  *err_info = g_strdup_printf("btsnoop: datalink %u unsupported", hdr.version);
 143                  return -1;
 144          }
 145   
 146          wth->subtype_read = btsnoop_read;
 147          wth->subtype_seek_read = btsnoop_seek_read;
 148          wth->file_encap = file_encap;
 149          wth->snapshot_length = 0;       /* not available in header */
 150          wth->tsprecision = WTAP_FILE_TSPREC_USEC;
 151          wth->file_type = WTAP_FILE_BTSNOOP;
 152          return 1;
 153  }
Show more  




Change Warning 965.29702 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: