From 1c0d4caf7c7a6ddd5cf24091249448bf2e169495 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 4 Sep 2017 20:51:56 +0200 Subject: sys: change BitfieldLast to BitfieldMiddle That's the condition we always want. Currently we always check: t.BitfieldOffset() == 0 || t.BitfieldLast() now can check just: !t.BitfieldMiddle() --- sys/decl.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'sys/decl.go') diff --git a/sys/decl.go b/sys/decl.go index 1a474616f..077023cf2 100644 --- a/sys/decl.go +++ b/sys/decl.go @@ -34,7 +34,7 @@ type Type interface { Size() uint64 BitfieldOffset() uint64 BitfieldLength() uint64 - BitfieldLast() bool + BitfieldMiddle() bool // returns true for all but last bitfield in a group } func IsPad(t Type) bool { @@ -87,7 +87,7 @@ func (t *TypeCommon) BitfieldLength() uint64 { return 0 } -func (t *TypeCommon) BitfieldLast() bool { +func (t *TypeCommon) BitfieldMiddle() bool { return false } @@ -124,15 +124,7 @@ type IntTypeCommon struct { BitfieldOff uint64 BitfieldLen uint64 BigEndian bool - BitfieldLst bool -} - -func (t *IntTypeCommon) Size() uint64 { - // TODO(dvyukov): check that this is not a middle bitfield - // if t.BitfieldLen != 0 && !t.BitfieldLst { - // panic(fmt.Sprintf("bitfields don't have size: %#v", t)) - // } - return t.TypeCommon.Size() + BitfieldMdl bool } func (t *IntTypeCommon) BitfieldOffset() uint64 { @@ -143,8 +135,8 @@ func (t *IntTypeCommon) BitfieldLength() uint64 { return t.BitfieldLen } -func (t *IntTypeCommon) BitfieldLast() bool { - return t.BitfieldLst +func (t *IntTypeCommon) BitfieldMiddle() bool { + return t.BitfieldMdl } type ConstType struct { -- cgit mrf-deployment