aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/bpf-loader.c
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2019-02-01 16:14:17 -0800
committerAlexei Starovoitov <ast@kernel.org>2019-02-04 09:40:59 -0800
commit6f1ae8b6628b9e054d3a8c959cf472234944a578 (patch)
treea06e49a2ac5d5a35f3fb6a25c1ea689f3c6bfe40 /tools/perf/util/bpf-loader.c
parenttools/bpf: print out btf log at LIBBPF_WARN level (diff)
downloadlinux-dev-6f1ae8b6628b9e054d3a8c959cf472234944a578.tar.xz
linux-dev-6f1ae8b6628b9e054d3a8c959cf472234944a578.zip
tools/bpf: simplify libbpf API function libbpf_set_print()
Currently, the libbpf API function libbpf_set_print() takes three function pointer parameters for warning, info and debug printout respectively. This patch changes the API to have just one function pointer parameter and the function pointer has one additional parameter "debugging level". So if in the future, if the debug level is increased, the function signature won't change. Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/perf/util/bpf-loader.c')
-rw-r--r--tools/perf/util/bpf-loader.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 2f3eb6d293ee..38afdbe6a9e0 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -24,21 +24,17 @@
#include "llvm-utils.h"
#include "c++/clang-c.h"
-#define DEFINE_PRINT_FN(name, level) \
-static int libbpf_##name(const char *fmt, ...) \
-{ \
- va_list args; \
- int ret; \
- \
- va_start(args, fmt); \
- ret = veprintf(level, verbose, pr_fmt(fmt), args);\
- va_end(args); \
- return ret; \
-}
+static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)),
+ const char *fmt, ...)
+{
+ va_list args;
+ int ret;
-DEFINE_PRINT_FN(warning, 1)
-DEFINE_PRINT_FN(info, 1)
-DEFINE_PRINT_FN(debug, 1)
+ va_start(args, fmt);
+ ret = veprintf(1, verbose, pr_fmt(fmt), args);
+ va_end(args);
+ return ret;
+}
struct bpf_prog_priv {
bool is_tp;
@@ -59,9 +55,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
struct bpf_object *obj;
if (!libbpf_initialized) {
- libbpf_set_print(libbpf_warning,
- libbpf_info,
- libbpf_debug);
+ libbpf_set_print(libbpf_perf_print);
libbpf_initialized = true;
}
@@ -79,9 +73,7 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
struct bpf_object *obj;
if (!libbpf_initialized) {
- libbpf_set_print(libbpf_warning,
- libbpf_info,
- libbpf_debug);
+ libbpf_set_print(libbpf_perf_print);
libbpf_initialized = true;
}