Skip to contentSkip to conversation

libbpf: fix handling of optional field_name in btf_dump__emit_type_decl

PATCH Applied Andrii Nakryiko 2 participants 2 messages Mar 3, 2020 – Mar 4, 2020

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

PATCH 1/1 libbpf: fix handling of optional field_name in btf_dump__emit_type_decl

Internal functions, used by btf_dump__emit_type_decl(), assume field_name is never going to be NULL. Ensure it's always the case.

Fixes 9f81654eebe8 ("libbpf: Expose BTF-to-C type declaration emitting API")
---
 tools/lib/bpf/btf_dump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf_dump.c +1 -1
index bd09ed1710f1..dc451e4de5ad 100644
@@ -1030,7 +1030,7 @@ int btf_dump__emit_type_decl(struct btf_dump *d, __u32 id,
 	if (!OPTS_VALID(opts, btf_dump_emit_type_decl_opts))
 		return -EINVAL;
 
-	fname = OPTS_GET(opts, field_name, NULL);
+	fname = OPTS_GET(opts, field_name, "");
 	lvl = OPTS_GET(opts, indent_level, 0);
 	btf_dump_emit_type_decl(d, id, fname, lvl);
 	return 0;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · Andrii Nakryiko

Internal functions, used by btf_dump__emit_type_decl(), assume field_name is never going to be NULL. Ensure it's always the case.

Fixes 9f81654eebe8 ("libbpf: Expose BTF-to-C type declaration emitting API")

Applied. Thanks