* [bpf-next v3 1/3] samples/bpf: remove unused function with test_lru_dist
2022-12-18 0:43 [bpf-next v3 0/3] samples/bpf: fix LLVM compilation warning with samples Daniel T. Lee
@ 2022-12-18 0:43 ` Daniel T. Lee
2022-12-18 0:43 ` [bpf-next v3 2/3] samples/bpf: replace meaningless counter with tracex4 Daniel T. Lee
2022-12-18 0:43 ` [bpf-next v3 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Daniel T. Lee
2 siblings, 0 replies; 4+ messages in thread
From: Daniel T. Lee @ 2022-12-18 0:43 UTC (permalink / raw)
To: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko,
Yonghong Song
Cc: bpf, netdev
Currently, compiling samples/bpf with LLVM warns about the unused
function with test_lru_dist.
./samples/bpf/test_lru_dist.c:45:19:
warning: unused function 'list_empty' [-Wunused-function]
static inline int list_empty(const struct list_head *head)
^
1 warning generated.
This commit resolve this compiler warning by removing the abandoned
function.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
---
samples/bpf/test_lru_dist.c | 5 -----
1 file changed, 5 deletions(-)
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)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [bpf-next v3 2/3] samples/bpf: replace meaningless counter with tracex4
2022-12-18 0:43 [bpf-next v3 0/3] samples/bpf: fix LLVM compilation warning with samples Daniel T. Lee
2022-12-18 0:43 ` [bpf-next v3 1/3] samples/bpf: remove unused function with test_lru_dist Daniel T. Lee
@ 2022-12-18 0:43 ` Daniel T. Lee
2022-12-18 0:43 ` [bpf-next v3 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Daniel T. Lee
2 siblings, 0 replies; 4+ messages in thread
From: Daniel T. Lee @ 2022-12-18 0:43 UTC (permalink / raw)
To: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko,
Yonghong Song
Cc: bpf, netdev
Currently, compiling samples/bpf with LLVM warns about the unused but
set variable with tracex4_user.
./samples/bpf/tracex4_user.c:54:14:
warning: variable 'i' set but not used [-Wunused-but-set-variable]
int map_fd, i, j = 0;
^
1 warning generated.
This commit resolve this compiler warning by replacing the meaningless
counter.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
---
samples/bpf/tracex4_user.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [bpf-next v3 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup
2022-12-18 0:43 [bpf-next v3 0/3] samples/bpf: fix LLVM compilation warning with samples Daniel T. Lee
2022-12-18 0:43 ` [bpf-next v3 1/3] samples/bpf: remove unused function with test_lru_dist Daniel T. Lee
2022-12-18 0:43 ` [bpf-next v3 2/3] samples/bpf: replace meaningless counter with tracex4 Daniel T. Lee
@ 2022-12-18 0:43 ` Daniel T. Lee
2 siblings, 0 replies; 4+ messages in thread
From: Daniel T. Lee @ 2022-12-18 0:43 UTC (permalink / raw)
To: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko,
Yonghong Song
Cc: bpf, netdev
Currently, compiling samples/bpf with LLVM warns about the uninitialized
use of variable with test_current_task_under_cgroup.
./samples/bpf/test_current_task_under_cgroup_user.c:57:6:
warning: variable 'cg2' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (setup_cgroup_environment())
^~~~~~~~~~~~~~~~~~~~~~~~~~
./samples/bpf/test_current_task_under_cgroup_user.c:106:8:
note: uninitialized use occurs here
close(cg2);
^~~
./samples/bpf/test_current_task_under_cgroup_user.c:57:2:
note: remove the 'if' if its condition is always false
if (setup_cgroup_environment())
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./samples/bpf/test_current_task_under_cgroup_user.c:19:9:
note: initialize the variable 'cg2' to silence this warning
int cg2, idx = 0, rc = 1;
^
= 0
1 warning generated.
This commit resolve this compiler warning by pre-initialize the variable
with error for safeguard.
Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
---
samples/bpf/test_current_task_under_cgroup_user.c | 6 ++++--
1 file changed, 4 insertions(+), 2 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:
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread