* [bpf-next 1/3] samples/bpf: remove unused function with test_lru_dist
2022-12-17 15:38 [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Daniel T. Lee
@ 2022-12-17 15:38 ` Daniel T. Lee
2022-12-17 17:48 ` Yonghong Song
2022-12-17 15:38 ` [bpf-next 2/3] samples/bpf: replace meaningless counter with tracex4 Daniel T. Lee
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Daniel T. Lee @ 2022-12-17 15:38 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>
---
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] 9+ messages in thread* Re: [bpf-next 1/3] samples/bpf: remove unused function with test_lru_dist
2022-12-17 15:38 ` [bpf-next 1/3] samples/bpf: remove unused function with test_lru_dist Daniel T. Lee
@ 2022-12-17 17:48 ` Yonghong Song
0 siblings, 0 replies; 9+ messages in thread
From: Yonghong Song @ 2022-12-17 17:48 UTC (permalink / raw)
To: Daniel T. Lee, Daniel Borkmann, Alexei Starovoitov,
Andrii Nakryiko, Yonghong Song
Cc: bpf, netdev
On 12/17/22 7:38 AM, Daniel T. Lee wrote:
> 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>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bpf-next 2/3] samples/bpf: replace meaningless counter with tracex4
2022-12-17 15:38 [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Daniel T. Lee
2022-12-17 15:38 ` [bpf-next 1/3] samples/bpf: remove unused function with test_lru_dist Daniel T. Lee
@ 2022-12-17 15:38 ` Daniel T. Lee
2022-12-17 17:49 ` Yonghong Song
2022-12-17 15:38 ` [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Daniel T. Lee
2022-12-17 17:48 ` [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Yonghong Song
3 siblings, 1 reply; 9+ messages in thread
From: Daniel T. Lee @ 2022-12-17 15:38 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>
---
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] 9+ messages in thread* Re: [bpf-next 2/3] samples/bpf: replace meaningless counter with tracex4
2022-12-17 15:38 ` [bpf-next 2/3] samples/bpf: replace meaningless counter with tracex4 Daniel T. Lee
@ 2022-12-17 17:49 ` Yonghong Song
0 siblings, 0 replies; 9+ messages in thread
From: Yonghong Song @ 2022-12-17 17:49 UTC (permalink / raw)
To: Daniel T. Lee, Daniel Borkmann, Alexei Starovoitov,
Andrii Nakryiko, Yonghong Song
Cc: bpf, netdev
On 12/17/22 7:38 AM, Daniel T. Lee wrote:
> 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>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup
2022-12-17 15:38 [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Daniel T. Lee
2022-12-17 15:38 ` [bpf-next 1/3] samples/bpf: remove unused function with test_lru_dist Daniel T. Lee
2022-12-17 15:38 ` [bpf-next 2/3] samples/bpf: replace meaningless counter with tracex4 Daniel T. Lee
@ 2022-12-17 15:38 ` Daniel T. Lee
2022-12-17 17:49 ` Yonghong Song
2022-12-17 17:48 ` [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Yonghong Song
3 siblings, 1 reply; 9+ messages in thread
From: Daniel T. Lee @ 2022-12-17 15:38 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>
---
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] 9+ messages in thread* Re: [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup
2022-12-17 15:38 ` [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Daniel T. Lee
@ 2022-12-17 17:49 ` Yonghong Song
0 siblings, 0 replies; 9+ messages in thread
From: Yonghong Song @ 2022-12-17 17:49 UTC (permalink / raw)
To: Daniel T. Lee, Daniel Borkmann, Alexei Starovoitov,
Andrii Nakryiko, Yonghong Song
Cc: bpf, netdev
On 12/17/22 7:38 AM, Daniel T. Lee wrote:
> 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>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with
2022-12-17 15:38 [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Daniel T. Lee
` (2 preceding siblings ...)
2022-12-17 15:38 ` [bpf-next 3/3] samples/bpf: fix uninitialized warning with test_current_task_under_cgroup Daniel T. Lee
@ 2022-12-17 17:48 ` Yonghong Song
2022-12-18 0:08 ` Daniel T. Lee
3 siblings, 1 reply; 9+ messages in thread
From: Yonghong Song @ 2022-12-17 17:48 UTC (permalink / raw)
To: Daniel T. Lee, Daniel Borkmann, Alexei Starovoitov,
Andrii Nakryiko, Yonghong Song
Cc: bpf, netdev
On 12/17/22 7:38 AM, Daniel T. Lee wrote:
> 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.
Could you change the subject line to
samples/bpf: fix LLVM compilation warning
>
> Daniel T. Lee (3):
> samples/bpf: remove unused function with test_lru_dist
> samples/bpf: replace meaningless counter with tracex4
> samples/bpf: fix uninitialized warning with
> test_current_task_under_cgroup
>
> samples/bpf/test_current_task_under_cgroup_user.c | 6 ++++--
> samples/bpf/test_lru_dist.c | 5 -----
> samples/bpf/tracex4_user.c | 4 ++--
> 3 files changed, 6 insertions(+), 9 deletions(-)
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with
2022-12-17 17:48 ` [bpf-next 0/3] samples/bpf: fix LLVM compilation warning with Yonghong Song
@ 2022-12-18 0:08 ` Daniel T. Lee
0 siblings, 0 replies; 9+ messages in thread
From: Daniel T. Lee @ 2022-12-18 0:08 UTC (permalink / raw)
To: Yonghong Song
Cc: Daniel Borkmann, Alexei Starovoitov, Andrii Nakryiko,
Yonghong Song, bpf, netdev
On Sun, Dec 18, 2022 at 2:48 AM Yonghong Song <yhs@meta.com> wrote:
>
>
>
> On 12/17/22 7:38 AM, Daniel T. Lee wrote:
> > 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.
>
> Could you change the subject line to
> samples/bpf: fix LLVM compilation warning
>
> >
> > Daniel T. Lee (3):
> > samples/bpf: remove unused function with test_lru_dist
> > samples/bpf: replace meaningless counter with tracex4
> > samples/bpf: fix uninitialized warning with
> > test_current_task_under_cgroup
> >
> > samples/bpf/test_current_task_under_cgroup_user.c | 6 ++++--
> > samples/bpf/test_lru_dist.c | 5 -----
> > samples/bpf/tracex4_user.c | 4 ++--
> > 3 files changed, 6 insertions(+), 9 deletions(-)
> >
Thanks for pointing this out.
I will send a v2 patch.
^ permalink raw reply [flat|nested] 9+ messages in thread