aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2025-07-15 16:43:33 +0200
committerTaras Madan <tarasmadan@google.com>2025-07-17 08:31:25 +0000
commitabd11cfd08430ec5f9d2c6dbd0e0f798816922d1 (patch)
tree522a8cc072d07d85c8a1d37b5b3ab89483599b48 /pkg/csource
parenta81f309b57265e5760b926274e1f1681e7550e41 (diff)
all: apply linter auto fixes
./tools/syz-env bin/golangci-lint run ./... --fix
Diffstat (limited to 'pkg/csource')
-rw-r--r--pkg/csource/common.go8
-rw-r--r--pkg/csource/csource.go14
-rw-r--r--pkg/csource/options.go6
3 files changed, 14 insertions, 14 deletions
diff --git a/pkg/csource/common.go b/pkg/csource/common.go
index a065a6bdb..f71926659 100644
--- a/pkg/csource/common.go
+++ b/pkg/csource/common.go
@@ -56,7 +56,7 @@ func createCommonHeader(p, mmapProg *prog.Prog, replacements map[string]string,
}
for from, to := range replacements {
- src = bytes.Replace(src, []byte("/*{{{"+from+"}}}*/"), []byte(to), -1)
+ src = bytes.ReplaceAll(src, []byte("/*{{{"+from+"}}}*/"), []byte(to))
}
for from, to := range map[string]string{
@@ -65,7 +65,7 @@ func createCommonHeader(p, mmapProg *prog.Prog, replacements map[string]string,
"uint16": "uint16_t",
"uint8": "uint8_t",
} {
- src = bytes.Replace(src, []byte(from), []byte(to), -1)
+ src = bytes.ReplaceAll(src, []byte(from), []byte(to))
}
src = regexp.MustCompile("#define SYZ_HAVE_.*").ReplaceAll(src, nil)
@@ -149,7 +149,7 @@ func removeSystemDefines(src []byte, defines []string) ([]byte, error) {
}
}
for def, val := range remove {
- src = bytes.Replace(src, []byte("#define "+def+" "+val+"\n"), nil, -1)
+ src = bytes.ReplaceAll(src, []byte("#define "+def+" "+val+"\n"), nil)
}
// strip: #define __STDC_VERSION__ 201112L
for _, def := range []string{"__STDC_VERSION__"} {
@@ -161,7 +161,7 @@ func removeSystemDefines(src []byte, defines []string) ([]byte, error) {
if end == -1 {
continue
}
- src = bytes.Replace(src, src[pos:end+1], nil, -1)
+ src = bytes.ReplaceAll(src, src[pos:end+1], nil)
}
return src, nil
}
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go
index d5da107b0..a37040e8f 100644
--- a/pkg/csource/csource.go
+++ b/pkg/csource/csource.go
@@ -202,7 +202,7 @@ func (ctx *context) generateSyscalls(calls []string, hasVars bool) string {
fmt.Fprintf(buf, "\tswitch (call) {\n")
for i, c := range calls {
fmt.Fprintf(buf, "\tcase %v:\n", i)
- fmt.Fprintf(buf, "%s", strings.Replace(c, "\t", "\t\t", -1))
+ fmt.Fprintf(buf, "%s", strings.ReplaceAll(c, "\t", "\t\t"))
fmt.Fprintf(buf, "\t\tbreak;\n")
}
fmt.Fprintf(buf, "\t}\n")
@@ -627,10 +627,10 @@ func (ctx *context) postProcess(result []byte) []byte {
if !ctx.opts.HandleSegv {
result = regexp.MustCompile(`\t*NONFAILING\((.*)\);\n`).ReplaceAll(result, []byte("$1;\n"))
}
- result = bytes.Replace(result, []byte("NORETURN"), nil, -1)
- result = bytes.Replace(result, []byte("doexit("), []byte("exit("), -1)
+ result = bytes.ReplaceAll(result, []byte("NORETURN"), nil)
+ result = bytes.ReplaceAll(result, []byte("doexit("), []byte("exit("))
// TODO: Figure out what would be the right replacement for doexit_thread().
- result = bytes.Replace(result, []byte("doexit_thread("), []byte("exit("), -1)
+ result = bytes.ReplaceAll(result, []byte("doexit_thread("), []byte("exit("))
result = regexp.MustCompile(`PRINTF\(.*?\)`).ReplaceAll(result, nil)
result = regexp.MustCompile(`\t*debug\((.*\n)*?.*\);\n`).ReplaceAll(result, nil)
result = regexp.MustCompile(`\t*debug_dump_data\((.*\n)*?.*\);\n`).ReplaceAll(result, nil)
@@ -683,9 +683,9 @@ func (ctx *context) hoistIncludes(result []byte) []byte {
// removeEmptyLines removes duplicate new lines.
func (ctx *context) removeEmptyLines(result []byte) []byte {
for {
- newResult := bytes.Replace(result, []byte{'\n', '\n', '\n'}, []byte{'\n', '\n'}, -1)
- newResult = bytes.Replace(newResult, []byte{'\n', '\n', '\t'}, []byte{'\n', '\t'}, -1)
- newResult = bytes.Replace(newResult, []byte{'\n', '\n', ' '}, []byte{'\n', ' '}, -1)
+ newResult := bytes.ReplaceAll(result, []byte{'\n', '\n', '\n'}, []byte{'\n', '\n'})
+ newResult = bytes.ReplaceAll(newResult, []byte{'\n', '\n', '\t'}, []byte{'\n', '\t'})
+ newResult = bytes.ReplaceAll(newResult, []byte{'\n', '\n', ' '}, []byte{'\n', ' '})
if len(newResult) == len(result) {
return result
}
diff --git a/pkg/csource/options.go b/pkg/csource/options.go
index ba44dd021..02e39980a 100644
--- a/pkg/csource/options.go
+++ b/pkg/csource/options.go
@@ -125,11 +125,11 @@ func (opts Options) checkLinuxOnly(OS string) error {
if OS == targets.Linux {
return nil
}
- if opts.NetInjection && !(OS == targets.OpenBSD || OS == targets.FreeBSD || OS == targets.NetBSD) {
+ if opts.NetInjection && (OS != targets.OpenBSD && OS != targets.FreeBSD && OS != targets.NetBSD) {
return fmt.Errorf("option NetInjection is not supported on %v", OS)
}
if opts.Sandbox == sandboxNamespace ||
- (opts.Sandbox == sandboxSetuid && !(OS == targets.OpenBSD || OS == targets.FreeBSD || OS == targets.NetBSD)) ||
+ (opts.Sandbox == sandboxSetuid && (OS != targets.OpenBSD && OS != targets.FreeBSD && OS != targets.NetBSD)) ||
opts.Sandbox == sandboxAndroid {
return fmt.Errorf("option Sandbox=%v is not supported on %v", opts.Sandbox, OS)
}
@@ -248,7 +248,7 @@ func deserializeLegacyOptions(data string, opts *Options) (int, error) {
// Support for legacy formats.
func deserializeLegacyFormats(data []byte, opts *Options) error {
- data = bytes.Replace(data, []byte("Sandbox: "), []byte("Sandbox:empty "), -1)
+ data = bytes.ReplaceAll(data, []byte("Sandbox: "), []byte("Sandbox:empty "))
strData := string(data)
// We can distinguish between legacy formats by the number