From: Kerin Millar Date: Tue, 9 Mar 2021 15:28:45 +0000 (+0000) Subject: json: Print warnings to stderr rather than stdout X-Git-Tag: v1.0.0~84 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=001bd5b1b744428c77c68dd371fed58c3dc511f2;p=thirdparty%2Fnftables.git json: Print warnings to stderr rather than stdout Unsurprisingly, printing warnings to stdout results in malformed JSON. Signed-off-by: Kerin Millar Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1511 Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/json.c b/src/json.c index b08c004a..f648ea1b 100644 --- a/src/json.c +++ b/src/json.c @@ -1,4 +1,5 @@ #define _GNU_SOURCE +#include #include #include @@ -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");