Browse Source

generate-wire.py: add memcheck() to towire functions.

Sanity check that we're not streaming uninitialized bytes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
bf7fefdc32
  1. 4
      tools/generate-wire.py

4
tools/generate-wire.py

@ -251,8 +251,9 @@ class Message(object):
print('\ttowire_{}(&p, {});' print('\ttowire_{}(&p, {});'
.format(basetype, f.name)) .format(basetype, f.name))
# Make sure we haven't encoded any uninitialzied fields!
print('\n' print('\n'
'\treturn p;\n' '\treturn memcheck(p, tal_count(p));\n'
'}\n') '}\n')
parser = OptionParser() parser = OptionParser()
@ -274,6 +275,7 @@ if options.output_header:
''.format(idem)) ''.format(idem))
else: else:
print('#include <{}>\n' print('#include <{}>\n'
'#include <ccan/mem/mem.h>\n'
''.format(args[0])) ''.format(args[0]))
# Maps message names to messages # Maps message names to messages

Loading…
Cancel
Save