tcpdump mailing list archives

A few compiler warnings


From: "Ebright, Don" <Don.Ebright () compuware com>
Date: Mon, 22 Dec 2003 16:58:10 -0500

I have successfully built the beta2 (351) versions of libpcap and tcpdump on
Solaris 2.6, AIX 4.3.3, Tru64 5.1, and HP-UX 11.00 using the vendor-supplied
compilers.  Each of the resulting tcpdump binaries appeared to work
properly, based on one or two short unfiltered captures on each platform,
but there were a few minor issues that caused compiler warning messages.  I
also encountered a build failure on Tru64 that was caused by a problematic
compiler switch.

1. The compiler on Tru64 5.1 flags a number of errors because line 1093 of
the configure script sets the -std1 compile switch which requests strict c89
compliance.  I worked around this issue by changing the switch to -std,
which accepts c99 as well as c89 syntax.  This issue also affects tcpdump
3.7.x.  I am not at all familiar with Tru64 so I can't say whether this
change would be appropriate for all situations, and I have no explanation
why others haven't encountered the same problem unless they are all using
gcc.  The issue probably deserves a mention in README.tru64 if the default
compiler switches for OSF1/Tru64 can't or shouldn't be changed.  

2. All of the compilers except for Tru64 warn of a type mismatch at line 216
of tcpdump/print-fr.c because line 206 defines addr_len as an int when it
appears that it should be u_int.

3. AIX warns about undeclared structs in the function declarations at lines
275-277 of /usr/include/cf.h.  These warnings can be eliminated by changing
line 62 of pcap-bpf.c to #include <sys/cfgodm.h> instead of #include
<odmi.h>.  The cfgodm.h header declares the missing structs and also
supplies the #include <odmi.h>.  None of the affected functions are actually
used by libpcap so there is no real problem here besides the annoying
warning messages.

4. The Sun Solaris compiler warns about line 98 of libpcap/gencode.c
initializing unsigned ints to negative values.

static u_int    orig_linktype = -1, orig_nl = -1, orig_nl_nosnap = -1;

This also affected tcpdump 3.7.x, and appears to be harmless.

5. The HP-UX 11.00 stdio.h doesn't specify the const attribute for the
format string in the declaration of the function prototype for snprintf().
This leads to warnings in print-icmp.c lines 354 and 364 and util.c lines
242, 286, and 307 where const variables are used as the format string.  It
is probably undesirable to "fix" this by removing the const attribute from
the variables named fmt that are used as format strings.  Most of us who
have used snprintf() on HP-UX are probably aware of this issue.

6. AIX warns about an argument type mismatch on lines 447 and 813 of
addrtoname.c because the AIX declaration of ether_ntohost() in arpa/inet.h
fails to indicate that the second argument is const.  Once again, probably
not worth "fixing".

I doubt that any of these warning messages represent a real problem except
for the Tru64 compile errors, but I would probably change the first three
items if it were up to me.  Let me know if there is anything else that I can
do.

Don




The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:tcpdump-workers-request () tcpdump org?body=unsubscribe


Current thread: