From 3ca39dfc4dd8a2dda5b3a9b8c29e295839490af3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 29 Sep 2016 13:28:03 +0200 Subject: sys: add padding to structs again Struct padding was accidentially lost after: 852e3d2eae98a913b7ec91822ba4dc61059a6955 Restore it. Now with tests. Fixes #78 --- sysparser/lexer.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'sysparser') diff --git a/sysparser/lexer.go b/sysparser/lexer.go index 21c7b77ef..85f657d41 100644 --- a/sysparser/lexer.go +++ b/sysparser/lexer.go @@ -86,8 +86,17 @@ func Parse(in io.Reader) *Description { } } } - if str.IsUnion && len(str.Flds) <= 1 { - failf("union %v has only %v fields, need at least 2", str.Name, len(str.Flds)) + if str.IsUnion { + if len(str.Flds) <= 1 { + failf("union %v has only %v fields, need at least 2", str.Name, len(str.Flds)) + } + fields := make(map[string]bool) + for _, f := range str.Flds { + if fields[f[0]] { + failf("duplicate filed %v in struct/union %v", f[0], str.Name) + } + fields[f[0]] = true + } } structs[str.Name] = *str str = nil -- cgit mrf-deployment