Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: [Wireshark-dev] Question on format_value variant of proto_tree_add_bits_item fun

From: Gerasimos Dimitriadis <gedimitr@xxxxxxxxx>
Date: Wed, 20 Jan 2010 13:21:17 +0200
Hi all,

I am writing again my question, because admittedly it was not very
clear what I was asking in the previous email :-[

I want to create a _format_value variant(s) of the
proto_tree_add_bits_item function. The easiest way to do so is to
create a single function that takes a void * pointer of the value and
then reads from that address a guint32, a gint32, a float etc
depending on the type of the provided header field.

The above is the most compact way of implementing such functionality,
but on the other hand no type checking is possible and also this
scheme is inflexible regarding the provided values (you cannot give a
pointer to uint8 if the function expects a pointer to uint32 --- even
worse: you can, but you shouldn't; the compiler will not say anything
about it.).

The alternative would be to create dedicated functions per header
field type: one for adding bits as uint, one for bits as float etc.

My thoughts are that adding a function per header field type is the
most robust one, but the temptation of exporting just one function
that can deal with all of them is big!

So, I want to ask (especially the core team members): Is it acceptable
in general for functions to be more dangerous than usual?

Best regards,

Gerasimos

PS: I tried sending this email from my work (intracom.gr) account, but
the list seems to silently discarding it. Any ideas why this happens?