Wireshark-dev: Re: [Wireshark-dev] bug 5175 PPI-GEOLOCATION patch, input pcap

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Thu, 11 Nov 2010 09:27:26 -0800
On Nov 8, 2010, at 1:15 PM, Jon Ellch wrote:

>> Is there a reason g_appstr_num is fetched using tvb_get_letohl() and
> then added
>> to the tree with proto_tree_add_uint() instead of adding it directly with
>> proto_tree_add_item()?  That would make for cleaner code as it appears that
>> g_appstr_num isn't used after the proto_tree_add_uint() call.  using
>> _add_item() makes the code easier to read if the variable isn't needed
> after
>> that.  There may be other cases of this; this is just an example I noticed.
> 
> Point made, however I would like to keep a copy of the values locally
> for future improvements (maybe making a cleaner text representation with
> the appropriate
> degrees of precision displayed). Also, if I were to skip the
> tvb_get_letohl() call,
> how do I make sure values are byte-swapped on big-endian systems?

The last argument to proto_tree_add_item() specifies the representation of the item; for multi-byte integral values, you can pass ENC_BIG_ENDIAN or ENC_LITTLE_ENDIAN to specify whether the value is big-endian or little-endian.