intel/genxml: Assert that genxml field start and ends are sane.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 7 May 2018 18:14:42 +0000 (11:14 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 8 May 2018 06:06:52 +0000 (23:06 -0700)
Chris recently fixed a bunch of genxml end < start bugs, as well as
booleans that are wider than a bit.  These are way too easy to write, so
asserting that the fields are sane is a good plan.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/genxml/gen_pack_header.py

index 4bce425d12e7283d225b3600bb2ffe032743b03e..c3d712c7a86e1580ec0fadcf8b4203fb07b21d69 100644 (file)
@@ -235,6 +235,13 @@ class Field(object):
         self.end = int(attrs["end"])
         self.type = attrs["type"]
 
+        assert self.start <= self.end, \
+               'field {} has end ({}) < start ({})'.format(self.name, self.end,
+                                                           self.start)
+        if self.type == 'bool':
+            assert self.end == self.start, \
+                   'bool field ({}) is too wide'.format(self.name)
+
         if "prefix" in attrs:
             self.prefix = attrs["prefix"]
         else: