Ethereal-dev: Re: [Ethereal-dev] Some compiler warnings

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 3 Dec 2003 16:53:09 -0800

On Dec 3, 2003, at 4:11 PM, Biot Olivier wrote:

I intend to use 'tee' more often.

I use it for almost all compiles and have done so for ages (about the only exceptions are quick-and-dirty runs of gcc from the command line).

 It will allow me to track compiler
warnings in an automated way. Here are some errors from a rather current CVS
image:

packet-mtp3.c:494: warning: dereferencing type-punned pointer will break
strict-aliasing rules

What version of GCC are you using, and what warning flags have you turned on? I'm not getting that one with the Panther GCC:

	% gcc --version
	gcc (GCC) 3.3 20030304 (Apple Computer, Inc. build 1495)

with the default compiler flags.

Ugly. The only "right" way to fix that would be to be to make "mtp3_standard" a "gint" rather than an enum.

wiretap:
airopeek9.c:314: warning: comparison between signed and unsigned

I'll have to look at that - it's not obvious what's different between that macro call and other macro calls.

gtk:
endpoint_talkers_table.c:487: warning: assignment discards qualifiers from
pointer target type

I'm not getting that one, but it's probably a GTK+ 1.2[.x] vs. 2.x difference - it looks as if GTK+ 2.x might have "gtk_entry_get_text()" return a "const gchar *" (unless G_DISABLE_CONST_RETURNS isn't defined:

http://mail.gnome.org/archives/gtk-devel-list/2000-November/ msg00191.html

which seems to imply that one reason for const pointer returns is to catch attempts to free stuff that shouldn't be freed, such as the return value of "gtk_entry_get_text()").

That's the case for most if not all of the other "assignment discards qualifiers from pointer target type" warnings - I've checked in a fix.

tcp_graph.c:1012: warning: unused parameter `data'

I'm not getting that one, either - it's another GTK+ 1.2[.x] vs. 2.x issue; in 1.2[.x], it's not unused. It might be that it *should* be used in GTK+ 2.x, as in 1.2[.x] it's used to get a font; I'll leave it as unused for now, as a reminder that it should be looked at.

io_stat.c:252,340,562: warning: comparison between signed and unsigned

The right cleanup for the first and third of those would probably be to make "idx" an unsigned variable. However, shortly before that, "idx" is computed using "git->io->interval", which is signed; I don't see any reason why it *should* be signed.

Making it unsigned would also fix the warning on line 340.

The "idx" argument to "get_it_value()" should also be made unsigned if that's done.