Skip to content

Commit 67e3a17

Browse files
committed
Merge branch 'bpf-bpftool-json-fixes'
Quentin Monnet says: ==================== These are two minor fixes to avoid breaking JSON output in batch mode. The first one makes bpftool output a "null" JSON object, as expected in batch mode if nothing else is to be printed, when dumping program instructions into an output file. The second one replaces a call to "perror()" with something that does not break JSON when parsing input file for batch mode. ==================== Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
2 parents 9c481b9 + 9be6d41 commit 67e3a17

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎tools/bpf/bpftool/main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ static int do_batch(int argc, char **argv)
244244
}
245245

246246
if (errno && errno != ENOENT) {
247-
perror("reading batch file failed");
247+
p_err("reading batch file failed: %s", strerror(errno));
248248
err = -1;
249249
} else {
250250
p_info("processed %d lines", lines);

‎tools/bpf/bpftool/prog.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,9 @@ static int do_dump(int argc, char **argv)
774774
n < 0 ? strerror(errno) : "short write");
775775
goto err_free;
776776
}
777+
778+
if (json_output)
779+
jsonw_null(json_wtr);
777780
} else {
778781
if (member_len == &info.jited_prog_len) {
779782
const char *name = NULL;

0 commit comments

Comments
 (0)