tools: bpftool: add pointer to file argument to print_hex()
Make print_hex() able to print to any file instead of standard output
only, and rename it to fprint_hex(). The function can now be called with
the info() macro, for example, without splitting the output between
standard and error outputs.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index d60f530..aa6d72e 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -224,7 +224,7 @@ static int show_prog(int fd)
printf("name %s ", info.name);
printf("tag ");
- print_hex(info.tag, BPF_TAG_SIZE, "");
+ fprint_hex(stdout, info.tag, BPF_TAG_SIZE, "");
printf("\n");
if (info.load_time) {
@@ -319,7 +319,7 @@ static void dump_xlated(void *buf, unsigned int len, bool opcodes)
if (opcodes) {
printf(" ");
- print_hex(insn + i, 8, " ");
+ fprint_hex(stdout, insn + i, 8, " ");
printf("\n");
}