Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 21556:/trunk/epan//trunk/epan/: prot
From: "Anders Broman" <a.broman@xxxxxxxxx>
Date: Fri, 18 May 2007 19:00:01 +0200

-----Ursprungligt meddelande-----
Från: wireshark-dev-bounces@xxxxxxxxxxxxx
[mailto:wireshark-dev-bounces@xxxxxxxxxxxxx] För Guy Harris
Skickat: den 9 maj 2007 04:46
Till: Developer support list for Wireshark
Ämne: Re: [Wireshark-dev] [Wireshark-commits] rev
21556:/trunk/epan//trunk/epan/: proto.c proto.h - all buildbotsred now :-(


Guy wrote:
>Or should there be:
>
>	guint8 tvb_get_bits8(tvbuff_t *tvb, gint bit_offset, gint
>no_of_bits,  
>gboolean
>little_endian)
>
>		where "no_of_bits" must be no larger than 8
>
>	guint16 tvb_get_bits16(tvbuff_t *tvb, gint bit_offset, gint  
>no_of_bits, gboolean
>little_endian)
>
>		where "no_of_bits" must be no larger than 16 (and >possibly
no  
>smaller than 9)
>
>	guint32 tvb_get_bits32(tvbuff_t *tvb, gint bit_offset, gint  
>no_of_bits, gboolean
>little_endian)
>
>		where "no_of_bits" must be no larger than 32 (and >possibly
no  
>smaller than 17)
>
>	guint64 tvb_get_bits64(tvbuff_t *tvb, gint bit_offset, gint  
>no_of_bits, gboolean
>little_endian)
>
>		where "no_of_bits" must be no larger than 64
>
>along with proto_tree_add_uint_bits() and proto_tree_add_uint64_bits()  
>routines that take the value to be added, as well as the bit offset  
>and length, as arguments.
>
>That would obviate the need to cast away compiler warnings to get rid  
>of the current buildbot warnings:
>
>	packet-umts_fp.c(1873) : error C2220: warning treated as error - >no

>object file generated
>	packet-umts_fp.c(1873) : warning C4244: '=' : conversion from  
>'unsigned __int64 ' to 'unsigned char ', possible loss of data
>	packet-umts_fp.c(1882) : warning C4244: '=' : conversion from  
>'unsigned __int64 ' to 'unsigned short ', possible loss of data
>
>as you'd fetch the value with the appropriate tvb_get_bits() calls and  
>add them with proto_tree_add_uint_bits().
>
>(Should proto_tree_add_bits() be renamed proto_tree_add_item_bits(),  
>to emphasize its kinship with proto_tree_add_item()?)
>

I've added/changed the tvb_get_bits.. functions as suggested and renamed
proto_tree_add_bits() to proto_tree_add_bits_item().

I think the proto_tree_add_bits_ret_val() is useful as it makes
The tvb_get... unnecessary but perhaps it should be spitted into
proto_tree_add_bits_ret_val8
proto_tree_add_bits_ret_val16
proto_tree_add_bits_ret_val32
proto_tree_add_bits_ret_val64

proto_tree_add_uint_bits() may be useful as well.
Comments?
Regards
Anders
I 

_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev