1
0
mirror of https://github.com/lightning/bolts.git synced 2024-11-19 01:50:03 +01:00

tools: Disable alignment check when we have a variable length field

If we have a variable length field we should not check the alignment
of the following fields, the check will be off anyway.
This commit is contained in:
Christian Decker 2017-06-30 13:11:51 +02:00
parent a257554456
commit a11d234e18

View File

@ -89,6 +89,7 @@ for i,line in enumerate(fileinput.input(args)):
if options.output_types: if options.output_types:
print("{},{}".format(match.group('name'), match.group('value'))) print("{},{}".format(match.group('name'), match.group('value')))
havedata = None havedata = None
alignoff = False
elif message is not None and havedata is None: elif message is not None and havedata is None:
if line != '2. data:': if line != '2. data:':
message = None message = None
@ -101,7 +102,12 @@ for i,line in enumerate(fileinput.input(args)):
if match: if match:
align = guess_alignment(message, match.group('name'), match.group('size')) align = guess_alignment(message, match.group('name'), match.group('size'))
if options.check_alignment and dataoff % align != 0: # Do not check alignment if we previously had a variable
# length field in the message
if off_extraterms != "":
alignoff = True
if not alignoff and options.check_alignment and dataoff % align != 0:
raise ValueError('{}:message {} field {} Offset {} not aligned on {} boundary:'.format(linenum, message, match.group('name'), dataoff, align)) raise ValueError('{}:message {} field {} Offset {} not aligned on {} boundary:'.format(linenum, message, match.group('name'), dataoff, align))
if options.output_fields: if options.output_fields: