You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.9 KiB
53 lines
1.9 KiB
From 022cb8bb2028571b9119fd4ae95c87c96f816d6c Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Date: Tue, 18 Oct 2022 18:09:06 +0200
|
|
Subject: [PATCH] shared/json: allow json_variant_dump() to return an error
|
|
|
|
(cherry picked from commit 7922ead507e0d83e4ec72a8cbd2b67194766e58c)
|
|
|
|
Related: #2149074
|
|
---
|
|
src/shared/json.c | 7 ++++---
|
|
src/shared/json.h | 2 +-
|
|
2 files changed, 5 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/shared/json.c b/src/shared/json.c
|
|
index bcc109abc2..f91738227b 100644
|
|
--- a/src/shared/json.c
|
|
+++ b/src/shared/json.c
|
|
@@ -1768,9 +1768,9 @@ int json_variant_format(JsonVariant *v, JsonFormatFlags flags, char **ret) {
|
|
return (int) sz - 1;
|
|
}
|
|
|
|
-void json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const char *prefix) {
|
|
+int json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const char *prefix) {
|
|
if (!v)
|
|
- return;
|
|
+ return 0;
|
|
|
|
if (!f)
|
|
f = stdout;
|
|
@@ -1796,7 +1796,8 @@ void json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const cha
|
|
fputc('\n', f); /* In case of SSE add a second newline */
|
|
|
|
if (flags & JSON_FORMAT_FLUSH)
|
|
- fflush(f);
|
|
+ return fflush_and_check(f);
|
|
+ return 0;
|
|
}
|
|
|
|
int json_variant_filter(JsonVariant **v, char **to_remove) {
|
|
diff --git a/src/shared/json.h b/src/shared/json.h
|
|
index dd73c1e497..e4bfeae8f5 100644
|
|
--- a/src/shared/json.h
|
|
+++ b/src/shared/json.h
|
|
@@ -195,7 +195,7 @@ typedef enum JsonFormatFlags {
|
|
} JsonFormatFlags;
|
|
|
|
int json_variant_format(JsonVariant *v, JsonFormatFlags flags, char **ret);
|
|
-void json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const char *prefix);
|
|
+int json_variant_dump(JsonVariant *v, JsonFormatFlags flags, FILE *f, const char *prefix);
|
|
|
|
int json_variant_filter(JsonVariant **v, char **to_remove);
|
|
|