Re: [tcpdump-workers] -W options to gcc
On Mar 28, 2013, at 4:41 PM, Michael Richardson wrote: > >> "Guy" == Guy Harris writes: >Guy> Wireshark's configure script checks whether the GCC shell >Guy> variable is "yes" or the CC shell variable is "clang" and, if >Guy> true, sets a flag saying "this compiler supports -W options". > > Cooll.. can we copy and paste :-) Wireshark's configuration scripts are GPLed, along with the rest of Wireshark, so, in principle, that might be a problem. I didn't originally write that macro, so I can't just relicense it. I don't know whether anybody'd care, however. (I've moved stuff of mine between Wireshark and tcpdump/libpcap configure scripts in the past.) ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
> "Guy" == Guy Harris writes: Guy> Wireshark's configure script checks whether the GCC shell Guy> variable is "yes" or the CC shell variable is "clang" and, if Guy> true, sets a flag saying "this compiler supports -W options". Cooll.. can we copy and paste :-) Guy> There's no C++ code in libpcap or tcpdump, so the second Guy> argument isn't necessary. true... but it won't hurt, and why let the code diverge? -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works| network architect [ ] m...@sandelman.ca http://www.sandelman.ca/| ruby on rails[ ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] [Patch] pcap-dos.c
On Mar 28, 2013, at 5:53 AM, Gisle Vanem wrote: > This file has fallen behind since pcap_create() was put in > pcap.c long time ago (a more generic create-function). Hence: Checked into the trunk and the 1.4 branch. ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
On Mar 28, 2013, at 5:37 AM, Michael Richardson wrote: > > While I'll bet that 95% of *nix systems that compile tcpdump regularly > are using gcc, I know that there remain other compilers in use. ...at least some of which may support -W options, and at least one of which (clang) supports most if not all of the same -W options that GCC does. > If one wants to add -W options to the standard build, I'm wondering what > the right autoconf magic is to enable such a thing. Wireshark's configure script checks whether the GCC shell variable is "yes" or the CC shell variable is "clang" and, if true, sets a flag saying "this compiler supports -W options". It then has a macro that takes, as arguments, a list of one or more flags to add; an optional indication of whether the flags are for C, C++, or both; an optional program to compile with the flag and with -Werror - if the compile fails, the option is not added (this handles some flags that issue incorrect or non-useful warnings with some compiler versions); if the third argument is supplied, a fourth argument which is a message describing what the test program is checking and, if the compiler supports -W options, doesn't fail if you pass it the -W option in question when compiling a trivial program (this tests whether the option is supported at all), and, if the test program is supplied, it compiles OK, it adds the flags to CFLAGS, CXXFLAGS, or both. (If the compiler is clang, you also have to pass -Werror=unknown-warning-option, so the compiler doesn't just print out a warning message and compile anyway; that way, we don't include a pile of unsupported -W flags and get a pile of warnings for every compilation.) There's no C++ code in libpcap or tcpdump, so the second argument isn't necessary. The third and fourth arguments are used to: avoid using -Wshadow if, when set, the compiler bogusly complains about variables in function and function pointer declarations shadowing other variables (which some versions of GCC do); avoid using -Wlogical-op if strchr() is given a constant string; so unless we plan to use those -W flags, we don't need them - no other tricky -W flags were found. > fxlb suggested: > "-Wunused -Wunused-parameter" > > -- > ] Never tell me the odds! | ipv6 mesh networks > [ > ] Michael Richardson, Sandelman Software Works| network architect > [ > ] m...@sandelman.ca http://www.sandelman.ca/| ruby on rails > [ > > > > ___ > tcpdump-workers mailing list > tcpdump-workers@lists.tcpdump.org > https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers > ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
> > "Gisle" == Gisle Vanem writes: > Gisle> I compile using MingW (gcc 4.7.2) and normally I use > Gisle> -Wall -W. > > sure, I'd like to get to -Wall -Werror at some point, but for the > moment, I want to know how to include -Wgcc-things when we are using > gcc, and omit when we aren't. You probably want to include (some of) them when using some other compilers (eg clang) that are likely to support the same options. There are problems with -Werror for release software in that different versions of gcc will detect different errors. Particularly if some aggressive function inlining is done. David ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
28.03.2013, 17:55, "Michael Richardson" : >> "Gisle" == Gisle Vanem writes: > > Gisle> I compile using MingW (gcc 4.7.2) and normally I use > Gisle> -Wall -W. > > sure, I'd like to get to -Wall -Werror at some point, but for the > moment, I want to know how to include -Wgcc-things when we are using > gcc, and omit when we aren't. > This is from autoconf documentation: "Macro: AC_PROG_CC ([compiler-search-list]) [...] If using the GNU C compiler, set shell variable GCC to ‘yes’." -- Denis Ovsienko ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
> "Gisle" == Gisle Vanem writes: Gisle> I compile using MingW (gcc 4.7.2) and normally I use Gisle> -Wall -W. sure, I'd like to get to -Wall -Werror at some point, but for the moment, I want to know how to include -Wgcc-things when we are using gcc, and omit when we aren't. -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works| network architect [ ] m...@sandelman.ca http://www.sandelman.ca/| ruby on rails[ ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
Re: [tcpdump-workers] -W options to gcc
"Michael Richardson" wrote: If one wants to add -W options to the standard build, I'm wondering what the right autoconf magic is to enable such a thing. fxlb suggested: "-Wunused -Wunused-parameter" I compile using MingW (gcc 4.7.2) and normally I use -Wall -W. But this gives tons of warnings. Hence I use these to supress most of them: -Wno-unused-but-set-variable -Wno-unused-function -Wno-strict-aliasing This results in only these warnings: missing/inet_ntop.c: In function 'inet_ntop': missing/inet_ntop.c:146:44: warning: 'best.len' may be used uninitialized in this function [-Wmaybe-uninitialized] missing/inet_ntop.c:117:5: note: 'best.len' was declared here Must be one of the oldest file in tcpdump. From 2005. --gv ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
[tcpdump-workers] [Patch] pcap-dos.c
This file has fallen behind since pcap_create() was put in pcap.c long time ago (a more generic create-function). Hence: --- Git-Latest\pcap-dos.c Wed Nov 28 23:41:44 2012 +++ pcap-dos.c Thu Nov 29 00:00:12 2012 @@ -143,7 +143,7 @@ return handle_to_device [fd-1]; } -pcap_t *pcap_create (const char *device, char *ebuf) +pcap_t *pcap_create_interface (const char *device, char *ebuf) { pcap_t *p; @@ -211,7 +211,7 @@ pcap_read_one (pcap_t *p, pcap_handler callback, u_char *data) { struct pcap_pkthdr pcap; - struct timeval now, expiry; + struct timeval now, expiry = { 0,0 }; BYTE *rx_buf; intrx_len = 0; @@ -287,7 +287,7 @@ return (1); } -/* If not to wait for a packet or pcap_close() called from +/* If not to wait for a packet or pcap_cleanup_dos() called from * e.g. SIGINT handler, exit loop now. */ if (p->md.timeout <= 0 || (volatile int)p->fd <= 0) -- The change in the comment is just to make it clear it's not pcap_close() that's called directly. --gv ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers
[tcpdump-workers] -W options to gcc
While I'll bet that 95% of *nix systems that compile tcpdump regularly are using gcc, I know that there remain other compilers in use. If one wants to add -W options to the standard build, I'm wondering what the right autoconf magic is to enable such a thing. fxlb suggested: "-Wunused -Wunused-parameter" -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works| network architect [ ] m...@sandelman.ca http://www.sandelman.ca/| ruby on rails[ ___ tcpdump-workers mailing list tcpdump-workers@lists.tcpdump.org https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers