Wireshark-dev: [Wireshark-dev] Use of non-constant initializer for structs
From: Albert Chin <wireshark-dev@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 6 Nov 2006 21:15:11 -0600
C89 does not allow non-constant initializers. Patch attached. -- albert chin (china@xxxxxxxxxxxxxxxxxx)
Index: asn1/h248/packet-h248-template.c =================================================================== --- asn1/h248/packet-h248-template.c (revision 19843) +++ asn1/h248/packet-h248-template.c (working copy) @@ -1112,11 +1112,14 @@ if (keep_persistent_data) { emem_tree_key_t key[] = { - {1,&(framenum)}, - {1,&offset}, + {1,NULL}, + {1,NULL}, {0,NULL}, }; + key[0].key = &(framenum); + key[1].key = &offset; + if (( m = se_tree_lookup32_array(msgs,key) )) { m->commited = TRUE; return m; @@ -1185,12 +1188,16 @@ } else { emem_tree_key_t key[] = { - {1,&(m->hi_addr)}, - {1,&(m->lo_addr)}, - {1,&(t_id)}, + {1,NULL}, + {1,NULL}, + {1,NULL}, {0,NULL} }; + key[0].key = &(m->hi_addr); + key[1].key = &(m->lo_addr); + key[2].key = &(t_id); + trxmsg = se_alloc(sizeof(h248_trx_msg_t)); t = se_tree_lookup32_array(trxs,key); @@ -1249,19 +1256,27 @@ if (keep_persistent_data) { emem_tree_key_t ctx_key[] = { - {1,&(m->hi_addr)}, - {1,&(m->lo_addr)}, - {1,&(c_id)}, + {1,NULL}, + {1,NULL}, + {1,NULL}, {0,NULL} }; emem_tree_key_t trx_key[] = { - {1,&(m->hi_addr)}, - {1,&(m->lo_addr)}, - {1,&(t->id)}, + {1,NULL}, + {1,NULL}, + {1,NULL}, {0,NULL} }; + ctx_key[0].key = &(m->hi_addr); + ctx_key[1].key = &(m->lo_addr); + ctx_key[2].key = &(c_id); + + trx_key[0].key = &(m->hi_addr); + trx_key[1].key = &(m->lo_addr); + trx_key[2].key = &(t->id); + if (m->commited) { if (( context = se_tree_lookup32_array(ctxs_by_trx,trx_key) )) { return context; Index: asn1/ldap/packet-ldap-template.c =================================================================== --- asn1/ldap/packet-ldap-template.c (revision 19843) +++ asn1/ldap/packet-ldap-template.c (working copy) @@ -1005,21 +1005,22 @@ guint32 flags; proto_item *item; proto_tree *tree=NULL; - guint fields[] = { hf_mscldap_netlogon_flags_ndnc, - hf_mscldap_netlogon_flags_good_timeserv, - hf_mscldap_netlogon_flags_writable, - hf_mscldap_netlogon_flags_closest, - hf_mscldap_netlogon_flags_timeserv, - hf_mscldap_netlogon_flags_kdc, - hf_mscldap_netlogon_flags_ds, - hf_mscldap_netlogon_flags_ldap, - hf_mscldap_netlogon_flags_gc, - hf_mscldap_netlogon_flags_pdc, - 0 }; + guint fields[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; guint *field; header_field_info *hfi; gboolean one_bit_set = FALSE; + fields[0] = hf_mscldap_netlogon_flags_ndnc; + fields[1] = hf_mscldap_netlogon_flags_good_timeserv; + fields[2] = hf_mscldap_netlogon_flags_writable; + fields[3] = hf_mscldap_netlogon_flags_closest; + fields[4] = hf_mscldap_netlogon_flags_timeserv; + fields[5] = hf_mscldap_netlogon_flags_kdc; + fields[6] = hf_mscldap_netlogon_flags_ds; + fields[7] = hf_mscldap_netlogon_flags_ldap; + fields[8] = hf_mscldap_netlogon_flags_gc; + fields[9] = hf_mscldap_netlogon_flags_pdc; + flags=tvb_get_letohl(tvb, offset); item=proto_tree_add_item(parent_tree, hf_mscldap_netlogon_flags, tvb, offset, 4, TRUE); if(parent_tree){ Index: epan/dissectors/packet-ldap.c =================================================================== --- epan/dissectors/packet-ldap.c (revision 19843) +++ epan/dissectors/packet-ldap.c (working copy) @@ -3535,21 +3535,22 @@ guint32 flags; proto_item *item; proto_tree *tree=NULL; - guint fields[] = { hf_mscldap_netlogon_flags_ndnc, - hf_mscldap_netlogon_flags_good_timeserv, - hf_mscldap_netlogon_flags_writable, - hf_mscldap_netlogon_flags_closest, - hf_mscldap_netlogon_flags_timeserv, - hf_mscldap_netlogon_flags_kdc, - hf_mscldap_netlogon_flags_ds, - hf_mscldap_netlogon_flags_ldap, - hf_mscldap_netlogon_flags_gc, - hf_mscldap_netlogon_flags_pdc, - 0 }; + guint fields[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; guint *field; header_field_info *hfi; gboolean one_bit_set = FALSE; + fields[0] = hf_mscldap_netlogon_flags_ndnc; + fields[1] = hf_mscldap_netlogon_flags_good_timeserv; + fields[2] = hf_mscldap_netlogon_flags_writable; + fields[3] = hf_mscldap_netlogon_flags_closest; + fields[4] = hf_mscldap_netlogon_flags_timeserv; + fields[5] = hf_mscldap_netlogon_flags_kdc; + fields[6] = hf_mscldap_netlogon_flags_ds; + fields[7] = hf_mscldap_netlogon_flags_ldap; + fields[8] = hf_mscldap_netlogon_flags_gc; + fields[9] = hf_mscldap_netlogon_flags_pdc; + flags=tvb_get_letohl(tvb, offset); item=proto_tree_add_item(parent_tree, hf_mscldap_netlogon_flags, tvb, offset, 4, TRUE); if(parent_tree){
- Prev by Date: [Wireshark-dev] Replace ntohl() with g_ntohl()
- Next by Date: [Wireshark-dev] Use of anonymous union in epan/dissectors/packet-usb.[ch]
- Previous by thread: Re: [Wireshark-dev] Replace ntohl() with g_ntohl() -> automated check?
- Next by thread: [Wireshark-dev] Use of anonymous union in epan/dissectors/packet-usb.[ch]
- Index(es):