diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2016-10-06 20:09:01 +0200 |
|---|---|---|
| committer | Andrey Konovalov <andreyknvl@google.com> | 2016-10-10 16:13:26 +0200 |
| commit | 0ee95115a16f1b62a0478377f7e2cef58f02b8c8 (patch) | |
| tree | a7e101d3422790748d54355fe66a3b4c18d63da4 /sysparser | |
| parent | 7311e016f3cd79d2563ed06e6488c2d96be5d1f5 (diff) | |
Report duplicate fields and args
Diffstat (limited to 'sysparser')
| -rw-r--r-- | sysparser/lexer.go | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sysparser/lexer.go b/sysparser/lexer.go index 85f657d41..06210a584 100644 --- a/sysparser/lexer.go +++ b/sysparser/lexer.go @@ -90,13 +90,13 @@ func Parse(in io.Reader) *Description { 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 + } + fields := make(map[string]bool) + for _, f := range str.Flds { + if fields[f[0]] { + failf("duplicate field %v in struct/union %v", f[0], str.Name) } + fields[f[0]] = true } structs[str.Name] = *str str = nil @@ -178,6 +178,13 @@ func Parse(in io.Reader) *Description { if idx := strings.IndexByte(callName, '$'); idx != -1 { callName = callName[:idx] } + fields := make(map[string]bool) + for _, a := range args { + if fields[a[0]] { + failf("duplicate arg %v in syscall %v", a[0], name) + } + fields[a[0]] = true + } syscalls = append(syscalls, Syscall{name, callName, args, ret}) case '=': // flag |
