Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linters: add makezero and fix a related bug #1832

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ linters:
- staticcheck
- unused
- gosimple
- makezero

linters-settings:
goheader:
Expand Down
18 changes: 9 additions & 9 deletions pkg/btf/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,12 @@ func AvailableSyscalls() ([]string, error) {
}

ret := []string{}
for _, key := range syscallinfo.SyscallsNames() {
if key == "" {
continue
for key, value := range syscallinfo.SyscallsNames() {
if value == "" {
return nil, fmt.Errorf("syscall name for %q is empty", key)
}

sym, err := arch.AddSyscallPrefix(key)
sym, err := arch.AddSyscallPrefix(value)
if err != nil {
return nil, err
}
Expand All @@ -298,7 +298,7 @@ func AvailableSyscalls() ([]string, error) {
continue
}

ret = append(ret, key)
ret = append(ret, value)
}

return ret, nil
Expand All @@ -322,14 +322,14 @@ func GetSyscallsList() ([]string, error) {

var list []string

for _, key := range syscallinfo.SyscallsNames() {
for key, value := range syscallinfo.SyscallsNames() {
var fn *btf.Func

if key == "" {
mtardy marked this conversation as resolved.
Show resolved Hide resolved
continue
if value == "" {
return nil, fmt.Errorf("syscall name for %q is empty", key)
}

sym, err := arch.AddSyscallPrefix(key)
sym, err := arch.AddSyscallPrefix(value)
if err != nil {
return []string{}, err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/reader/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func GetIP(i [2]uint64, family uint16) net.IP {

binary.LittleEndian.PutUint64(a, i[0])
binary.LittleEndian.PutUint64(b, i[1])
// nolint:makezero // slices carefully manipulated like arrays
ip := append(a, b...)
return ip
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/syscallinfo/syscallinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var syscallIDs = func() map[string]int {
}()

func SyscallsNames() []string {
ret := make([]string, len(syscallNames))
ret := make([]string, 0, len(syscallNames))

for _, v := range syscallNames {
ret = append(ret, v)
Expand Down
Loading