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_*_format* cleanup: script needed :)

From: Jakub Zawadzki <darkjames-ws@xxxxxxxxxxxx>
Date: Tue, 19 Jun 2012 20:28:10 +0200
Hi list,

We have tons of proto_tree_add_*_format() calls where format string starts with hf_name.

Code like:
  tf = proto_tree_add_uint_format(ip_tree, hf_ip_len, tvb, offset + 2, 2, iph->ip_len, "Total length: ...);
can be replaced with:
  tf = proto_tree_add_uint_format_value(ip_tree, hf_ip_len, tvb, offset + 2, 2, iph->ip_len, ...);

To make thing harder, it'd be best if we don't change it when there's no bitmask in hfinfo.


In next step we could also replace code where proto_tree_add_*_format_value() is exactly the same as standard representation, like:
  proto_tree_add_uint_format_value(field_tree, hf_tcp_proc_dst_uid, tvb, 0, 0, tcpd->fwd->process_uid, "%u", tcpd->fwd->process_uid);
to simpler:
  proto_tree_add_uint(field_tree, hf_tcp_proc_dst_uid, tvb, 0, 0, tcpd->fwd->process_uid);


I wonder if we have some perl hackers, who could write such scripts.