summaryrefslogtreecommitdiff
path: root/src/journal-remote
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 17:34:26 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 17:34:26 +0100
commiteb56eb9b40950f1edcffdb7313f8de4f8572a6d5 (patch)
tree6e6c04129d1bb12b5ff3fcfbc26a294766079e0e /src/journal-remote
parentc33b329709ebe2755181980a050d02ec7c81ed87 (diff)
treewide: simplify log_*_errno(r,...) immediately followed by "return r"
Diffstat (limited to 'src/journal-remote')
-rw-r--r--src/journal-remote/journal-remote.c47
-rw-r--r--src/journal-remote/journal-upload-journal.c55
-rw-r--r--src/journal-remote/journal-upload.c49
3 files changed, 56 insertions, 95 deletions
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index d1df83fba0..21309743fe 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -320,11 +320,9 @@ static int get_source_for_fd(RemoteServer *s,
return log_oom();
r = get_writer(s, name, &writer);
- if (r < 0) {
- log_warning_errno(r, "Failed to get writer for source %s: %m",
- name);
- return r;
- }
+ if (r < 0)
+ return log_warning_errno(r, "Failed to get writer for source %s: %m",
+ name);
if (s->sources[fd] == NULL) {
s->sources[fd] = source_new(fd, false, name, writer);
@@ -459,11 +457,9 @@ static int request_meta(void **connection_cls, int fd, char *hostname) {
return 0;
r = get_writer(server, hostname, &writer);
- if (r < 0) {
- log_warning_errno(r, "Failed to get writer for source %s: %m",
- hostname);
- return r;
- }
+ if (r < 0)
+ return log_warning_errno(r, "Failed to get writer for source %s: %m",
+ hostname);
source = source_new(fd, true, hostname, writer);
if (!source) {
@@ -855,10 +851,9 @@ static int remoteserver_init(RemoteServer *s,
return r;
n = sd_listen_fds(true);
- if (n < 0) {
- log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
- return n;
- } else
+ if (n < 0)
+ return log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
+ else
log_info("Received %d descriptors", n);
if (MAX(http_socket, https_socket) >= SD_LISTEN_FDS_START + n) {
@@ -1460,28 +1455,22 @@ static int load_certificates(char **key, char **cert, char **trust) {
int r;
r = read_full_file(arg_key ?: PRIV_KEY_FILE, key, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to read key from file '%s': %m",
- arg_key ?: PRIV_KEY_FILE);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to read key from file '%s': %m",
+ arg_key ?: PRIV_KEY_FILE);
r = read_full_file(arg_cert ?: CERT_FILE, cert, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to read certificate from file '%s': %m",
- arg_cert ?: CERT_FILE);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to read certificate from file '%s': %m",
+ arg_cert ?: CERT_FILE);
if (arg_trust_all)
log_info("Certificate checking disabled.");
else {
r = read_full_file(arg_trust ?: TRUST_FILE, trust, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to read CA certificate file '%s': %m",
- arg_trust ?: TRUST_FILE);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to read CA certificate file '%s': %m",
+ arg_trust ?: TRUST_FILE);
}
return 0;
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index 6e5e45f7c9..942320cbf6 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -25,10 +25,8 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
u->current_cursor = NULL;
r = sd_journal_get_cursor(u->journal, &u->current_cursor);
- if (r < 0) {
- log_error_errno(r, "Failed to get cursor: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get cursor: %m");
r = snprintf(buf + pos, size - pos,
"__CURSOR=%s\n", u->current_cursor);
@@ -51,10 +49,8 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
usec_t realtime;
r = sd_journal_get_realtime_usec(u->journal, &realtime);
- if (r < 0) {
- log_error_errno(r, "Failed to get realtime timestamp: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get realtime timestamp: %m");
r = snprintf(buf + pos, size - pos,
"__REALTIME_TIMESTAMP="USEC_FMT"\n", realtime);
@@ -78,10 +74,8 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
sd_id128_t boot_id;
r = sd_journal_get_monotonic_usec(u->journal, &monotonic, &boot_id);
- if (r < 0) {
- log_error_errno(r, "Failed to get monotonic timestamp: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get monotonic timestamp: %m");
r = snprintf(buf + pos, size - pos,
"__MONOTONIC_TIMESTAMP="USEC_FMT"\n", monotonic);
@@ -105,10 +99,8 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
char sid[33];
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
- if (r < 0) {
- log_error_errno(r, "Failed to get monotonic timestamp: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get monotonic timestamp: %m");
r = snprintf(buf + pos, size - pos,
"_BOOT_ID=%s\n", sd_id128_to_string(boot_id, sid));
@@ -133,10 +125,9 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
r = sd_journal_enumerate_data(u->journal,
&u->field_data,
&u->field_length);
- if (r < 0) {
- log_error_errno(r, "Failed to move to next field in entry: %m");
- return r;
- } else if (r == 0) {
+ if (r < 0)
+ return log_error_errno(r, "Failed to move to next field in entry: %m");
+ else if (r == 0) {
u->entry_state = ENTRY_OUTRO;
continue;
}
@@ -302,10 +293,9 @@ static int process_journal_input(Uploader *u, int skip) {
int r;
r = sd_journal_next_skip(u->journal, skip);
- if (r < 0) {
- log_error_errno(r, "Failed to skip to next entry: %m");
- return r;
- } else if (r < skip)
+ if (r < 0)
+ return log_error_errno(r, "Failed to skip to next entry: %m");
+ else if (r < skip)
return 0;
/* have data */
@@ -361,10 +351,8 @@ int open_journal_for_upload(Uploader *u,
if (follow) {
fd = sd_journal_get_fd(j);
- if (fd < 0) {
- log_error_errno(fd, "sd_journal_get_fd failed: %m");
- return fd;
- }
+ if (fd < 0)
+ return log_error_errno(fd, "sd_journal_get_fd failed: %m");
events = sd_journal_get_events(j);
@@ -377,10 +365,8 @@ int open_journal_for_upload(Uploader *u,
r = sd_event_add_io(u->events, &u->input_event,
fd, events, dispatch_journal_input, u);
- if (r < 0) {
- log_error_errno(r, "Failed to register input event: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to register input event: %m");
log_debug("Listening for journal events on fd:%d, timeout %d",
fd, u->timeout == (uint64_t) -1 ? -1 : (int) u->timeout);
@@ -390,9 +376,8 @@ int open_journal_for_upload(Uploader *u,
if (cursor) {
r = sd_journal_seek_cursor(j, cursor);
if (r < 0) {
- log_error_errno(r, "Failed to seek to cursor %s: %m",
- cursor);
- return r;
+ return log_error_errno(r, "Failed to seek to cursor %s: %m",
+ cursor);
}
}
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index e677e13348..8da65132ca 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -103,18 +103,14 @@ static int check_cursor_updating(Uploader *u) {
return 0;
r = mkdir_parents(u->state_file, 0755);
- if (r < 0) {
- log_error_errno(r, "Cannot create parent directory of state file %s: %m",
- u->state_file);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot create parent directory of state file %s: %m",
+ u->state_file);
r = fopen_temporary(u->state_file, &f, &temp_path);
- if (r < 0) {
- log_error_errno(r, "Cannot save state to %s: %m",
- u->state_file);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot save state to %s: %m",
+ u->state_file);
unlink(temp_path);
return 0;
@@ -164,11 +160,10 @@ static int load_cursor_state(Uploader *u) {
if (r == -ENOENT)
log_debug("State file %s is not present.", u->state_file);
- else if (r < 0) {
- log_error_errno(r, "Failed to read state file %s: %m",
- u->state_file);
- return r;
- } else
+ else if (r < 0)
+ return log_error_errno(r, "Failed to read state file %s: %m",
+ u->state_file);
+ else
log_debug("Last cursor was %s", u->last_cursor);
return 0;
@@ -374,10 +369,8 @@ static int open_file_for_upload(Uploader *u, const char *filename) {
r = sd_event_add_io(u->events, &u->input_event,
fd, EPOLLIN, dispatch_fd_input, u);
if (r < 0) {
- if (r != -EPERM || arg_follow > 0) {
- log_error_errno(r, "Failed to register input event: %m");
- return r;
- }
+ if (r != -EPERM || arg_follow > 0)
+ return log_error_errno(r, "Failed to register input event: %m");
/* Normal files should just be consumed without polling. */
r = start_upload(u, fd_input_callback, u);
@@ -458,16 +451,12 @@ static int setup_uploader(Uploader *u, const char *url, const char *state_file)
u->state_file = state_file;
r = sd_event_default(&u->events);
- if (r < 0) {
- log_error_errno(r, "sd_event_default failed: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "sd_event_default failed: %m");
r = setup_signals(u);
- if (r < 0) {
- log_error_errno(r, "Failed to set up signals: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to set up signals: %m");
return load_cursor_state(u);
}
@@ -701,10 +690,8 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_FILE:
r = glob_extend(&arg_file, optarg);
- if (r < 0) {
- log_error_errno(r, "Failed to add paths: %m");
- return r;
- };
+ if (r < 0)
+ return log_error_errno(r, "Failed to add paths: %m");
break;
case ARG_CURSOR: