When BTF fails to load, only show the warning for callers that didn't supply a log_buf. This will remove an unneeded warning for users loading BPF programs (via `bpf_object__sanitize_and_load_btf`) on kernels that don't require BTF. This also assumes that callers providing a log_buf know what they're doing. Signed-off-by: Jordan Rome <linux@xxxxxxxxxxxxxx> --- tools/lib/bpf/btf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index eea99c766a20..e4a463bda0b8 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -1447,10 +1447,11 @@ int btf_load_into_kernel(struct btf *btf, goto retry_load; err = -errno; - pr_warn("BTF loading error: %s\n", errstr(err)); /* don't print out contents of custom log_buf */ - if (!log_buf && buf[0]) + if (!log_buf && buf[0]) { + pr_warn("BTF loading error: %s\n", errstr(err)); pr_warn("-- BEGIN BTF LOAD LOG ---\n%s\n-- END BTF LOAD LOG --\n", buf); + } } done: -- 2.43.5