@@ -186,7 +186,7 @@ int main(int argc, char **argv)
}
prog = bpf_object__find_program_by_name(obj, "do_sample");
- if (!prog) {
+ if (libbpf_get_error(prog)) {
fprintf(stderr, "ERROR: finding a prog in obj file failed\n");
goto cleanup;
}
@@ -318,7 +318,7 @@ int main(int argc, char **argv)
}
prog = bpf_object__find_program_by_name(obj, "bpf_prog1");
- if (!prog) {
+ if (libbpf_get_error(prog)) {
printf("finding a prog in obj file failed\n");
goto cleanup;
}
@@ -20,7 +20,7 @@ int main(int ac, char **argv)
}
prog = bpf_object__find_program_by_name(obj, "bpf_prog1");
- if (!prog) {
+ if (libbpf_get_error(prog)) {
fprintf(stderr, "ERROR: finding a prog in obj file failed\n");
goto cleanup;
}
@@ -53,7 +53,7 @@ int main(int ac, char **argv)
}
prog = bpf_object__find_program_by_name(obj, "bpf_prog1");
- if (!prog) {
+ if (libbpf_get_error(prog)) {
printf("finding a prog in obj file failed\n");
goto cleanup;
}
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
}
prog = bpf_object__find_program_by_name(obj, "bpf_prog1");
- if (!prog) {
+ if (libbpf_get_error(prog)) {
fprintf(stderr, "ERROR: finding a prog in obj file failed\n");
goto cleanup;
}
Libbpf has its own helper function to check for errors in the bpf data structure (pointer). And Some codes do not use this libbbpf helper function and check the pointer's error directly. This commit clean up the existing pointer error check logic with libbpf. Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> --- samples/bpf/sampleip_user.c | 2 +- samples/bpf/trace_event_user.c | 2 +- samples/bpf/tracex1_user.c | 2 +- samples/bpf/tracex5_user.c | 2 +- samples/bpf/tracex7_user.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)