summaryrefslogtreecommitdiffstats
path: root/src/journal-remote/journal-remote-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal-remote/journal-remote-write.c')
-rw-r--r--src/journal-remote/journal-remote-write.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c
index ace4a1cfad..54ed1e23a0 100644
--- a/src/journal-remote/journal-remote-write.c
+++ b/src/journal-remote/journal-remote-write.c
@@ -21,19 +21,22 @@ static int do_rotate(ManagedJournalFile **f, MMapCache *m, JournalFileFlags file
return r;
}
-Writer* writer_new(RemoteServer *server) {
+int writer_new(RemoteServer *server, Writer **ret) {
_cleanup_(writer_unrefp) Writer *w = NULL;
int r;
+ assert(server);
+ assert(ret);
+
w = new0(Writer, 1);
if (!w)
- return NULL;
+ return -ENOMEM;
w->metrics = server->metrics;
w->mmap = mmap_cache_new();
if (!w->mmap)
- return NULL;
+ return -ENOMEM;
w->n_ref = 1;
w->server = server;
@@ -41,16 +44,15 @@ Writer* writer_new(RemoteServer *server) {
if (is_dir(server->output, /* follow = */ true) > 0) {
w->output = strdup(server->output);
if (!w->output)
- return NULL;
+ return -ENOMEM;
} else {
r = path_extract_directory(server->output, &w->output);
- if (r < 0) {
- log_error_errno(r, "Failed to find directory of file \"%s\": %m", server->output);
- return NULL;
- }
+ if (r < 0)
+ return r;
}
- return TAKE_PTR(w);
+ *ret = TAKE_PTR(w);
+ return 0;
}
static Writer* writer_free(Writer *w) {