Text   |  XML   |  ReML   |   Visible Warnings:

Useless Assignment  at packet-synphasor.c:328

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

config_frame_fast

(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-synphasor.c)expand/collapse
Show more  
 315  static config_frame* config_frame_fast(tvbuff_t *tvb)
 316  {
 317          guint16       idcode, num_pmu;
 318          gint          offset;
 319          config_frame *frame;
 320   
 321          /* get a new frame and initialize it */
 322  #if GLIB_CHECK_VERSION(2,10,0)
 323          frame = g_slice_new(config_frame);
 324  #else
 325          frame = g_mem_chunk_alloc(frame_chunks);
 326  #endif
 327   
 328          frame->config_blocks = g_array_new(FALSE, TRUE, sizeof(config_block));
 329   
 330          idcode = tvb_get_ntohs(tvb, 4);
 331          frame->id       = idcode;
 332   
 333          num_pmu = tvb_get_ntohs(tvb, 18);
 334          offset = 20; /* start of repeating blocks */
 335   
 336          while (num_pmu) {
 337                  guint16      format_flags;
 338                  gint         num_ph,
 339                               num_an,
 340                               num_dg;
 341                  gint         i,
 342                               phunit,
 343                               anunit,
 344                               fnom;
 345                  config_block block;
 346   
 347                  /* initialize the block */
 348                  block.phasors = g_array_new(FALSE, TRUE, sizeof(phasor_info));
 349                  block.analogs = g_array_new(FALSE, TRUE, sizeof(analog_info));
 350                  /* copy the station name from the tvb to block, and add NULL byte */
 351                  tvb_memcpy(tvb, block.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
 352                  block.name[CHNAM_LEN] = '\0';
 353   
 354                  block.id = tvb_get_ntohs(tvb, offset); offset += 2;
 355   
 356                  format_flags          = tvb_get_ntohs(tvb, offset); offset += 2;
 357                  block.format_fr       = (format_flags & 0x0008) ? floating_point : integer;
 358                  block.format_an       = (format_flags & 0x0004) ? floating_point : integer;
 359                  block.format_ph       = (format_flags & 0x0002) ? floating_point : integer;
 360                  block.phasor_notation = (format_flags & 0x0001) ? polar          : rect;
 361   
 362                  num_ph = tvb_get_ntohs(tvb, offset); offset += 2;
 363                  num_an = tvb_get_ntohs(tvb, offset); offset += 2;
 364                  num_dg = tvb_get_ntohs(tvb, offset); offset += 2;
 365                  block.num_dg = num_dg;
 366   
 367                  /* the offset of the PHUNIT, ANUNIT, and FNOM blocks */
 368                  phunit = offset + (num_ph + num_an + num_dg * CHNAM_LEN) * CHNAM_LEN;
 369                  anunit = phunit + num_ph * 4;
 370                  fnom   = anunit + num_an * 4 + num_dg * 4;
 371   
 372                  /* read num_ph phasor names and conversation factors */
 373                  for (i = 0; i != num_ph; i++) {
 374                          phasor_info  pi;
 375                          guint32      conv;
 376                           
 377                          /* copy the phasor name from the tvb, and add NULL byte */
 378                          tvb_memcpy(tvb, pi.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
 379                          pi.name[CHNAM_LEN] = '\0';
 380                           
 381                          conv = tvb_get_ntohl(tvb, phunit + 4 * i);
 382                          pi.unit = conv & 0xFF000000 ? A : V;
 383                          pi.conv = conv & 0x00FFFFFF;
 384   
 385                          g_array_append_val(block.phasors, pi);
 386                  }
 387   
 388                  /* read num_an analog value names and conversation factors */
 389                  for (i = 0; i != num_an; i++) {
 390                          analog_info ai;
 391                          guint32     conv;
 392   
 393                          /* copy the phasor name from the tvb, and add NULL byte */
 394                          tvb_memcpy(tvb, ai.name, offset, CHNAM_LEN); offset += CHNAM_LEN;
 395                          ai.name[CHNAM_LEN] = '\0';
 396   
 397                          conv = tvb_get_ntohl(tvb, anunit + 4 * i);
 398                          ai.conv = conv;
 399   
 400                          g_array_append_val(block.analogs, ai);
 401                  }
 402   
 403                  /* the names for the bits in the digital status words aren't saved,
 404                     there is no space to display them in the GUI anyway */
 405   
 406                  /* save FNOM */
 407                  block.fnom = tvb_get_ntohs(tvb, fnom) & 0x0001 ? 50 : 60;
 408                  offset = fnom + 2;
 409   
 410                  /* skip CFGCNT */
 411                  offset += 2;
 412   
 413                  g_array_append_val(frame->config_blocks, block);
 414                  num_pmu--;
 415          }
 416   
 417          return frame;
 418  }
Show more  




Change Warning 3004.31292 : Useless Assignment

Priority:
State:
Finding:
Owner:
Note: