[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200626081720.5546-2-danieltimlee@gmail.com>
Date: Fri, 26 Jun 2020 17:17:19 +0900
From: "Daniel T. Lee" <danieltimlee@...il.com>
To: Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>,
Yonghong Song <yhs@...com>, Martin KaFai Lau <kafai@...com>,
Andrii Nakryiko <andriin@...com>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: [PATCH 2/3] samples: bpf: cleanup pointer error check with libbpf
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@...il.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(-)
diff --git a/samples/bpf/sampleip_user.c b/samples/bpf/sampleip_user.c
index 921c505bb567..554dfa1cb34d 100644
--- a/samples/bpf/sampleip_user.c
+++ b/samples/bpf/sampleip_user.c
@@ -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;
}
diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
index ac1ba368195c..8bcb9b4bfbe6 100644
--- a/samples/bpf/trace_event_user.c
+++ b/samples/bpf/trace_event_user.c
@@ -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;
}
diff --git a/samples/bpf/tracex1_user.c b/samples/bpf/tracex1_user.c
index 9d4adb7fd834..d3e01807dcd0 100644
--- a/samples/bpf/tracex1_user.c
+++ b/samples/bpf/tracex1_user.c
@@ -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;
}
diff --git a/samples/bpf/tracex5_user.c b/samples/bpf/tracex5_user.c
index 98dad57a96c4..65c753b30121 100644
--- a/samples/bpf/tracex5_user.c
+++ b/samples/bpf/tracex5_user.c
@@ -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;
}
diff --git a/samples/bpf/tracex7_user.c b/samples/bpf/tracex7_user.c
index fdcd6580dd73..10c896732139 100644
--- a/samples/bpf/tracex7_user.c
+++ b/samples/bpf/tracex7_user.c
@@ -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;
}
--
2.25.1
Powered by blists - more mailing lists