tools/firewire: nosy-dump: remove unused code

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

+50 -57
+50 -57
tools/firewire/nosy-dump.c
··· 903 903 904 904 int main(int argc, const char *argv[]) 905 905 { 906 + uint32_t buf[128 * 1024]; 907 + uint32_t filter; 908 + int length, retval, view; 906 909 int fd = -1; 907 910 FILE *output = NULL, *input = NULL; 908 911 poptContext con; 909 - int retval; 910 - int view; 911 912 char c; 912 913 struct pollfd pollfds[2]; 913 914 ··· 962 961 963 962 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); 964 963 965 - if (1) { 966 - uint32_t buf[128 * 1024]; 967 - uint32_t filter; 968 - int length; 964 + filter = ~0; 965 + if (!option_iso) 966 + filter &= ~(1 << TCODE_STREAM_DATA); 967 + if (!option_cycle_start) 968 + filter &= ~(1 << TCODE_CYCLE_START); 969 + if (view == VIEW_STATS) 970 + filter = ~(1 << TCODE_CYCLE_START); 969 971 970 - filter = ~0; 971 - if (!option_iso) 972 - filter &= ~(1 << TCODE_STREAM_DATA); 973 - if (!option_cycle_start) 974 - filter &= ~(1 << TCODE_CYCLE_START); 975 - if (view == VIEW_STATS) 976 - filter = ~(1 << TCODE_CYCLE_START); 972 + ioctl(fd, NOSY_IOC_FILTER, filter); 977 973 978 - ioctl(fd, NOSY_IOC_FILTER, filter); 974 + ioctl(fd, NOSY_IOC_START); 979 975 980 - ioctl(fd, NOSY_IOC_START); 976 + pollfds[0].fd = fd; 977 + pollfds[0].events = POLLIN; 978 + pollfds[1].fd = STDIN_FILENO; 979 + pollfds[1].events = POLLIN; 981 980 982 - pollfds[0].fd = fd; 983 - pollfds[0].events = POLLIN; 984 - pollfds[1].fd = STDIN_FILENO; 985 - pollfds[1].events = POLLIN; 986 - 987 - while (run) { 988 - if (input != NULL) { 989 - if (fread(&length, sizeof length, 1, input) != 1) 981 + while (run) { 982 + if (input != NULL) { 983 + if (fread(&length, sizeof length, 1, input) != 1) 984 + return 0; 985 + fread(buf, 1, length, input); 986 + } else { 987 + poll(pollfds, 2, -1); 988 + if (pollfds[1].revents) { 989 + read(STDIN_FILENO, &c, sizeof c); 990 + switch (c) { 991 + case 'q': 992 + if (output != NULL) 993 + fclose(output); 990 994 return 0; 991 - fread(buf, 1, length, input); 992 - } else { 993 - poll(pollfds, 2, -1); 994 - if (pollfds[1].revents) { 995 - read(STDIN_FILENO, &c, sizeof c); 996 - switch (c) { 997 - case 'q': 998 - if (output != NULL) 999 - fclose(output); 1000 - return 0; 1001 - } 1002 995 } 1003 - 1004 - if (pollfds[0].revents) 1005 - length = read(fd, buf, sizeof buf); 1006 - else 1007 - continue; 1008 996 } 1009 997 1010 - if (output != NULL) { 1011 - fwrite(&length, sizeof length, 1, output); 1012 - fwrite(buf, 1, length, output); 1013 - } 1014 - 1015 - switch (view) { 1016 - case VIEW_TRANSACTION: 1017 - handle_packet(buf, length); 1018 - break; 1019 - case VIEW_PACKET: 1020 - print_packet(buf, length); 1021 - break; 1022 - case VIEW_STATS: 1023 - print_stats(buf, length); 1024 - break; 1025 - } 998 + if (pollfds[0].revents) 999 + length = read(fd, buf, sizeof buf); 1000 + else 1001 + continue; 1026 1002 } 1027 - } else { 1028 - poptPrintUsage(con, stdout, 0); 1003 + 1004 + if (output != NULL) { 1005 + fwrite(&length, sizeof length, 1, output); 1006 + fwrite(buf, 1, length, output); 1007 + } 1008 + 1009 + switch (view) { 1010 + case VIEW_TRANSACTION: 1011 + handle_packet(buf, length); 1012 + break; 1013 + case VIEW_PACKET: 1014 + print_packet(buf, length); 1015 + break; 1016 + case VIEW_STATS: 1017 + print_stats(buf, length); 1018 + break; 1019 + } 1029 1020 } 1030 1021 1031 1022 if (output != NULL)