Wireshark-dev: [Wireshark-dev] Commit 54832 (packet-diameter.c HFILL initialization)
Sorry for this form of reply, but I accidentally deleted the original commit
mail...
> Author: Anders Broman <anders.broman@xxxxxxxxxxxx>
> Date: Fri Jan 17 18:58:50 2014 +0000
>
> Try to fix warning: initializer element is not computable at load time.
>
> svn path=/trunk/; revision=54832
>
> diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c
> index 9a23ab3..1878508 100644
> --- a/epan/dissectors/packet-diameter.c
> +++ b/epan/dissectors/packet-diameter.c
> @@ -1289,15 +1289,22 @@ reginfo(int *hf_ptr, const char *name, const char *abbr, const c
> har *desc,
> enum ftenum ft, field_display_e base, const value_string_ext *vs_ext,
> guint32 mask)
> {
> - hf_register_info hf = { hf_ptr, {
> - name,
> - abbr,
> - ft,
> - base,
> - NULL,
> - mask,
> - desc,
> - HFILL }};
> + hf_register_info hf;
> +
> + hf.p_id = hf_ptr;
> + hf.hfinfo.name = name;
> + hf.hfinfo.abbrev = abbr;
> + hf.hfinfo.type = ft;
> + hf.hfinfo.display = base;
> + hf.hfinfo.strings = NULL;
> + hf.hfinfo.bitmask = mask;
> + hf.hfinfo.blurb = desc;
> + /* HFILL */
> + hf.hfinfo.id = -1;
> + hf.hfinfo.parent = 0;
> + hf.hfinfo.ref_type = HF_REF_TYPE_NONE;
> + hf.hfinfo.same_name_prev_id = -1;
> + hf.hfinfo.same_name_next = NULL;
This is not good: We use HFILL for a reason: To make it trivial to change the
(private) elements of the hf structure. If we need to do this, we should create
another MACRO (e.g. HFILL_INIT) in the same place where we define HFILL and use
that instead of explicitely setting all the values inside a dissector file.
Ciao
Jörg
--
Joerg Mayer <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.