diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2017-11-03 13:59:07 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-05 22:28:51 +0900 |
commit | 0b1c27db12fd338ed912fec18f5cc02d7bd4e54e (patch) | |
tree | 0dd8caba4edcc1dee3ba8c30b520d57ace8ced45 /tools/bpf/bpftool/common.c | |
parent | 8a3b718ac2c29abcba8e12636710cff3cee8c01b (diff) | |
download | linux-0b1c27db12fd338ed912fec18f5cc02d7bd4e54e.tar.gz linux-0b1c27db12fd338ed912fec18f5cc02d7bd4e54e.tar.bz2 linux-0b1c27db12fd338ed912fec18f5cc02d7bd4e54e.zip |
tools: bpftool: move p_err() and p_info() from main.h to common.c
The two functions were declared as static inline in a header file. There
is no particular reason why they should be inlined, they just happened to
remain in the same header file when they were turned from macros to
functions in a precious commit.
Make them non-inlined functions and move them to common.c file instead.
Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/bpf/bpftool/common.c')
-rw-r--r-- | tools/bpf/bpftool/common.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index f0288269dae8..aa7017098b2a 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -50,6 +50,37 @@ #include "main.h" +void p_err(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + if (json_output) { + jsonw_start_object(json_wtr); + jsonw_name(json_wtr, "error"); + jsonw_vprintf_enquote(json_wtr, fmt, ap); + jsonw_end_object(json_wtr); + } else { + fprintf(stderr, "Error: "); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + } + va_end(ap); +} + +void p_info(const char *fmt, ...) +{ + va_list ap; + + if (json_output) + return; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, "\n"); + va_end(ap); +} + static bool is_bpffs(char *path) { struct statfs st_fs; |