From 55adcb8ca0ca0b7185e917ece137fae218365c89 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 16 Dec 2020 14:21:05 +0100 Subject: all: use tool.Failf instead of local functions --- pkg/csource/gen.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'pkg/csource') diff --git a/pkg/csource/gen.go b/pkg/csource/gen.go index 53b34bbc2..c92c4b581 100644 --- a/pkg/csource/gen.go +++ b/pkg/csource/gen.go @@ -11,17 +11,19 @@ import ( "io/ioutil" "os" "regexp" + + "github.com/google/syzkaller/pkg/tool" ) func main() { out, err := os.Create("generated.go") if err != nil { - failf("%v", err) + tool.Fail(err) } defer out.Close() data, err := ioutil.ReadFile("../../executor/common.h") if err != nil { - failf("%v", err) + tool.Fail(err) } executorFilenames := []string{ "common_linux.h", @@ -60,20 +62,15 @@ func main() { fmt.Fprintf(out, "`\n") } -func failf(msg string, args ...interface{}) { - fmt.Fprintf(os.Stderr, msg+"\n", args...) - os.Exit(1) -} - func replaceIncludes(filenames []string, location string, data []byte) []byte { for _, include := range filenames { contents, err := ioutil.ReadFile(location + include) if err != nil { - failf("%v", err) + tool.Fail(err) } replace := []byte("#include \"" + include + "\"") if bytes.Index(data, replace) == -1 { - failf("can't find %v include", include) + tool.Failf("can't find %v include", include) } data = bytes.Replace(data, replace, contents, -1) } -- cgit mrf-deployment