diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-12-18 18:30:39 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-12-19 19:32:45 +0100 |
| commit | 20c6855484620eda011e4e4002c6f7f272a878c4 (patch) | |
| tree | e8143cbd4d72702e02a91cd68883c7117681954b /tools/syz-check/check.go | |
| parent | af9047c60a3db32d5e43c29321f8f531db051a63 (diff) | |
prog: refactor bitfields representation
All callers of BitfieldMiddle just want static size (0 for middle).
Make it so: Size for middle bitfields just returns 0. Removes lots of if's.
Introduce Type.UnitSize, which now holds the underlying type for bitfields.
This will be needed to fix #1542 b/c even if UnitSize=4 for last bitfield
Size can be anywhere from 0 to 4 (not necessary equal to UnitSize due to overlapping).
Diffstat (limited to 'tools/syz-check/check.go')
| -rw-r--r-- | tools/syz-check/check.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go index 561786013..0582d892c 100644 --- a/tools/syz-check/check.go +++ b/tools/syz-check/check.go @@ -187,9 +187,9 @@ func checkStruct(typ *prog.StructDesc, astStruct *ast.Struct, str *dwarf.StructT if field.FieldName() != fld.Name { desc += "/" + fld.Name } - if field.Size() != uint64(fld.Type.Size()) { + if field.UnitSize() != uint64(fld.Type.Size()) { warn(pos, "%v: bad size: syz=%v kernel=%v", - desc, field.Size(), fld.Type.Size()) + desc, field.UnitSize(), fld.Type.Size()) } if offset != uint64(fld.ByteOffset) { warn(pos, "%v: bad offset: syz=%v kernel=%v", @@ -212,9 +212,7 @@ func checkStruct(typ *prog.StructDesc, astStruct *ast.Struct, str *dwarf.StructT } } ai++ - if !field.BitfieldMiddle() { - offset += field.Size() - } + offset += field.Size() } if ai != len(str.Field) { warn(astStruct.Pos, "struct %v: bad number of fields: syz=%v kernel=%v", typ.Name(), ai, len(str.Field)) |
