aboutsummaryrefslogtreecommitdiffstats
path: root/sysparser
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-09-29 13:28:03 +0200
committerDmitry Vyukov <dvyukov@google.com>2016-09-29 13:30:08 +0200
commit3ca39dfc4dd8a2dda5b3a9b8c29e295839490af3 (patch)
treed3f4161d07c22e4a08eb0d3edfd61b485ef10579 /sysparser
parentbf21057e7c36c72c1b46aa71bea8dc48509d4c40 (diff)
sys: add padding to structs again
Struct padding was accidentially lost after: 852e3d2eae98a913b7ec91822ba4dc61059a6955 Restore it. Now with tests. Fixes #78
Diffstat (limited to 'sysparser')
-rw-r--r--sysparser/lexer.go13
1 files changed, 11 insertions, 2 deletions
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