diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-09-14 19:25:01 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-09-15 16:02:37 +0200 |
| commit | 52a33fd516102a98d3753bf69417235b655a68dc (patch) | |
| tree | 351ab73db934d3b4e4babbe27e8801c659f2631b /tools/syz-prog2c | |
| parent | 25f4fe0662f7f3b390d16b2e786f2ba0aa0293f1 (diff) | |
prog: remove default target and all global state
Now each prog function accepts the desired target explicitly.
No global, implicit state involved.
This is much cleaner and allows cross-OS/arch testing, etc.
Diffstat (limited to 'tools/syz-prog2c')
| -rw-r--r-- | tools/syz-prog2c/prog2c.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/syz-prog2c/prog2c.go b/tools/syz-prog2c/prog2c.go index bc6453875..f0ab63f36 100644 --- a/tools/syz-prog2c/prog2c.go +++ b/tools/syz-prog2c/prog2c.go @@ -15,6 +15,7 @@ import ( ) var ( + flagArch = flag.String("arch", runtime.GOARCH, "target arch") flagThreaded = flag.Bool("threaded", false, "create threaded program") flagCollide = flag.Bool("collide", false, "create collide program") flagRepeat = flag.Bool("repeat", false, "repeat program infinitely or not") @@ -36,7 +37,8 @@ func main() { flag.PrintDefaults() os.Exit(1) } - if err := prog.SetDefaultTarget(runtime.GOOS, runtime.GOARCH); err != nil { + target, err := prog.GetTarget(runtime.GOOS, *flagArch) + if err != nil { fmt.Fprintf(os.Stderr, "%v", err) os.Exit(1) } @@ -45,7 +47,7 @@ func main() { fmt.Fprintf(os.Stderr, "failed to read prog file: %v\n", err) os.Exit(1) } - p, err := prog.Deserialize(data) + p, err := target.Deserialize(data) if err != nil { fmt.Fprintf(os.Stderr, "failed to deserialize the program: %v\n", err) os.Exit(1) |
