aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
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
parenta81f309b57265e5760b926274e1f1681e7550e41 (diff)
all: apply linter auto fixes
./tools/syz-env bin/golangci-lint run ./... --fix
Diffstat (limited to 'pkg')
-rw-r--r--pkg/bisect/bisect.go5
-rw-r--r--pkg/build/build.go15
-rw-r--r--pkg/compiler/check.go17
-rw-r--r--pkg/csource/common.go8
-rw-r--r--pkg/csource/csource.go14
-rw-r--r--pkg/csource/options.go6
-rw-r--r--pkg/declextract/declextract.go4
-rw-r--r--pkg/email/parser.go4
-rw-r--r--pkg/email/parser_test.go6
-rw-r--r--pkg/ifuzz/powerpc/pseudo.go5
-rw-r--r--pkg/ifuzz/x86/decode.go12
-rw-r--r--pkg/ifuzz/x86/encode.go36
-rw-r--r--pkg/kcidb/client.go2
-rw-r--r--pkg/kconfig/kconfig.go8
-rw-r--r--pkg/report/report.go8
-rw-r--r--pkg/runtest/run.go4
-rw-r--r--pkg/symbolizer/addr2line.go6
-rw-r--r--pkg/vcs/linux.go12
18 files changed, 93 insertions, 79 deletions
diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go
index ba022e514..c4b2ebf50 100644
--- a/pkg/bisect/bisect.go
+++ b/pkg/bisect/bisect.go
@@ -749,9 +749,10 @@ func (env *env) testPredicate() (vcs.BisectResult, error) {
}
// For fix bisections, results are inverted.
if env.cfg.Fix {
- if testRes1.verdict == vcs.BisectBad {
+ switch testRes1.verdict {
+ case vcs.BisectBad:
testRes1.verdict = vcs.BisectGood
- } else if testRes1.verdict == vcs.BisectGood {
+ case vcs.BisectGood:
testRes1.verdict = vcs.BisectBad
}
}
diff --git a/pkg/build/build.go b/pkg/build/build.go
index 86906a0f7..26ba8f4d3 100644
--- a/pkg/build/build.go
+++ b/pkg/build/build.go
@@ -156,13 +156,14 @@ type builder interface {
func getBuilder(targetOS, targetArch, vmType string) (builder, error) {
if targetOS == targets.Linux {
- if vmType == targets.GVisor {
+ switch vmType {
+ case targets.GVisor:
return gvisor{}, nil
- } else if vmType == "cuttlefish" {
+ case "cuttlefish":
return cuttlefish{}, nil
- } else if vmType == "proxyapp:android" {
+ case "proxyapp:android":
return android{}, nil
- } else if vmType == targets.Starnix {
+ case targets.Starnix:
return starnix{}, nil
}
}
@@ -266,7 +267,7 @@ func extractCauseInner(s []byte, kernelSrc string) ([]byte, string) {
file := ""
for i := range lines {
if stripPrefix != nil {
- lines[i] = bytes.Replace(lines[i], stripPrefix, nil, -1)
+ lines[i] = bytes.ReplaceAll(lines[i], stripPrefix, nil)
}
if file == "" {
for _, fileRe := range fileRes {
@@ -292,8 +293,8 @@ func extractCauseInner(s []byte, kernelSrc string) ([]byte, string) {
res := bytes.Join(lines, []byte{'\n'})
// gcc uses these weird quotes around identifiers, which may be
// mis-rendered by systems that don't understand utf-8.
- res = bytes.Replace(res, []byte("‘"), []byte{'\''}, -1)
- res = bytes.Replace(res, []byte("’"), []byte{'\''}, -1)
+ res = bytes.ReplaceAll(res, []byte("‘"), []byte{'\''})
+ res = bytes.ReplaceAll(res, []byte("’"), []byte{'\''})
return res, file
}
diff --git a/pkg/compiler/check.go b/pkg/compiler/check.go
index bd3489ccc..121e7386a 100644
--- a/pkg/compiler/check.go
+++ b/pkg/compiler/check.go
@@ -393,7 +393,8 @@ func (comp *compiler) checkRequiredCallAttrs(call *ast.Call, callAttrNames map[s
}
}
- if desc == typeStruct {
+ switch desc {
+ case typeStruct:
s := comp.structs[t.Ident]
// Prune recursion, can happen even on correct tree via opt pointers.
if checked[s.Name.Name] {
@@ -404,10 +405,10 @@ func (comp *compiler) checkRequiredCallAttrs(call *ast.Call, callAttrNames map[s
for _, fld := range fields {
comp.checkRequiredCallAttrs(call, callAttrNames, fld.Type, checked)
}
- } else if desc == typeArray {
+ case typeArray:
typ := t.Args[0]
comp.checkRequiredCallAttrs(call, callAttrNames, typ, checked)
- } else if desc == typePtr {
+ case typePtr:
typ := t.Args[1]
comp.checkRequiredCallAttrs(call, callAttrNames, typ, checked)
}
@@ -502,9 +503,10 @@ func (comp *compiler) checkFieldPathsRec(t0, t *ast.Type, parents []parentDesc,
_, args, _ := comp.getArgsBase(t, isArg)
for i, arg := range args {
argDesc := desc.Args[i]
- if argDesc.Type == typeArgLenTarget {
+ switch argDesc.Type {
+ case typeArgLenTarget:
comp.validateFieldPath(arg, t0, t, parents, warned)
- } else if argDesc.Type == typeArgType {
+ case typeArgType:
comp.checkFieldPathsRec(t0, arg, parents, checked, warned, argDesc.IsArg)
}
}
@@ -1548,13 +1550,14 @@ func (comp *compiler) checkDupConstsCall(n *ast.Call, dups map[string]map[string
constArgID := ""
for i, arg := range n.Args {
desc := comp.getTypeDesc(arg.Type)
- if desc == typeConst {
+ switch desc {
+ case typeConst:
v := arg.Type.Args[0].Value
if v != 0 && v != 18446744073709551516 { // AT_FDCWD
constArgID += fmt.Sprintf("(%v-%v)", i, fmt.Sprintf("%v", v))
hasConsts = true
}
- } else if desc == typeResource {
+ case typeResource:
constArgID += fmt.Sprintf("(%v-%v)", i, arg.Type.Ident)
}
}
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
diff --git a/pkg/declextract/declextract.go b/pkg/declextract/declextract.go
index 7320279bc..923e2440f 100644
--- a/pkg/declextract/declextract.go
+++ b/pkg/declextract/declextract.go
@@ -419,8 +419,8 @@ func (ctx *context) specialInt4(field, typ string, needBase bool) string {
}
func (ctx *context) specialIntptr(field, typ string, needBase bool) string {
- switch {
- case field == "sigsetsize":
+ switch field {
+ case "sigsetsize":
return fmt.Sprintf("const[8 %v]", maybeBaseType("intptr", needBase))
}
return ""
diff --git a/pkg/email/parser.go b/pkg/email/parser.go
index 3ebd7ac08..6db3d2415 100644
--- a/pkg/email/parser.go
+++ b/pkg/email/parser.go
@@ -368,9 +368,9 @@ func extractArgsTokens(body string, num int) string {
if lineEnd == -1 {
lineEnd = len(body) - pos
}
- line := strings.TrimSpace(strings.Replace(body[pos:pos+lineEnd], "\t", " ", -1))
+ line := strings.TrimSpace(strings.ReplaceAll(body[pos:pos+lineEnd], "\t", " "))
for {
- line1 := strings.Replace(line, " ", " ", -1)
+ line1 := strings.ReplaceAll(line, " ", " ")
if line == line1 {
break
}
diff --git a/pkg/email/parser_test.go b/pkg/email/parser_test.go
index 87f6ec38e..c9e7022ae 100644
--- a/pkg/email/parser_test.go
+++ b/pkg/email/parser_test.go
@@ -19,7 +19,7 @@ func TestExtractCommand(t *testing.T) {
if diff := cmp.Diff(test.cmd, cmd); diff != "" {
t.Fatal(diff)
}
- cmd, _ = extractCommand(strings.Replace(test.body, "\n", "\r\n", -1))
+ cmd, _ = extractCommand(strings.ReplaceAll(test.body, "\n", "\r\n"))
if diff := cmp.Diff(test.cmd, cmd); diff != "" {
t.Fatal(diff)
}
@@ -130,8 +130,8 @@ func TestParse(t *testing.T) {
}
t.Run(fmt.Sprint(i), func(t *testing.T) { body(t, test) })
- test.email = strings.Replace(test.email, "\n", "\r\n", -1)
- test.res.Body = strings.Replace(test.res.Body, "\n", "\r\n", -1)
+ test.email = strings.ReplaceAll(test.email, "\n", "\r\n")
+ test.res.Body = strings.ReplaceAll(test.res.Body, "\n", "\r\n")
t.Run(fmt.Sprint(i)+"rn", func(t *testing.T) { body(t, test) })
}
}
diff --git a/pkg/ifuzz/powerpc/pseudo.go b/pkg/ifuzz/powerpc/pseudo.go
index f67a38907..fcc7b0941 100644
--- a/pkg/ifuzz/powerpc/pseudo.go
+++ b/pkg/ifuzz/powerpc/pseudo.go
@@ -96,10 +96,11 @@ func (gen *generator) sc(lev uint) {
hcrange := gen.r.Intn(3)
offset := 4
maxhc := MaxHcall
- if hcrange == 1 {
+ switch hcrange {
+ case 1:
offset = 0xf000
maxhc = 0xf810
- } else if hcrange == 2 {
+ case 2:
offset = 0xef00
maxhc = 0xef20
}
diff --git a/pkg/ifuzz/x86/decode.go b/pkg/ifuzz/x86/decode.go
index 0160e0fd3..dd9418e07 100644
--- a/pkg/ifuzz/x86/decode.go
+++ b/pkg/ifuzz/x86/decode.go
@@ -65,20 +65,22 @@ func (insnset *InsnSet) Decode(mode iset.Mode, text []byte) (int, error) {
for len(text) != 0 && prefixes[text[0]] {
switch text[0] {
case 0x66:
- if immSize == 4 {
+ switch immSize {
+ case 4:
immSize1 = 2
operSize1 = 2
- } else if immSize == 2 {
+ case 2:
immSize1 = 4
operSize1 = 4
}
case 0x67:
- if addrSize == 8 {
+ switch addrSize {
+ case 8:
addrSize1 = 4
- } else if addrSize == 4 {
+ case 4:
dispSize1 = 2
addrSize1 = 2
- } else if addrSize == 2 {
+ case 2:
dispSize1 = 4
addrSize1 = 4
}
diff --git a/pkg/ifuzz/x86/encode.go b/pkg/ifuzz/x86/encode.go
index 59b9a294a..b196e81b2 100644
--- a/pkg/ifuzz/x86/encode.go
+++ b/pkg/ifuzz/x86/encode.go
@@ -90,20 +90,22 @@ func (insn *Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
for _, pref := range code {
switch pref {
case 0x66:
- if immSize == 4 {
+ switch immSize {
+ case 4:
immSize1 = 2
operSize1 = 2
- } else if immSize == 2 {
+ case 2:
immSize1 = 4
operSize1 = 4
}
case 0x67:
- if addrSize == 8 {
+ switch addrSize {
+ case 8:
addrSize1 = 4
- } else if addrSize == 4 {
+ case 4:
dispSize1 = 2
addrSize1 = 2
- } else if addrSize == 2 {
+ case 2:
dispSize1 = 4
addrSize1 = 4
}
@@ -125,15 +127,17 @@ func (insn *Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
}
vexB = byte(r.Intn(2))
W := byte(r.Intn(2))
- if insn.Rexw == 1 {
+ switch insn.Rexw {
+ case 1:
W = 1
- } else if insn.Rexw == -1 {
+ case -1:
W = 0
}
L := byte(r.Intn(2))
- if insn.VexL == 1 {
+ switch insn.VexL {
+ case 1:
L = 1
- } else if insn.VexL == -1 {
+ case -1:
L = 0
}
pp := byte(r.Intn(4))
@@ -174,11 +178,12 @@ func (insn *Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
}
reg := byte(insn.Reg)
- if insn.Reg == -1 {
+ switch insn.Reg {
+ case -1:
reg = byte(r.Intn(8))
- } else if insn.Reg == -6 {
+ case -6:
reg = byte(r.Intn(6)) // segment register
- } else if insn.Reg == -8 {
+ case -8:
if rexR {
reg = 0 // CR8
} else {
@@ -242,11 +247,12 @@ func (insn *Insn) Encode(cfg *iset.Config, r *rand.Rand) []byte {
}
addImm := func(imm int) {
- if imm == -1 {
+ switch imm {
+ case -1:
imm = immSize
- } else if imm == -2 {
+ case -2:
imm = addrSize
- } else if imm == -3 {
+ case -3:
imm = operSize
}
if imm != 0 {
diff --git a/pkg/kcidb/client.go b/pkg/kcidb/client.go
index 1c4d53764..687386f37 100644
--- a/pkg/kcidb/client.go
+++ b/pkg/kcidb/client.go
@@ -178,7 +178,7 @@ func normalizeRepo(repo string) string {
// and where it isn't. We know that "https:" is supported on kernel.org,
// and that's the main case we need to fix up. "https:" is always used
// for github.com and googlesource.com.
- return strings.Replace(repo, "git://git.kernel.org", "https://git.kernel.org", -1)
+ return strings.ReplaceAll(repo, "git://git.kernel.org", "https://git.kernel.org")
}
func (c *Client) extID(id string) string {
diff --git a/pkg/kconfig/kconfig.go b/pkg/kconfig/kconfig.go
index 7cb54a1bb..15dc0d22a 100644
--- a/pkg/kconfig/kconfig.go
+++ b/pkg/kconfig/kconfig.go
@@ -449,9 +449,9 @@ func (kp *kconfigParser) parseDefaultValue() {
}
func (kp *kconfigParser) expandString(str string) string {
- str = strings.Replace(str, "$(SRCARCH)", kp.target.KernelHeaderArch, -1)
- str = strings.Replace(str, "$SRCARCH", kp.target.KernelHeaderArch, -1)
- str = strings.Replace(str, "$(KCONFIG_EXT_PREFIX)", "", -1)
- str = strings.Replace(str, "$(MALI_KCONFIG_EXT_PREFIX)", "", -1) // ChromeOS.
+ str = strings.ReplaceAll(str, "$(SRCARCH)", kp.target.KernelHeaderArch)
+ str = strings.ReplaceAll(str, "$SRCARCH", kp.target.KernelHeaderArch)
+ str = strings.ReplaceAll(str, "$(KCONFIG_EXT_PREFIX)", "")
+ str = strings.ReplaceAll(str, "$(MALI_KCONFIG_EXT_PREFIX)", "") // ChromeOS.
return str
}
diff --git a/pkg/report/report.go b/pkg/report/report.go
index 44d4563e2..2ac039fdd 100644
--- a/pkg/report/report.go
+++ b/pkg/report/report.go
@@ -438,10 +438,10 @@ type frameExtractor func(frames []string) (string, int)
var parseStackTrace *regexp.Regexp
func compile(re string) *regexp.Regexp {
- re = strings.Replace(re, "{{ADDR}}", "0x[0-9a-f]+", -1)
- re = strings.Replace(re, "{{PC}}", "\\[\\<?(?:0x)?[0-9a-f]+\\>?\\]", -1)
- re = strings.Replace(re, "{{FUNC}}", "([a-zA-Z0-9_]+)(?:\\.|\\+)", -1)
- re = strings.Replace(re, "{{SRC}}", "([a-zA-Z0-9-_/.]+\\.[a-z]+:[0-9]+)", -1)
+ re = strings.ReplaceAll(re, "{{ADDR}}", "0x[0-9a-f]+")
+ re = strings.ReplaceAll(re, "{{PC}}", "\\[\\<?(?:0x)?[0-9a-f]+\\>?\\]")
+ re = strings.ReplaceAll(re, "{{FUNC}}", "([a-zA-Z0-9_]+)(?:\\.|\\+)")
+ re = strings.ReplaceAll(re, "{{SRC}}", "([a-zA-Z0-9-_/.]+\\.[a-z]+:[0-9]+)")
return regexp.MustCompile(re)
}
diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go
index e95a1aa38..36159b9a7 100644
--- a/pkg/runtest/run.go
+++ b/pkg/runtest/run.go
@@ -100,10 +100,10 @@ func (ctx *Context) Run(waitCtx context.Context) error {
if req.err != nil {
fail++
result = fmt.Sprintf("FAIL: %v",
- strings.Replace(req.err.Error(), "\n", "\n\t", -1))
+ strings.ReplaceAll(req.err.Error(), "\n", "\n\t"))
if req.result != nil && len(req.result.Output) != 0 {
result += fmt.Sprintf("\n\t%s",
- strings.Replace(string(req.result.Output), "\n", "\n\t", -1))
+ strings.ReplaceAll(string(req.result.Output), "\n", "\n\t"))
}
} else {
ok++
diff --git a/pkg/symbolizer/addr2line.go b/pkg/symbolizer/addr2line.go
index bb4e4a3fa..35cbfbe98 100644
--- a/pkg/symbolizer/addr2line.go
+++ b/pkg/symbolizer/addr2line.go
@@ -136,10 +136,8 @@ func parse(interner *Interner, s *bufio.Scanner) ([]Frame, error) {
return nil, fmt.Errorf("failed to parse pc '%v' in addr2line output: %w", s.Text(), err)
}
var frames []Frame
- for {
- if !s.Scan() {
- break
- }
+ for s.Scan() {
+
ln := s.Text()
if len(ln) > 3 && ln[0] == '0' && ln[1] == 'x' {
break
diff --git a/pkg/vcs/linux.go b/pkg/vcs/linux.go
index e34fe9186..f1e73a265 100644
--- a/pkg/vcs/linux.go
+++ b/pkg/vcs/linux.go
@@ -50,7 +50,8 @@ func (ctx *linux) PreviousReleaseTags(commit, compilerType string) ([]string, er
}
cutoff := ""
- if compilerType == "gcc" {
+ switch compilerType {
+ case "gcc":
// Initially we tried to stop at 3.8 because:
// v3.8 does not work with modern perl, and as we go further in history
// make stops to work, then binutils, glibc, etc. So we stop at v3.8.
@@ -75,7 +76,7 @@ func (ctx *linux) PreviousReleaseTags(commit, compilerType string) ([]string, er
// This has caused lots of bad bisection results, see #3224. We either need a new
// universal image or a kernel version dependant image selection.
cutoff = "v4.18"
- } else if compilerType == "clang" {
+ case "clang":
// v5.3 was the first release with solid clang support, however I was able to
// compile v5.1..v5.3 using a newer defconfig + make oldconfig. Everything older
// would require further cherry-picks.
@@ -139,11 +140,12 @@ func (ctx *linux) EnvForCommit(
setLinuxTagConfigs(cf, tags)
compiler := ""
- if compilerType == "gcc" {
+ switch compilerType {
+ case "gcc":
compiler = linuxGCCPath(tags, binDir, defaultCompiler)
- } else if compilerType == "clang" {
+ case "clang":
compiler = linuxClangPath(tags, binDir, defaultCompiler)
- } else {
+ default:
return nil, fmt.Errorf("unsupported bisect compiler: %v", compilerType)
}