Skip to content

Commit ed9db1a

Browse files
committed
use bytes instead of string, switch instead of slices
1 parent e8502b9 commit ed9db1a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

unix/linux/mksysnum.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ package main
88

99
import (
1010
"bufio"
11+
"bytes"
1112
"fmt"
1213
"os"
1314
"os/exec"
1415
"regexp"
15-
"slices"
1616
"sort"
1717
"strconv"
1818
"strings"
@@ -127,16 +127,17 @@ func main() {
127127
os.Exit(1)
128128
}
129129

130-
if slices.Contains([]string{"riscv64", "loong64", "arm64"}, goarch) {
131-
// Kernel linux v6.11 removed some __NR_* constants that only
130+
switch goarch {
131+
case "riscv64", "loong64", "arm64":
132+
// Kernel linux v6.11 removed some __NR_* macros that only
132133
// existed on some architectures as an implementation detail. In
133134
// order to keep backwards compatibility we add them back.
134135
//
135-
// See https://lkml.org/lkml/2024/8/5/1283
136-
if !strings.Contains(string(cmd), "#define __NR_arch_specific_syscall") {
136+
// See https://lkml.org/lkml/2024/8/5/1283.
137+
if !bytes.Contains(cmd, []byte("#define __NR_arch_specific_syscall")) {
137138
cmd = append(cmd, []byte("#define __NR_arch_specific_syscall 244\n")...)
138139
}
139-
if !strings.Contains(string(cmd), "#define __NR_fstatat") {
140+
if !bytes.Contains(cmd, []byte("#define __NR_fstatat")) {
140141
cmd = append(cmd, []byte("#define __NR_fstatat 79\n")...)
141142
}
142143
}

0 commit comments

Comments
 (0)