diff options
author | Martin KaFai Lau <martin.lau@kernel.org> | 2022-12-19 14:21:05 -0800 |
---|---|---|
committer | Martin KaFai Lau <martin.lau@kernel.org> | 2022-12-19 14:21:05 -0800 |
commit | 64f4660f691c61506828faef38ef374811fbbe71 (patch) | |
tree | 6fcebd2b0a0d50eab3042f2417678ca80303c1e5 | |
parent | e2bb9e01d589f7fa82573aedd2765ff9b277816a (diff) | |
parent | 68be98e0f4191abc64c871e3e461f275715eaf67 (diff) |
Merge branch 'samples/bpf: fix LLVM compilation warning'
"Daniel T. Lee" says:
====================
Currently, compiling samples/bpf with LLVM emits several warning. They
are only small details, but they do not appear when compiled with GCC.
Detailed compilation command and warning logs can be found from bpf CI.
====================
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
-rw-r--r-- | samples/bpf/test_current_task_under_cgroup_user.c | 6 | ||||
-rw-r--r-- | samples/bpf/test_lru_dist.c | 5 | ||||
-rw-r--r-- | samples/bpf/tracex4_user.c | 4 |
3 files changed, 6 insertions, 9 deletions
diff --git a/samples/bpf/test_current_task_under_cgroup_user.c b/samples/bpf/test_current_task_under_cgroup_user.c index ac251a417f45..6fb25906835e 100644 --- a/samples/bpf/test_current_task_under_cgroup_user.c +++ b/samples/bpf/test_current_task_under_cgroup_user.c @@ -14,9 +14,9 @@ int main(int argc, char **argv) { pid_t remote_pid, local_pid = getpid(); + int cg2 = -1, idx = 0, rc = 1; struct bpf_link *link = NULL; struct bpf_program *prog; - int cg2, idx = 0, rc = 1; struct bpf_object *obj; char filename[256]; int map_fd[2]; @@ -103,7 +103,9 @@ int main(int argc, char **argv) rc = 0; err: - close(cg2); + if (cg2 != -1) + close(cg2); + cleanup_cgroup_environment(); cleanup: diff --git a/samples/bpf/test_lru_dist.c b/samples/bpf/test_lru_dist.c index 5efb91763d65..1c161276d57b 100644 --- a/samples/bpf/test_lru_dist.c +++ b/samples/bpf/test_lru_dist.c @@ -42,11 +42,6 @@ static inline void INIT_LIST_HEAD(struct list_head *list) list->prev = list; } -static inline int list_empty(const struct list_head *head) -{ - return head->next == head; -} - static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next) diff --git a/samples/bpf/tracex4_user.c b/samples/bpf/tracex4_user.c index 227b05a0bc88..dee8f0a091ba 100644 --- a/samples/bpf/tracex4_user.c +++ b/samples/bpf/tracex4_user.c @@ -51,7 +51,7 @@ int main(int ac, char **argv) struct bpf_program *prog; struct bpf_object *obj; char filename[256]; - int map_fd, i, j = 0; + int map_fd, j = 0; snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]); obj = bpf_object__open_file(filename, NULL); @@ -82,7 +82,7 @@ int main(int ac, char **argv) j++; } - for (i = 0; ; i++) { + while (1) { print_old_objects(map_fd); sleep(1); } |