Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 21556:/trunk/epan//trunk/epan/: prot

From: "Anders Broman" <a.broman@xxxxxxxxx>
Date: Wed, 9 May 2007 08:04:15 +0200
Hi,
>(Should proto_tree_add_bits() be renamed proto_tree_add_item_bits(),  
>to emphasize its kinship with proto_tree_add_item()?)

Or is proto_tree_add_bits_item() better?
Regards
Anders

-----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 :-(


On Apr 25, 2007, at 11:06 AM, Anders Broman wrote:

> Hi,
> I'm looking inot spliting it into:
>
> /*This function will call proto_tree_add_bits_ret_val() without the  
> return
> value. */
> extern proto_item *
> proto_tree_add_bits(proto_tree *tree, int hf_index, tvbuff_t *tvb,  
> gint
> bit_offset, gint no_of_bits, gboolean little_endian);
>
> /* Calls tvb_get bits */
> extern proto_item *
> proto_tree_add_bits_ret_val(proto_tree *tree, int hf_index, tvbuff_t  
> *tvb,
> gint bit_offset, gint no_of_bits, guint32 *return_value, gboolean
> little_endian);
>
>
> guint32
> tvb_get_bits(tvbuff_t *tvb, gint bit_offset, gint no_of_bits, gboolean
> little_endian)
>
> (Should it handle 64bits?)

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()?)
_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
http://www.wireshark.org/mailman/listinfo/wireshark-dev