Skip to content

Commit 9af3775

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
selftests/bpf: fix test_maps' use of bpf_map_create_opts
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>
1 parent fd381ce commit 9af3775

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

tools/testing/selftests/bpf/map_tests/map_percpu_stats.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -326,20 +326,14 @@ static int map_create(__u32 type, const char *name, struct bpf_map_create_opts *
326326

327327
static int create_hash(void)
328328
{
329-
struct bpf_map_create_opts map_opts = {
330-
.sz = sizeof(map_opts),
331-
.map_flags = BPF_F_NO_PREALLOC,
332-
};
329+
LIBBPF_OPTS(bpf_map_create_opts, map_opts, .map_flags = BPF_F_NO_PREALLOC);
333330

334331
return map_create(BPF_MAP_TYPE_HASH, "hash", &map_opts);
335332
}
336333

337334
static int create_percpu_hash(void)
338335
{
339-
struct bpf_map_create_opts map_opts = {
340-
.sz = sizeof(map_opts),
341-
.map_flags = BPF_F_NO_PREALLOC,
342-
};
336+
LIBBPF_OPTS(bpf_map_create_opts, map_opts, .map_flags = BPF_F_NO_PREALLOC);
343337

344338
return map_create(BPF_MAP_TYPE_PERCPU_HASH, "percpu_hash", &map_opts);
345339
}
@@ -356,21 +350,17 @@ static int create_percpu_hash_prealloc(void)
356350

357351
static int create_lru_hash(__u32 type, __u32 map_flags)
358352
{
359-
struct bpf_map_create_opts map_opts = {
360-
.sz = sizeof(map_opts),
361-
.map_flags = map_flags,
362-
};
353+
LIBBPF_OPTS(bpf_map_create_opts, map_opts, .map_flags = map_flags);
363354

364355
return map_create(type, "lru_hash", &map_opts);
365356
}
366357

367358
static int create_hash_of_maps(void)
368359
{
369-
struct bpf_map_create_opts map_opts = {
370-
.sz = sizeof(map_opts),
360+
LIBBPF_OPTS(bpf_map_create_opts, map_opts,
371361
.map_flags = BPF_F_NO_PREALLOC,
372362
.inner_map_fd = create_small_hash(),
373-
};
363+
);
374364
int ret;
375365

376366
ret = map_create_opts(BPF_MAP_TYPE_HASH_OF_MAPS, "hash_of_maps",

0 commit comments

Comments
 (0)