2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-16 01:04:08 +08:00

tools: bpftool: fix format strings and arguments for jsonw_printf()

There are some mismatches between format strings and arguments passed to
jsonw_printf() in the BTF dumper for bpftool, which seems harmless but
may result in warnings if the "__printf()" attribute is used correctly
for jsonw_printf(). Let's fix relevant format strings and type cast.

Fixes: b12d6ec097 ("bpf: btf: add btf print functionality")
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
Quentin Monnet 2019-08-15 15:32:16 +01:00 committed by Alexei Starovoitov
parent 9def249dc8
commit 22c349e8db

View File

@ -26,9 +26,9 @@ static void btf_dumper_ptr(const void *data, json_writer_t *jw,
bool is_plain_text) bool is_plain_text)
{ {
if (is_plain_text) if (is_plain_text)
jsonw_printf(jw, "%p", *(unsigned long *)data); jsonw_printf(jw, "%p", data);
else else
jsonw_printf(jw, "%u", *(unsigned long *)data); jsonw_printf(jw, "%lu", *(unsigned long *)data);
} }
static int btf_dumper_modifier(const struct btf_dumper *d, __u32 type_id, static int btf_dumper_modifier(const struct btf_dumper *d, __u32 type_id,
@ -216,7 +216,7 @@ static int btf_dumper_int(const struct btf_type *t, __u8 bit_offset,
switch (BTF_INT_ENCODING(*int_type)) { switch (BTF_INT_ENCODING(*int_type)) {
case 0: case 0:
if (BTF_INT_BITS(*int_type) == 64) if (BTF_INT_BITS(*int_type) == 64)
jsonw_printf(jw, "%lu", *(__u64 *)data); jsonw_printf(jw, "%llu", *(__u64 *)data);
else if (BTF_INT_BITS(*int_type) == 32) else if (BTF_INT_BITS(*int_type) == 32)
jsonw_printf(jw, "%u", *(__u32 *)data); jsonw_printf(jw, "%u", *(__u32 *)data);
else if (BTF_INT_BITS(*int_type) == 16) else if (BTF_INT_BITS(*int_type) == 16)
@ -229,7 +229,7 @@ static int btf_dumper_int(const struct btf_type *t, __u8 bit_offset,
break; break;
case BTF_INT_SIGNED: case BTF_INT_SIGNED:
if (BTF_INT_BITS(*int_type) == 64) if (BTF_INT_BITS(*int_type) == 64)
jsonw_printf(jw, "%ld", *(long long *)data); jsonw_printf(jw, "%lld", *(long long *)data);
else if (BTF_INT_BITS(*int_type) == 32) else if (BTF_INT_BITS(*int_type) == 32)
jsonw_printf(jw, "%d", *(int *)data); jsonw_printf(jw, "%d", *(int *)data);
else if (BTF_INT_BITS(*int_type) == 16) else if (BTF_INT_BITS(*int_type) == 16)