Skip to contentSkip to conversation

selftests/bpf: properly initialize linfo in sockmap_basic

PATCH Applied Stanislav Fomichev 3 participants 3 messages Oct 2, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/bpf: properly initialize linfo in sockmap_basic

When using -Werror=missing-braces, compiler complains about missing braces. Let's use use ={} initialization which should do the job:

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function 'test_sockmap_iter':
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: missing braces around initializer [-Werror=missing-braces]

  union bpf_iter_link_info linfo = {0};
        ^

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: (near initialization for 'linfo.map') [-Werror=missing-braces] tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: At top level:

---
 tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c +1 -1
index 4c4224e3e10a..85f73261fab0 100644
@@ -198,7 +198,7 @@ static void test_sockmap_copy(enum bpf_map_type map_type)
 {
 	DECLARE_LIBBPF_OPTS(bpf_iter_attach_opts, opts);
 	int err, len, src_fd, iter_fd, duration = 0;
-	union bpf_iter_link_info linfo = {0};
+	union bpf_iter_link_info linfo = {};
 	__u32 i, num_sockets, num_elems;
 	struct bpf_iter_sockmap *skel;
 	__s64 *sock_fd = NULL;
Signature · 1 line
2.28.0.709.gb0816b6eb0-goog
#1 lore raw
This patch was applied to bpf/bpf-next.git (refs/heads/master):

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

Quoted 11 lines · On Thu, 1 Oct 2020 17:04:51 -0700 you wrote:

When using -Werror=missing-braces, compiler complains about missing braces. Let's use use ={} initialization which should do the job:

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function 'test_sockmap_iter':
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: missing braces around initializer [-Werror=missing-braces]

  union bpf_iter_link_info linfo = {0};
        ^

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: (near initialization for 'linfo.map') [-Werror=missing-braces] tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: At top level:

[...]

Here is the summary with links:
- [bpf-next] selftests/bpf: properly initialize linfo in sockmap_basic

    https://git.kernel.org/bpf/bpf-next/c/48ca6243c6ad

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Acked-by on v1 1/1
#2 lore raw
In reply to Stanislav Fomichev
Quoted 5 lines · Stanislav Fomichev

When using -Werror=missing-braces, compiler complains about missing braces. Let's use use ={} initialization which should do the job:

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: In function 'test_sockmap_iter':
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: missing braces around initializer [-Werror=missing-braces]

Quoted 7 lines
  union bpf_iter_link_info linfo = {0};
        ^

tools/testing/selftests/bpf/prog_tests/sockmap_basic.c:181:8: error: (near initialization for 'linfo.map') [-Werror=missing-braces] tools/testing/selftests/bpf/prog_tests/sockmap_basic.c: At top level:

---

Works for me.

Quoted 19 lines
 tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c +1 -1
index 4c4224e3e10a..85f73261fab0 100644
@@ -198,7 +198,7 @@ static void test_sockmap_copy(enum bpf_map_type map_type)
 {
 	DECLARE_LIBBPF_OPTS(bpf_iter_attach_opts, opts);
 	int err, len, src_fd, iter_fd, duration = 0;
-	union bpf_iter_link_info linfo = {0};
+	union bpf_iter_link_info linfo = {};
 	__u32 i, num_sockets, num_elems;
 	struct bpf_iter_sockmap *skel;
 	__s64 *sock_fd = NULL;
Signature · 1 line
2.28.0.709.gb0816b6eb0-goog