From a11d234e18c8f2ae406b0dea9cd91f258b369c4c Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Fri, 30 Jun 2017 13:11:51 +0200 Subject: [PATCH] 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. --- tools/extract-formats.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/extract-formats.py b/tools/extract-formats.py index 006ce62..e8c720c 100755 --- a/tools/extract-formats.py +++ b/tools/extract-formats.py @@ -89,6 +89,7 @@ for i,line in enumerate(fileinput.input(args)): if options.output_types: print("{},{}".format(match.group('name'), match.group('value'))) havedata = None + alignoff = False elif message is not None and havedata is None: if line != '2. data:': message = None @@ -101,7 +102,12 @@ for i,line in enumerate(fileinput.input(args)): if match: 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)) if options.output_fields: