diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-10-26 10:51:06 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-10-26 15:44:28 +0100 |
| commit | e6e35dba937599d098fc034eff2686e5ddc409e9 (patch) | |
| tree | 802be708d0bc84dee01b9285639690a53f1f6f94 /tools/syz-check | |
| parent | d46bc75207fea1d7671c1277dd660cf1a4d7847b (diff) | |
sys/targets: add OS/Arch name consts
We use strings to identify OS/Arch.
These strings are duplicated throughout the code base massively.
golangci-lint points to possiblity of typos and duplication.
We already had to define these names in pkg/csource
and disable checking for prog package. A future change triggers
such warnings in another package.
Add OS/Arch name consts to sys/targets so that they can be used
to refer to OS/Arch. Use the consts everywhere.
Diffstat (limited to 'tools/syz-check')
| -rw-r--r-- | tools/syz-check/check.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/syz-check/check.go b/tools/syz-check/check.go index 86048f9a4..de7145dfb 100644 --- a/tools/syz-check/check.go +++ b/tools/syz-check/check.go @@ -52,7 +52,7 @@ func main() { flagNetlink = flag.Bool("netlink", true, "do checking of netlink policies") ) arches := make(map[string]*string) - for arch := range targets.List["linux"] { + for arch := range targets.List[targets.Linux] { arches[arch] = flag.String("obj-"+arch, "", arch+" kernel object file") } failf := func(msg string, args ...interface{}) { @@ -152,7 +152,7 @@ func writeWarnings(OS string, narches int, warnings []Warn) error { byFile := make(map[string][]Warn) for _, warn := range warnings { // KVM is not supported on ARM completely. - if OS == "linux" && warn.arch == "arm" && strings.HasSuffix(warn.pos.File, "_kvm.txt") { + if OS == targets.Linux && warn.arch == targets.ARM && strings.HasSuffix(warn.pos.File, "_kvm.txt") { continue } byFile[warn.pos.File] = append(byFile[warn.pos.File], warn) @@ -358,7 +358,7 @@ func parseDescriptions(OS, arch string) ([]prog.Type, map[string]*ast.Struct, [] // Finally we compare our descriptions with the kernel policy description. func checkNetlink(OS, arch, obj string, structTypes []prog.Type, locs map[string]*ast.Struct) ([]Warn, error) { - if arch != "amd64" { + if arch != targets.AMD64 { // Netlink policies are arch-independent (?), // so no need to check all arches. // Also our definition of nlaPolicy below is 64-bit specific. |
