From 897c53ce1c6bbc57079da06c0e0f07efcd2e85f5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 25 Aug 2020 12:55:13 +0930 Subject: [PATCH] tools/generate-wire.py: fix loop logic for towire_xxx_array has_len_fields() doesn't cover our blacklist of variable types, so if we have an array of them, this logic is wrong. This happens in the the bolt13 patch: ```C struct tlv_offer_tlvs_blindedpath { struct pubkey blinding; struct onionmsg_path **path; }; ``` Before: wire/gen_bolt13_tlv.c: ```C for (size_t i = 0; i < tal_count(r->blindedpath->path); i++) towire_onionmsg_path(&ptr, r->blindedpath->path + i); ``` After: ```C for (size_t i = 0; i < tal_count(r->blindedpath->path); i++) towire_onionmsg_path(&ptr, r->blindedpath->path[i]); ``` Signed-off-by: Rusty Russell --- tools/gen/impl_template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen/impl_template b/tools/gen/impl_template index c255506a8..edeee0b8f 100644 --- a/tools/gen/impl_template +++ b/tools/gen/impl_template @@ -53,7 +53,7 @@ bool ${enum_set['name']}_is_defined(u16 type) towire_${type_obj.name}_array(${ptr}, ${fieldname}, ${f.size('tal_count(' + fieldname + ')')}); % else: for (size_t i = 0; i < ${f.size('tal_count(' + fieldname + ')')}; i++) - % if type_obj.is_assignable() or type_obj.has_len_fields(): + % if type_obj.is_assignable() or type_obj.is_varsize(): towire_${type_obj.name}(${ptr}, ${fieldname}[i]); % else: towire_${type_obj.name}(${ptr}, ${fieldname} + i);