From: Philippe Proulx Date: Thu, 3 Sep 2020 01:23:56 +0000 (-0400) Subject: Fix: _IntegerFieldType.__init__(): use correct alignment X-Git-Tag: v3.0.0~139 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=5833e4da3cdbb6d7946a5fab35a4eb09e4782c25;p=barectf.git Fix: _IntegerFieldType.__init__(): use correct alignment This patch makes _IntegerFieldType.__init__() consider `alignment` if it's not `None` instead of completely ignoring it. 😒 Signed-off-by: Philippe Proulx --- diff --git a/barectf/config.py b/barectf/config.py index e438cfb..1920c87 100644 --- a/barectf/config.py +++ b/barectf/config.py @@ -75,12 +75,10 @@ class _IntegerFieldType(_BitArrayFieldType): def __init__(self, size: Count, byte_order: Optional[ByteOrder] = None, alignment: Optional[Alignment] = None, preferred_display_base: DisplayBase = DisplayBase.DECIMAL): - effective_alignment = 1 + if alignment is None: + alignment = Alignment(8 if size % 8 == 0 else 1) - if alignment is None and size % 8 == 0: - effective_alignment = 8 - - super().__init__(size, byte_order, Alignment(effective_alignment)) + super().__init__(size, byte_order, alignment) self._preferred_display_base = preferred_display_base @property diff --git a/doc/examples/linux-fs-simple/config.yaml b/doc/examples/linux-fs-simple/config.yaml index 9d81b3d..7e7e2cb 100644 --- a/doc/examples/linux-fs-simple/config.yaml +++ b/doc/examples/linux-fs-simple/config.yaml @@ -66,7 +66,6 @@ metadata: packet_size: uint32 content_size: uint32 events_discarded: uint32 - salut: string event-header-type: class: struct fields: