diff options
author | Kerin Millar <kfm@plushkava.net> | 2021-03-09 15:28:45 +0000 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-06-09 00:22:15 +0200 |
commit | 001bd5b1b744428c77c68dd371fed58c3dc511f2 (patch) | |
tree | b4d33c54b7de20f7dd3e35f89dcaa49c16d54ebc /src/json.c | |
parent | 8161ea9433dc4bffc8641f6fd2635de31e6d2daf (diff) |
json: Print warnings to stderr rather than stdout
Unsurprisingly, printing warnings to stdout results in malformed JSON.
Signed-off-by: Kerin Millar <kfm@plushkava.net>
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1511
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,4 +1,5 @@ #define _GNU_SOURCE +#include <stdio.h> #include <string.h> #include <expression.h> @@ -42,7 +43,8 @@ static json_t *expr_print_json(const struct expr *expr, struct output_ctx *octx) if (ops->json) return ops->json(expr, octx); - printf("warning: expr ops %s have no json callback\n", expr_name(expr)); + fprintf(stderr, "warning: expr ops %s have no json callback\n", + expr_name(expr)); fp = octx->output_fp; octx->output_fp = fmemopen(buf, 1024, "w"); @@ -180,8 +182,8 @@ static json_t *stmt_print_json(const struct stmt *stmt, struct output_ctx *octx) if (stmt->ops->json) return stmt->ops->json(stmt, octx); - printf("warning: stmt ops %s have no json callback\n", - stmt->ops->name); + fprintf(stderr, "warning: stmt ops %s have no json callback\n", + stmt->ops->name); fp = octx->output_fp; octx->output_fp = fmemopen(buf, 1024, "w"); |