Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 20902: /trunk/epan/dissectors/ /trun

From: Jeff Morriss <jeff.morriss@xxxxxxxxxxx>
Date: Sat, 24 Feb 2007 04:17:41 +0800


lego@xxxxxxxxxxxxx wrote:
http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=20902

User: lego
Date: 2007/02/23 07:26 PM

Log:
 Wow!
  hidden fields appear twice defeating the purpose, that's what I call deprecating a function!!

Directory: /trunk/epan/dissectors/
  Changes    Path             Action
  +12 -6     packet-m3ua.c    Modified

I made the same mistake once:

PROTO_ITEM_SET_HIDDEN(proto_tree_add_item(parameter_tree, hf_protocol_data_mtp3_opc, parameter_tvb, DATA_OPC_OFFSET, DATA_OPC_LENGTH, NETWORK_BYTE_ORDER));

The problem is PROTO_ITEM_SET_HIDDEN is a macro using the "?" operator. As a result the argument to the macro may evaluated multiple times. That's fine if the argument is a variable, not so fine if it's a function call (as above).

I'm not sure if there's a way that works other than to assign the result of "*add_item()" to a variable then call PROTO_ITEM_SET_HIDDEN() on that variable. I'm also not sure if there's a way to make it obvious that PROTO_ITEM_SET_HIDDEN() must be used on a variable.