tree-wide: use memstream-util

This commit is contained in:
Yu Watanabe
2023-06-01 06:48:47 +09:00
parent abe72100cf
commit 2485b7e2b8
29 changed files with 302 additions and 479 deletions
+5 -4
View File
@@ -5,12 +5,13 @@
#include "fd-util.h"
#include "fuzz.h"
#include "json.h"
#include "memstream-util.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_free_ char *out = NULL; /* out should be freed after g */
size_t out_size;
_cleanup_fclose_ FILE *f = NULL, *g = NULL;
_cleanup_(memstream_done) MemStream m = {};
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_fclose_ FILE *f = NULL;
FILE *g = NULL;
int r;
/* Disable most logging if not running standalone */
@@ -27,7 +28,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
if (getenv_bool("SYSTEMD_FUZZ_OUTPUT") <= 0)
assert_se(g = open_memstream_unlocked(&out, &out_size));
assert_se(g = memstream_init(&m));
json_variant_dump(v, 0, g ?: stdout, NULL);
json_variant_dump(v, JSON_FORMAT_PRETTY|JSON_FORMAT_COLOR|JSON_FORMAT_SOURCE, g ?: stdout, NULL);