ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: Re: [Wireshark-dev] FYI: Status of gcc warnings in epan/dissectors

From: Jeff Morriss <jeff.morriss@xxxxxxxxxxx>
Date: Wed, 28 Mar 2007 18:45:01 +0800


Stephen Fisher wrote:
On Wed, Mar 28, 2007 at 03:04:27PM +0800, Jeff Morriss wrote:
Stephen Fisher wrote:
Almost all of the warnings I've fixed so far are "sign mismatches" between guint8* and (g)char* :(. 552 of the 795 remaining warnings outside of the .cnf files are this problem.
Is casting away signed and unsigned really the way to go with that?

Well, since (g)char defaults to unsigned on most platforms, it is usually the same as a guint8. So it isn't really a mismatch; I think

Well, both glib-1.2 and 2.0 on Linux and Solaris say:

typedef char   gchar;
typedef unsigned char   guchar;

and it looks like you recently changed things like:

        const char *dn;
[...]
-                   format_text(dn, strlen(dn)));
+                   format_text(dn, strlen((guchar*)dn)));

but strlen() usually takes a (const) char*.

That makes no sense to me.  Maybe the compiler is wrong?

gcc 4.0 is warning about it for portability to platforms that don't have (g)char unsigned by default (which are they?). The problem is that we use guint8 all over the place, but the standard C and GLib functions use char. So there is a lot of going back and forth in the code. The implicit "conversion" is already being done and the code works, I'm just making it explicit with a cast. I'm open to other ideas if you have any other than getting rid of our use of guint8 :).

That's why I suggested turning on "-Wno-pointer-sign" (because I don't have a better idea and I don't particularly like the idea of just casting them all away).