(/home/sate/Testcases/c/cve/wireshark-1.2.0/epan/dissectors/packet-synphasor.c) |
| |
| 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 | | | |
| 322 | | | #if GLIB_CHECK_VERSION(2,10,0)
x /usr/include/glib-2.0/glib/gutils.h |
| |
438 | #define GLIB_CHECK_VERSION(major,minor,micro) \ |
439 | (GLIB_MAJOR_VERSION > (major) || \ |
440 | (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \ |
441 | (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \ |
442 | GLIB_MICRO_VERSION >= (micro))) |
| |
|
| 323 | | | frame = g_slice_new(config_frame);
x /usr/include/glib-2.0/glib/gslice.h |
| |
42 | #define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type))) |
| |
|
| 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)); |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 329 | | | |
| 330 | | | idcode = tvb_get_ntohs(tvb, 4); |
| 331 | | | frame->id = idcode; |
| 332 | | | |
| 333 | | | num_pmu = tvb_get_ntohs(tvb, 18); |
| 334 | | | offset = 20; |
| 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 | | | |
| 348 | | | block.phasors = g_array_new(FALSE, TRUE, sizeof(phasor_info)); |
| 349 | | | block.analogs = g_array_new(FALSE, TRUE, sizeof(analog_info)); |
| 350 | | | |
| 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 | | | |
| 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 | | | |
| 373 | | | for (i = 0; i != num_ph; i++) { |
| 374 | | | phasor_info pi; |
| 375 | | | guint32 conv; |
| 376 | | | |
| 377 | | | |
| 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);
x /usr/include/glib-2.0/glib/garray.h |
| |
65 | #define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) |
| |
|
| 386 | | | } |
| 387 | | | |
| 388 | | | |
| 389 | | | for (i = 0; i != num_an; i++) { |
| 390 | | | analog_info ai; |
| 391 | | | guint32 conv; |
| 392 | | | |
| 393 | | | |
| 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);
x /usr/include/glib-2.0/glib/garray.h |
| |
65 | #define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) |
| |
|
| 401 | | | } |
| 402 | | | |
| 403 | | | |
| 404 | | | |
| 405 | | | |
| 406 | | | |
| 407 | | | block.fnom = tvb_get_ntohs(tvb, fnom) & 0x0001 ? 50 : 60; |
| 408 | | | offset = fnom + 2; |
| 409 | | | |
| 410 | | | |
| 411 | | | offset += 2; |
| 412 | | | |
| 413 | | | g_array_append_val(frame->config_blocks, block);
x /usr/include/glib-2.0/glib/garray.h |
| |
65 | #define g_array_append_val(a,v) g_array_append_vals (a, &(v), 1) |
| |
|
| 414 | | | num_pmu--; |
| 415 | | | } |
| 416 | | | |
| 417 | | | return frame; |
| 418 | | | } |
| |