(/home/sate/Testcases/c/cve/wireshark-1.2.0/tap-iostat.c) |
| |
| 615 | | | iostat_init(const char *optarg, void* userdata _U_) |
| 616 | | | { |
| 617 | | | float interval_float; |
| 618 | | | gint32 interval; |
| 619 | | | int pos=0; |
| 620 | | | io_stat_t *io; |
| 621 | | | const char *filter=NULL; |
| 622 | | | |
| 623 | | | if(sscanf(optarg,"io,stat,%f,%n",&interval_float,&pos)==1){ |
| 624 | | | if(pos){ |
| 625 | | | filter=optarg+pos; |
| 626 | | | } else { |
| 627 | | | filter=NULL; |
Useless Assignment
This code assigns the variable the same value it already had. |
|
| 628 | | | } |
| 629 | | | } else { |
| 630 | | | fprintf(stderr, "tshark: invalid \"-z io,stat,<interval>[,<filter>]\" argument\n"); |
| 631 | | | exit(1); |
| 632 | | | } |
| 633 | | | |
| 634 | | | |
| 635 | | | |
| 636 | | | |
| 637 | | | if(interval_float==0) { |
| 638 | | | interval=G_MAXINT32;
x /usr/include/glib-2.0/glib/gtypes.h |
| |
71 | #define G_MAXINT32 ((gint32) 0x7fffffff) |
| |
|
| 639 | | | } else { |
| 640 | | | |
| 641 | | | interval=(gint32)(interval_float*1000.0+0.9); |
| 642 | | | } |
| 643 | | | |
| 644 | | | if(interval<1){ |
| 645 | | | fprintf(stderr, "tshark: \"-z\" interval must be >=0.001 seconds or 0.\n"); |
| 646 | | | exit(10); |
| 647 | | | } |
| 648 | | | |
| 649 | | | io=g_malloc(sizeof(io_stat_t)); |
| 650 | | | io->interval=interval; |
| 651 | | | if((!filter)||(filter[0]==0)){ |
| 652 | | | io->num_items=1; |
| 653 | | | io->items=g_malloc(sizeof(io_stat_item_t)*io->num_items); |
| 654 | | | io->filters=g_malloc(sizeof(char *)*io->num_items); |
| 655 | | | |
| 656 | | | register_io_tap(io, 0, NULL); |
| 657 | | | } else { |
| 658 | | | const char *str,*pos; |
| 659 | | | char *tmp; |
| 660 | | | int i; |
| 661 | | | |
| 662 | | | str=filter; |
| 663 | | | io->num_items=1; |
| 664 | | | while((str=strchr(str,','))){ |
| 665 | | | io->num_items++; |
| 666 | | | str++; |
| 667 | | | } |
| 668 | | | |
| 669 | | | io->items=g_malloc(sizeof(io_stat_item_t)*io->num_items); |
| 670 | | | io->filters=g_malloc(sizeof(char *)*io->num_items); |
| 671 | | | |
| 672 | | | |
| 673 | | | i=0; |
| 674 | | | str=filter; |
| 675 | | | do{ |
| 676 | | | pos=strchr(str,','); |
| 677 | | | if(pos==str){ |
| 678 | | | register_io_tap(io, i, NULL); |
| 679 | | | } else if(pos==NULL) { |
| 680 | | | tmp=g_strdup(str); |
| 681 | | | register_io_tap(io, i, tmp); |
| 682 | | | } else { |
| 683 | | | tmp=g_malloc((pos-str)+1); |
| 684 | | | g_strlcpy(tmp,str,(pos-str)+1); |
| 685 | | | register_io_tap(io, i, tmp); |
| 686 | | | } |
| 687 | | | str=pos+1; |
| 688 | | | i++; |
| 689 | | | } while(pos); |
| 690 | | | } |
| 691 | | | } |
| |