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-trace2syz | |
| 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-trace2syz')
| -rw-r--r-- | tools/syz-trace2syz/proggen/fuzz.go | 3 | ||||
| -rw-r--r-- | tools/syz-trace2syz/proggen/proggen_test.go | 3 | ||||
| -rw-r--r-- | tools/syz-trace2syz/trace2syz.go | 5 |
3 files changed, 7 insertions, 4 deletions
diff --git a/tools/syz-trace2syz/proggen/fuzz.go b/tools/syz-trace2syz/proggen/fuzz.go index 7f74534b9..da4fae7bb 100644 --- a/tools/syz-trace2syz/proggen/fuzz.go +++ b/tools/syz-trace2syz/proggen/fuzz.go @@ -8,10 +8,11 @@ package proggen import ( "github.com/google/syzkaller/prog" _ "github.com/google/syzkaller/sys/linux/gen" // pull in the target + "github.com/google/syzkaller/sys/targets" ) var linuxTarget = func() *prog.Target { - target, err := prog.GetTarget("linux", "amd64") + target, err := prog.GetTarget(targets.Linux, targets.AMD64) if err != nil { panic(err) } diff --git a/tools/syz-trace2syz/proggen/proggen_test.go b/tools/syz-trace2syz/proggen/proggen_test.go index 0eaec0d8d..451147bed 100644 --- a/tools/syz-trace2syz/proggen/proggen_test.go +++ b/tools/syz-trace2syz/proggen/proggen_test.go @@ -12,6 +12,7 @@ import ( "github.com/google/syzkaller/prog" _ "github.com/google/syzkaller/sys" + "github.com/google/syzkaller/sys/targets" "github.com/google/syzkaller/tools/syz-trace2syz/parser" ) @@ -265,7 +266,7 @@ r0 = openat$rtc(0xffffffffffffff9c, &(0x7f0000000000)='/dev/rtc0\x00', 0x0, 0x0) ioctl$RTC_WKALM_SET(r0, 0x4028700f, &(0x7f0000000040)={0x0, 0x0, {0x0, 0x0, 0x0, 0x0, 0x10000, 0x5181}})`, }, } - target, err := prog.GetTarget("linux", "amd64") + target, err := prog.GetTarget(targets.Linux, targets.AMD64) if err != nil { t.Fatal(err) } diff --git a/tools/syz-trace2syz/trace2syz.go b/tools/syz-trace2syz/trace2syz.go index d634f137f..89081d57c 100644 --- a/tools/syz-trace2syz/trace2syz.go +++ b/tools/syz-trace2syz/trace2syz.go @@ -22,6 +22,7 @@ import ( "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/prog" _ "github.com/google/syzkaller/sys" + "github.com/google/syzkaller/sys/targets" "github.com/google/syzkaller/tools/syz-trace2syz/proggen" ) @@ -32,8 +33,8 @@ var ( ) const ( - goos = "linux" // Target OS - arch = "amd64" // Target architecture + goos = targets.Linux // Target OS + arch = targets.AMD64 // Target architecture ) func main() { |
