]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selftests/bpf: fix test_maps' use of bpf_map_create_opts
authorAndrii Nakryiko <andrii@kernel.org>
Sun, 29 Oct 2023 01:15:09 +0000 (18:15 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 2 Nov 2023 05:42:38 +0000 (22:42 -0700)
Use LIBBPF_OPTS() macro to properly initialize bpf_map_create_opts in
test_maps' tests.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20231029011509.2479232-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/map_tests/map_percpu_stats.c

index 1a9eeefda9a8701f967d727813d46db3e8f79850..8bf497a9843e1b97d0e23cd80e82c5787e45c981 100644 (file)
@@ -326,20 +326,14 @@ static int map_create(__u32 type, const char *name, struct bpf_map_create_opts *
 
 static int create_hash(void)
 {
-       struct bpf_map_create_opts map_opts = {
-               .sz = sizeof(map_opts),
-               .map_flags = BPF_F_NO_PREALLOC,
-       };
+       LIBBPF_OPTS(bpf_map_create_opts, map_opts, .map_flags = BPF_F_NO_PREALLOC);
 
        return map_create(BPF_MAP_TYPE_HASH, "hash", &map_opts);
 }
 
 static int create_percpu_hash(void)
 {
-       struct bpf_map_create_opts map_opts = {
-               .sz = sizeof(map_opts),
-               .map_flags = BPF_F_NO_PREALLOC,
-       };
+       LIBBPF_OPTS(bpf_map_create_opts, map_opts, .map_flags = BPF_F_NO_PREALLOC);
 
        return map_create(BPF_MAP_TYPE_PERCPU_HASH, "percpu_hash", &map_opts);
 }
@@ -356,21 +350,17 @@ static int create_percpu_hash_prealloc(void)
 
 static int create_lru_hash(__u32 type, __u32 map_flags)
 {
-       struct bpf_map_create_opts map_opts = {
-               .sz = sizeof(map_opts),
-               .map_flags = map_flags,
-       };
+       LIBBPF_OPTS(bpf_map_create_opts, map_opts, .map_flags = map_flags);
 
        return map_create(type, "lru_hash", &map_opts);
 }
 
 static int create_hash_of_maps(void)
 {
-       struct bpf_map_create_opts map_opts = {
-               .sz = sizeof(map_opts),
+       LIBBPF_OPTS(bpf_map_create_opts, map_opts,
                .map_flags = BPF_F_NO_PREALLOC,
                .inner_map_fd = create_small_hash(),
-       };
+       );
        int ret;
 
        ret = map_create_opts(BPF_MAP_TYPE_HASH_OF_MAPS, "hash_of_maps",