Skip to content

Commit

Permalink
error: consider errno as a return value (#332)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
geyslan authored Jun 2, 2023
1 parent 7c15abd commit 1be18b3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libbpfgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2091,9 +2091,9 @@ func BPFProgramTypeIsSupported(progType BPFProgType) (bool, error) {
}

func NumPossibleCPUs() (int, error) {
numCPUs, _ := C.libbpf_num_possible_cpus()
numCPUs, errC := C.libbpf_num_possible_cpus()
if numCPUs < 0 {
return 0, fmt.Errorf("failed to retrieve the number of CPUs")
return 0, fmt.Errorf("failed to retrieve the number of CPUs: %w", errC)
}
return int(numCPUs), nil
}

0 comments on commit 1be18b3

Please sign in to comment.