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

libbpf-tools/profile: Check if nr_cpus is zero #5120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion libbpf-tools/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ int main(int argc, char **argv)
libbpf_set_print(libbpf_print_fn);

nr_cpus = libbpf_num_possible_cpus();
if (nr_cpus < 0) {
if (nr_cpus <= 0) {
printf("failed to get # of possible cpus: '%s'!\n",
strerror(-nr_cpus));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you that a result of 0 from libbpf_num_possible_cpus can be treated as a failure case.

However, on line 589, strerror(0) will print 'Success'. Please check this. Thank you.

return 1;
Expand Down
Loading