Wireshark-bugs: [Wireshark-bugs] [Bug 1539] Applying filter for signed integer (FT_INT32) hf_ en

Date: Tue, 20 May 2008 07:11:08 -0700 (PDT)
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1539





--- Comment #6 from Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>  2008-05-20 07:11:06 PDT ---
(In reply to comment #5)
> I disagree with how this bug was resolved/fixed. Instead of disallowing the use
> of FT_INT8, FT_INT16, FT_INT24, and FT_INT32 with BASE_DEC_HEX and
> BASE_HEX_DEC, I think that the "underlying bug (filter prep?)" should be fixed
> instead.

That would be possible (and I long considered it) but it raises the question
asked by Guy: how do you display a negative number in hex?

> Why did you decide that forcing developers to use UINT for values that will
> display in hex was the right solution? When someone wants to make 0xffff
> display, did you get tired of arguing over whether to display 0xffff (2’s
> complement for -1), or -0x0001 (a unary negation operator on the value +1)? Or,
> did it just seem to be the easier of the two to change?

In Wireshark the representations are prepared using standard printf-style
formatting: %x for hex and %d for decimal.  %x is unsigned.  It doesn't really
make sense to display signed things in unsigned.  I seriously contemplated
leaving BASE_DEC_HEX alone but when I discovered that no dissector (in the
source tree) was using it on a signed number I took it out for consistency.

> For example, if I have a integer (representing, in this case, the real world
> example of a discriminator position) that has range -100 or so to about +100, 
> I want it displayed in both integer form and the host byte order hexedecimal
> two's complement form. BASE_DEC_HEX was perfect for this. When its value is -1,
> I would see something like this in the tree:
> Discriminator 1: -1 (0xffff)

This sounds like a special case to me and I'm tempted to leave it as such
(where you can use the *_format() routine to display it as you want it).  I
think the cost of doing that is outweighed by the benefit of keeping developers
straight about the signedness of their fields.


-- 
Configure bugmail: http://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.