aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-check
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-12-20 14:19:12 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-12-20 16:45:34 +0100
commitf83f92fd5e8f53114eb4e4149c19f2c4d7fddc78 (patch)
treeb7bdfc5bdd2ffb3a9f0044e978b8f85946952134 /tools/syz-check
parentae5ed0b14052adc4be0d98e5e8a46a0b0ab2c565 (diff)
tools/syz-check: inject description compilation warnings
Currently we print them as part of `make genereate`, but nobody reads them, too much output each time. Don't print them in `make generate` and instead print in syz-check, the warn files are a good mechanism to handle "known warnings".
Diffstat (limited to 'tools/syz-check')
-rw-r--r--tools/syz-check/check.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go
index 5bd556516..6b28d3671 100644
--- a/tools/syz-check/check.go
+++ b/tools/syz-check/check.go
@@ -74,7 +74,7 @@ func main() {
}
func check(OS, arch, obj string) error {
- structDescs, locs, err := parseDescriptions(OS, arch)
+ structDescs, locs, warnings1, err := parseDescriptions(OS, arch)
if err != nil {
return err
}
@@ -82,11 +82,11 @@ func check(OS, arch, obj string) error {
if err != nil {
return err
}
- warnings, err := checkImpl(structs, structDescs, locs)
+ warnings2, err := checkImpl(structs, structDescs, locs)
if err != nil {
return err
}
- return writeWarnings(OS, arch, warnings)
+ return writeWarnings(OS, arch, append(warnings1, warnings2...))
}
type Warn struct {
@@ -224,22 +224,24 @@ func checkStruct(typ *prog.StructDesc, astStruct *ast.Struct, str *dwarf.StructT
return warnings, nil
}
-func parseDescriptions(OS, arch string) ([]*prog.KeyedStruct, map[string]*ast.Struct, error) {
+func parseDescriptions(OS, arch string) ([]*prog.KeyedStruct, map[string]*ast.Struct, []Warn, error) {
errorBuf := new(bytes.Buffer)
+ var warnings []Warn
eh := func(pos ast.Pos, msg string) {
+ warnings = append(warnings, Warn{pos, msg})
fmt.Fprintf(errorBuf, "%v: %v\n", pos, msg)
}
top := ast.ParseGlob(filepath.Join("sys", OS, "*.txt"), eh)
if top == nil {
- return nil, nil, fmt.Errorf("failed to parse txt files:\n%s", errorBuf.Bytes())
+ return nil, nil, nil, fmt.Errorf("failed to parse txt files:\n%s", errorBuf.Bytes())
}
consts := compiler.DeserializeConstsGlob(filepath.Join("sys", OS, "*_"+arch+".const"), eh)
if consts == nil {
- return nil, nil, fmt.Errorf("failed to parse const files:\n%s", errorBuf.Bytes())
+ return nil, nil, nil, fmt.Errorf("failed to parse const files:\n%s", errorBuf.Bytes())
}
prg := compiler.Compile(top, consts, targets.Get(OS, arch), eh)
if prg == nil {
- return nil, nil, fmt.Errorf("failed to compile descriptions:\n%s", errorBuf.Bytes())
+ return nil, nil, nil, fmt.Errorf("failed to compile descriptions:\n%s", errorBuf.Bytes())
}
prog.RestoreLinks(prg.Syscalls, prg.Resources, prg.StructDescs)
locs := make(map[string]*ast.Struct)
@@ -249,5 +251,5 @@ func parseDescriptions(OS, arch string) ([]*prog.KeyedStruct, map[string]*ast.St
locs[n.Name.Name] = n
}
}
- return prg.StructDescs, locs, nil
+ return prg.StructDescs, locs, warnings, nil
}