diff mbox series

[bpf-next] selftests/bpf: properly initialize linfo in sockmap_basic

Message ID 20201002000451.1794044-1-sdf@google.com
State New
Headers show
Series [bpf-next] selftests/bpf: properly initialize linfo in sockmap_basic | expand

Commit Message

Stanislav Fomichev Oct. 2, 2020, 12:04 a.m. UTC
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:

Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Fastabend Oct. 2, 2020, 3:59 p.m. UTC | #1
Stanislav Fomichev 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:
> 
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
> ---

Works for me.

Acked-by: John Fastabend <john.fastabend@gmail.com>

>  tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> index 4c4224e3e10a..85f73261fab0 100644
> --- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> +++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
> @@ -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;
> -- 
> 2.28.0.709.gb0816b6eb0-goog
>
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
index 4c4224e3e10a..85f73261fab0 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
@@ -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;