From a3857c4e90fa4a3fbe78bd4b53cdc77aa91533cf Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 26 Aug 2017 21:36:08 +0200 Subject: pkg/compiler, sys/syz-sysgen: move const handling to pkg/compiler Now pkg/compiler deals with consts. --- sys/syz-extract/extract.go | 10 +++++----- sys/syz-extract/fetch.go | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'sys/syz-extract') diff --git a/sys/syz-extract/extract.go b/sys/syz-extract/extract.go index d3547dbcb..5f978a37e 100644 --- a/sys/syz-extract/extract.go +++ b/sys/syz-extract/extract.go @@ -68,12 +68,12 @@ func main() { failf("failed to read input file: %v", err) } - top, ok := ast.Parse(indata, filepath.Dir(inname), nil) - if !ok { + desc := ast.Parse(indata, filepath.Dir(inname), nil) + if desc == nil { os.Exit(1) } - consts := compileConsts(archs[*flagArch], top) + consts := compileConsts(archs[*flagArch], desc) out := new(bytes.Buffer) generateConsts(*flagArch, consts, out) @@ -95,8 +95,8 @@ func generateConsts(arch string, consts map[string]uint64, out io.Writer) { } } -func compileConsts(arch *Arch, top []interface{}) map[string]uint64 { - valArr, includes, incdirs, defines := compiler.ExtractConsts(top) +func compileConsts(arch *Arch, desc *ast.Description) map[string]uint64 { + valArr, includes, incdirs, defines := compiler.ExtractConsts(desc) if len(valArr) == 0 { return nil } diff --git a/sys/syz-extract/fetch.go b/sys/syz-extract/fetch.go index c480b8563..2340395cc 100644 --- a/sys/syz-extract/fetch.go +++ b/sys/syz-extract/fetch.go @@ -58,8 +58,13 @@ func fetchValues(arch string, vals []string, includes []string, incdirs []string } flagVals := strings.Split(string(out), " ") + if len(out) == 0 { + flagVals = nil + } if len(flagVals) != len(vals)-len(undeclared) { - failf("fetched wrong number of values %v != %v - %v", len(flagVals), len(vals), len(undeclared)) + failf("fetched wrong number of values %v != %v - %v\nflagVals: %q\nvals: %q\nundeclared: %q", + len(flagVals), len(vals), len(undeclared), + flagVals, vals, undeclared) } res := make(map[string]uint64) j := 0 -- cgit mrf-deployment