aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2023-07-21 11:54:11 +0200
committerTaras Madan <tarasmadan@google.com>2023-07-24 09:12:13 +0000
commit7549a7e1b57831cf6b08ce4700fc6e53417919f9 (patch)
tree8e027cdaf7abbc52a5fb29c37c7137dfd2122e7a /sys
parentf7eecac8b446ef11cff4122de6f496ad5eaba3a9 (diff)
all: use special placeholder for errors
Diffstat (limited to 'sys')
-rw-r--r--sys/syz-extract/extract.go2
-rw-r--r--sys/syz-extract/fetch.go8
-rw-r--r--sys/syz-extract/freebsd.go4
-rw-r--r--sys/syz-extract/linux.go8
-rw-r--r--sys/syz-extract/netbsd.go2
-rw-r--r--sys/syz-extract/openbsd.go4
6 files changed, 14 insertions, 14 deletions
diff --git a/sys/syz-extract/extract.go b/sys/syz-extract/extract.go
index adcb1d0ac..e391a6654 100644
--- a/sys/syz-extract/extract.go
+++ b/sys/syz-extract/extract.go
@@ -193,7 +193,7 @@ func createArches(OS string, archArray, files []string) ([]*Arch, int, error) {
if *flagBuild {
dir, err := os.MkdirTemp("", "syzkaller-kernel-build")
if err != nil {
- return nil, 0, fmt.Errorf("failed to create temp dir: %v", err)
+ return nil, 0, fmt.Errorf("failed to create temp dir: %w", err)
}
buildDir = dir
} else if *flagBuildDir != "" {
diff --git a/sys/syz-extract/fetch.go b/sys/syz-extract/fetch.go
index dd5123b31..a7a0e46fe 100644
--- a/sys/syz-extract/fetch.go
+++ b/sys/syz-extract/fetch.go
@@ -70,7 +70,7 @@ func extract(info *compiler.ConstInfo, cc string, args []string, params *extract
}
}
if !tryAgain {
- return nil, nil, fmt.Errorf("failed to run compiler: %v %v\n%v\n%s",
+ return nil, nil, fmt.Errorf("failed to run compiler: %v %v\n%w\n%s",
cc, args, err, out)
}
data.Values = nil
@@ -121,7 +121,7 @@ type CompileData struct {
func compile(cc string, args []string, data *CompileData) (string, []byte, error) {
src := new(bytes.Buffer)
if err := srcTemplate.Execute(src, data); err != nil {
- return "", nil, fmt.Errorf("failed to generate source: %v", err)
+ return "", nil, fmt.Errorf("failed to generate source: %w", err)
}
binFile, err := osutil.TempFile("syz-extract-bin")
if err != nil {
@@ -147,7 +147,7 @@ func compile(cc string, args []string, data *CompileData) (string, []byte, error
func extractFromExecutable(binFile string) ([]uint64, error) {
out, err := osutil.Command(binFile).CombinedOutput()
if err != nil {
- return nil, fmt.Errorf("failed to run flags binary: %v\n%s", err, out)
+ return nil, fmt.Errorf("failed to run flags binary: %w\n%s", err, out)
}
if len(out) == 0 {
return nil, nil
@@ -156,7 +156,7 @@ func extractFromExecutable(binFile string) ([]uint64, error) {
for _, val := range strings.Split(string(out), " ") {
n, err := strconv.ParseUint(val, 10, 64)
if err != nil {
- return nil, fmt.Errorf("failed to parse value: %v (%v)", err, val)
+ return nil, fmt.Errorf("failed to parse value: %w (%v)", err, val)
}
vals = append(vals, n)
}
diff --git a/sys/syz-extract/freebsd.go b/sys/syz-extract/freebsd.go
index 2660e832c..99f74d636 100644
--- a/sys/syz-extract/freebsd.go
+++ b/sys/syz-extract/freebsd.go
@@ -34,11 +34,11 @@ func (*freebsd) prepareArch(arch *Arch) error {
if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", archName, "include"),
filepath.Join(arch.buildDir, "machine")); err != nil {
- return fmt.Errorf("failed to create link: %v", err)
+ return fmt.Errorf("failed to create link: %w", err)
}
if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", "x86", "include"),
filepath.Join(arch.buildDir, "x86")); err != nil {
- return fmt.Errorf("failed to create link: %v", err)
+ return fmt.Errorf("failed to create link: %w", err)
}
return nil
}
diff --git a/sys/syz-extract/linux.go b/sys/syz-extract/linux.go
index 086c2d64b..4ba940ef4 100644
--- a/sys/syz-extract/linux.go
+++ b/sys/syz-extract/linux.go
@@ -33,7 +33,7 @@ func (*linux) prepare(sourcedir string, build bool, arches []*Arch) error {
out, err := osutil.RunCmd(time.Hour, sourcedir, "make", "mrproper", "ARCH="+arch,
"-j", fmt.Sprint(runtime.NumCPU()))
if err != nil {
- return fmt.Errorf("make mrproper failed: %v\n%s", err, out)
+ return fmt.Errorf("make mrproper failed: %w\n%s", err, out)
}
}
}
@@ -82,7 +82,7 @@ func (*linux) prepareArch(arch *Arch) error {
makeArgs := build.LinuxMakeArgs(arch.target, "", "", "", arch.buildDir)
out, err := osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "defconfig")...)
if err != nil {
- return fmt.Errorf("make defconfig failed: %v\n%s", err, out)
+ return fmt.Errorf("make defconfig failed: %w\n%s", err, out)
}
_, err = osutil.RunCmd(time.Minute, arch.buildDir, filepath.Join(kernelDir, "scripts", "config"),
// powerpc arch is configured to be big-endian by default, but we want little-endian powerpc.
@@ -106,11 +106,11 @@ func (*linux) prepareArch(arch *Arch) error {
}
out, err = osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "olddefconfig")...)
if err != nil {
- return fmt.Errorf("make olddefconfig failed: %v\n%s", err, out)
+ return fmt.Errorf("make olddefconfig failed: %w\n%s", err, out)
}
out, err = osutil.RunCmd(time.Hour, kernelDir, "make", append(makeArgs, "init/main.o")...)
if err != nil {
- return fmt.Errorf("make failed: %v\n%s", err, out)
+ return fmt.Errorf("make failed: %w\n%s", err, out)
}
return nil
}
diff --git a/sys/syz-extract/netbsd.go b/sys/syz-extract/netbsd.go
index 8f86cd5d5..8cc5efac0 100644
--- a/sys/syz-extract/netbsd.go
+++ b/sys/syz-extract/netbsd.go
@@ -38,7 +38,7 @@ func (*netbsd) prepareArch(arch *Arch) error {
func machineLink(arch *Arch, machine, dest string) error {
if err := os.Symlink(machineInclude(arch, machine),
filepath.Join(arch.buildDir, dest)); err != nil {
- return fmt.Errorf("failed to create link: %v", err)
+ return fmt.Errorf("failed to create link: %w", err)
}
return nil
}
diff --git a/sys/syz-extract/openbsd.go b/sys/syz-extract/openbsd.go
index 5f7036356..f103d1949 100644
--- a/sys/syz-extract/openbsd.go
+++ b/sys/syz-extract/openbsd.go
@@ -24,11 +24,11 @@ func (*openbsd) prepare(sourcedir string, build bool, arches []*Arch) error {
func (*openbsd) prepareArch(arch *Arch) error {
if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", "arch", "amd64", "include"),
filepath.Join(arch.buildDir, "amd64")); err != nil {
- return fmt.Errorf("failed to create link: %v", err)
+ return fmt.Errorf("failed to create link: %w", err)
}
if err := os.Symlink(filepath.Join(arch.sourceDir, "sys", "arch", "amd64", "include"),
filepath.Join(arch.buildDir, "machine")); err != nil {
- return fmt.Errorf("failed to create link: %v", err)
+ return fmt.Errorf("failed to create link: %w", err)
}
return nil
}