Skip to content

Commit 1be18b3

Browse files
authored
error: consider errno as a return value (#332)
CGo provide us a way to get errno value from C code as a return value, so it's always a good idea to make use of it.
1 parent 7c15abd commit 1be18b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libbpfgo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,9 +2091,9 @@ func BPFProgramTypeIsSupported(progType BPFProgType) (bool, error) {
20912091
}
20922092

20932093
func NumPossibleCPUs() (int, error) {
2094-
numCPUs, _ := C.libbpf_num_possible_cpus()
2094+
numCPUs, errC := C.libbpf_num_possible_cpus()
20952095
if numCPUs < 0 {
2096-
return 0, fmt.Errorf("failed to retrieve the number of CPUs")
2096+
return 0, fmt.Errorf("failed to retrieve the number of CPUs: %w", errC)
20972097
}
20982098
return int(numCPUs), nil
20992099
}

0 commit comments

Comments
 (0)