summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/journal-gatewayd.c2
-rw-r--r--src/journal-remote/journal-remote-main.c9
-rw-r--r--src/journal-remote/journal-remote-write.c20
-rw-r--r--src/journal-remote/journal-remote-write.h2
-rw-r--r--src/journal-remote/journal-remote.c9
-rw-r--r--src/journal-remote/journal-upload.c2
6 files changed, 24 insertions, 20 deletions
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index a792c75cca..b6e8469922 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -329,7 +329,7 @@ static int request_parse_range(
return r;
}
- p = (colon2 ? colon2 : colon) + 1;
+ p = (colon2 ?: colon) + 1;
if (*p) {
r = safe_atou64(p, &m->n_entries);
if (r < 0)
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 956c96c5e3..c5ecc2b844 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -42,7 +42,7 @@ static int http_socket = -1, https_socket = -1;
static char** arg_gnutls_log = NULL;
static JournalWriteSplitMode arg_split_mode = _JOURNAL_WRITE_SPLIT_INVALID;
-static const char* arg_output = NULL;
+static char *arg_output = NULL;
static char *arg_key = NULL;
static char *arg_cert = NULL;
@@ -62,6 +62,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_gnutls_log, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_key, freep);
STATIC_DESTRUCTOR_REGISTER(arg_cert, freep);
STATIC_DESTRUCTOR_REGISTER(arg_trust, freep);
+STATIC_DESTRUCTOR_REGISTER(arg_output, freep);
static const char* const journal_write_split_mode_table[_JOURNAL_WRITE_SPLIT_MAX] = {
[JOURNAL_WRITE_SPLIT_NONE] = "none",
@@ -734,7 +735,7 @@ static int create_remoteserver(
create output as expected. */
r = journal_remote_get_writer(s, NULL, &s->_single_writer);
if (r < 0)
- return r;
+ return log_warning_errno(r, "Failed to get writer: %m");
}
return 0;
@@ -957,7 +958,9 @@ static int parse_argv(int argc, char *argv[]) {
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"cannot use --output/-o more than once");
- arg_output = optarg;
+ r = parse_path_argument(optarg, /* suppress_root = */ false, &arg_output);
+ if (r < 0)
+ return r;
break;
case ARG_SPLIT_MODE:
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) {
diff --git a/src/journal-remote/journal-remote-write.h b/src/journal-remote/journal-remote-write.h
index c140f6cba3..55513d9bf7 100644
--- a/src/journal-remote/journal-remote-write.h
+++ b/src/journal-remote/journal-remote-write.h
@@ -20,7 +20,7 @@ typedef struct Writer {
unsigned n_ref;
} Writer;
-Writer* writer_new(RemoteServer* server);
+int writer_new(RemoteServer *server, Writer **ret);
Writer* writer_ref(Writer *w);
Writer* writer_unref(Writer *w);
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index a670468884..6e993863bf 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -122,14 +122,14 @@ int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer
if (w)
writer_ref(w);
else {
- w = writer_new(s);
- if (!w)
- return log_oom();
+ r = writer_new(s, &w);
+ if (r < 0)
+ return r;
if (s->split_mode == JOURNAL_WRITE_SPLIT_HOST) {
w->hashmap_key = strdup(key);
if (!w->hashmap_key)
- return log_oom();
+ return -ENOMEM;
}
r = open_output(s, w, host);
@@ -142,7 +142,6 @@ int journal_remote_get_writer(RemoteServer *s, const char *host, Writer **writer
}
*writer = TAKE_PTR(w);
-
return 0;
}
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index e42516c799..b9b310b664 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -801,7 +801,7 @@ static int open_journal(sd_journal **j) {
r = sd_journal_open(j, (arg_merge ? 0 : SD_JOURNAL_LOCAL_ONLY) | arg_journal_type);
if (r < 0)
log_error_errno(r, "Failed to open %s: %m",
- arg_directory ? arg_directory : arg_file ? "files" : "journal");
+ arg_directory ?: (arg_file ? "files" : "journal"));
return r;
}