linux-stable/tools/bpf/bpftool
Quentin Monnet 9a5ab8bf1d tools: bpftool: turn err() and info() macros into functions
Turn err() and info() macros into functions.

In order to avoid naming conflicts with variables in the code, rename
them as p_err() and p_info() respectively.

The behavior of these functions is similar to the one of the macros for
plain output. However, when JSON output is requested, these macros
return a JSON-formatted "error" object instead of printing a message to
stderr.

To handle error messages correctly with JSON, a modification was brought
to their behavior nonetheless: the functions now append a end-of-line
character at the end of the message. This way, we can remove end-of-line
characters at the end of the argument strings, and not have them in the
JSON output.

All error messages are formatted to hold in a single call to p_err(), in
order to produce a single JSON field.

Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-24 01:25:09 +01:00
..
Documentation tools: bpftool: add option parsing to bpftool, --help and --version 2017-10-24 01:25:08 +01:00
Makefile tools: bpftool: use the kernel's instruction printer 2017-10-10 12:30:16 -07:00
common.c tools: bpftool: turn err() and info() macros into functions 2017-10-24 01:25:09 +01:00
jit_disasm.c tools: bpftool: add JSON output for `bpftool prog dump jited *` command 2017-10-24 01:25:08 +01:00
json_writer.c tools: bpftool: add JSON output for `bpftool prog dump xlated *` command 2017-10-24 01:25:08 +01:00
json_writer.h tools: bpftool: add JSON output for `bpftool prog dump xlated *` command 2017-10-24 01:25:08 +01:00
main.c tools: bpftool: turn err() and info() macros into functions 2017-10-24 01:25:09 +01:00
main.h tools: bpftool: turn err() and info() macros into functions 2017-10-24 01:25:09 +01:00
map.c tools: bpftool: turn err() and info() macros into functions 2017-10-24 01:25:09 +01:00
prog.c tools: bpftool: turn err() and info() macros into functions 2017-10-24 01:25:09 +01:00