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] proto_tree_add_subtree[_format]

Date: Sun, 22 Jun 2014 18:21:48 -0400 (EDT)
In an effort to further remove proto_tree_add_text calls from the Wireshark source, I've created proto_tree_add_subtree and proto_tree_add_subtree_format.  The use case is to combine proto_tree_add_text + proto_item_add_subtree into a single call when the intent of the dissector is to create a "subtree with a label".  It could also replace some proto_tree_add_none_format + proto_item_add_subtree calls (some of the filters don't seem that useful IMO and it appears that dissector just wanted to avoid proto_tree_add_text).  proto_tree_add_subtree takes just a string (const char*), while proto_tree_add_subtree_format supports printf style arguments (like proto_tree_add_text already does).  The intention is to have proto_tree_add_subtree be more optimized since it doesn't need the printf style arguments (as a few API calls have done that direction), but it's not currently implemented that way (patches welcome!)
 
I am currently in the process of converting applicable proto_tree_add_text + proto_item_add_subtree into proto_tree_add_subtree[_format] calls.  It should take me a while, so any help would be appreciated (ideas on scripts would also be helpful, as I haven't found an idea I like).  Just drop me a note so we're not duplicating work. I'm going alphabetically by dissector filename (in epan/dissectors directory), and I've already done the ASN.1 generated dissectors (because 1 change counts twice).  I will not be touching any of the proto_tree_add_none_format calls, as I probably won't have enough knowledge of the dissector using it to be confident in removing the filter.
 
I would also appreciate code reviews "encouraging" the use of this new API.  We don't need to specifically revisit current patches (dissectors) submitted to Gerrit (most will probably be committed before I get to them in master anyway), but new ones should be subject to it.
 
Michael