generate-wire.py: allow NULL len parameter from fromwire_*

It implies tal_count() gives the length. Great for almost all callers which
don't care if there are extra bytes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-01-04 14:09:21 +10:30
parent e076d56709
commit bdaa22e247
2 changed files with 8 additions and 6 deletions

View File

@@ -169,7 +169,12 @@ class Message(object):
print('\t{} {};'.format(f.typename, f.name));
print('\tconst u8 *cursor = p;\n'
'\tsize_t tmp_len;\n'
'\n'
'\tif (!plen) {{\n'
'\t\ttmp_len = tal_count(p);\n'
'\t\tplen = &tmp_len;\n'
'\t}}\n'
'\tif (fromwire_u16(&cursor, plen) != {})\n'
'\t\treturn false;'
.format(self.enum.name))