diff options
| author | Andrii Nakryiko <[email protected]> | 2019-07-28 03:25:26 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2019-07-28 05:36:19 +0000 |
| commit | e87fd8bae44c3eaa6205c9c81419e773896dc157 (patch) | |
| tree | e503465a3c5227bc9c1872a16139c396e87801e7 /tools/lib/bpf/libbpf.c | |
| parent | selftests/bpf: add test selectors by number and name to test_progs (diff) | |
| download | kernel-e87fd8bae44c3eaa6205c9c81419e773896dc157.tar.gz kernel-e87fd8bae44c3eaa6205c9c81419e773896dc157.zip | |
libbpf: return previous print callback from libbpf_set_print
By returning previously set print callback from libbpf_set_print, it's
possible to restore it, eventually. This is useful when running many
independent test with one default print function, but overriding log
verbosity for particular subset of tests.
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/lib/bpf/libbpf.c')
| -rw-r--r-- | tools/lib/bpf/libbpf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 8741c39adb1c..ead915aec349 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -74,9 +74,12 @@ static int __base_pr(enum libbpf_print_level level, const char *format, static libbpf_print_fn_t __libbpf_pr = __base_pr; -void libbpf_set_print(libbpf_print_fn_t fn) +libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn) { + libbpf_print_fn_t old_print_fn = __libbpf_pr; + __libbpf_pr = fn; + return old_print_fn; } __printf(2, 3) |
