summaryrefslogtreecommitdiff
path: root/src/journal
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 19:57:32 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 19:57:32 +0100
commit4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4f (patch)
treec7a6228e7151aa74bc8e331694a1e795226550cd /src/journal
parent56f64d95763a799ba4475daf44d8e9f72a1bd474 (diff)
treewide: another round of simplifications
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno + return simplifications".
Diffstat (limited to 'src/journal')
-rw-r--r--src/journal/catalog.c6
-rw-r--r--src/journal/coredump-vacuum.c6
-rw-r--r--src/journal/coredump.c42
-rw-r--r--src/journal/coredumpctl.c12
-rw-r--r--src/journal/journalctl.c30
-rw-r--r--src/journal/journald-audit.c12
-rw-r--r--src/journal/journald-native.c24
-rw-r--r--src/journal/journald-server.c6
-rw-r--r--src/journal/journald-stream.c18
-rw-r--r--src/journal/journald-syslog.c24
10 files changed, 60 insertions, 120 deletions
diff --git a/src/journal/catalog.c b/src/journal/catalog.c
index 41cdb0dade..81a2e946e4 100644
--- a/src/journal/catalog.c
+++ b/src/journal/catalog.c
@@ -209,10 +209,8 @@ int catalog_import_file(Hashmap *h, struct strbuf *sb, const char *path) {
assert(path);
f = fopen(path, "re");
- if (!f) {
- log_error_errno(errno, "Failed to open file %s: %m", path);
- return -errno;
- }
+ if (!f)
+ return log_error_errno(errno, "Failed to open file %s: %m", path);
r = catalog_file_lang(path, &deflang);
if (r < 0)
diff --git a/src/journal/coredump-vacuum.c b/src/journal/coredump-vacuum.c
index 5f2ff2a025..9b73795e5b 100644
--- a/src/journal/coredump-vacuum.c
+++ b/src/journal/coredump-vacuum.c
@@ -139,10 +139,8 @@ int coredump_vacuum(int exclude_fd, off_t keep_free, off_t max_use) {
return 0;
if (exclude_fd >= 0) {
- if (fstat(exclude_fd, &exclude_st) < 0) {
- log_error_errno(errno, "Failed to fstat(): %m");
- return -errno;
- }
+ if (fstat(exclude_fd, &exclude_st) < 0)
+ return log_error_errno(errno, "Failed to fstat(): %m");
}
/* This algorithm will keep deleting the oldest file of the
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index a871c570ca..26953cc5b0 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -142,10 +142,8 @@ static int fix_acl(int fd, uid_t uid) {
* their own coredumps */
acl = acl_get_fd(fd);
- if (!acl) {
- log_error_errno(errno, "Failed to get ACL: %m");
- return -errno;
- }
+ if (!acl)
+ return log_error_errno(errno, "Failed to get ACL: %m");
if (acl_create_entry(&acl, &entry) < 0 ||
acl_set_tag_type(entry, ACL_USER) < 0 ||
@@ -161,10 +159,8 @@ static int fix_acl(int fd, uid_t uid) {
return -errno;
}
- if (acl_set_fd(fd, acl) < 0) {
- log_error_errno(errno, "Failed to apply ACL: %m");
- return -errno;
- }
+ if (acl_set_fd(fd, acl) < 0)
+ return log_error_errno(errno, "Failed to apply ACL: %m");
#endif
return 0;
@@ -223,15 +219,11 @@ static int fix_permissions(
fix_acl(fd, uid);
fix_xattr(fd, info);
- if (fsync(fd) < 0) {
- log_error_errno(errno, "Failed to sync coredump %s: %m", filename);
- return -errno;
- }
+ if (fsync(fd) < 0)
+ return log_error_errno(errno, "Failed to sync coredump %s: %m", filename);
- if (rename(filename, target) < 0) {
- log_error_errno(errno, "Failed to rename coredump %s -> %s: %m", filename, target);
- return -errno;
- }
+ if (rename(filename, target) < 0)
+ return log_error_errno(errno, "Failed to rename coredump %s -> %s: %m", filename, target);
return 0;
}
@@ -247,10 +239,8 @@ static int maybe_remove_external_coredump(const char *filename, off_t size) {
if (!filename)
return 1;
- if (unlink(filename) < 0 && errno != ENOENT) {
- log_error_errno(errno, "Failed to unlink %s: %m", filename);
- return -errno;
- }
+ if (unlink(filename) < 0 && errno != ENOENT)
+ return log_error_errno(errno, "Failed to unlink %s: %m", filename);
return 1;
}
@@ -322,10 +312,8 @@ static int save_external_coredump(
mkdir_p_label("/var/lib/systemd/coredump", 0755);
fd = open(tmp, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0640);
- if (fd < 0) {
- log_error_errno(errno, "Failed to create coredump file %s: %m", tmp);
- return -errno;
- }
+ if (fd < 0)
+ return log_error_errno(errno, "Failed to create coredump file %s: %m", tmp);
r = copy_bytes(STDIN_FILENO, fd, arg_process_size_max);
if (r == -EFBIG) {
@@ -429,10 +417,8 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
assert(ret);
assert(ret_size);
- if (lseek(fd, 0, SEEK_SET) == (off_t) -1) {
- log_warning_errno(errno, "Failed to seek: %m");
- return -errno;
- }
+ if (lseek(fd, 0, SEEK_SET) == (off_t) -1)
+ return log_warning_errno(errno, "Failed to seek: %m");
field = malloc(9 + size);
if (!field) {
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 2163ef9989..a6551ac44b 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -190,10 +190,8 @@ static int parse_argv(int argc, char *argv[], Set *matches) {
}
output = fopen(optarg, "we");
- if (!output) {
- log_error_errno(errno, "writing to '%s': %m", optarg);
- return -errno;
- }
+ if (!output)
+ return log_error_errno(errno, "writing to '%s': %m", optarg);
break;
@@ -609,10 +607,8 @@ static int save_core(sd_journal *j, int fd, char **path, bool *unlink_temp) {
return log_oom();
fdt = mkostemp_safe(temp, O_WRONLY|O_CLOEXEC);
- if (fdt < 0) {
- log_error_errno(errno, "Failed to create temporary file: %m");
- return -errno;
- }
+ if (fdt < 0)
+ return log_error_errno(errno, "Failed to create temporary file: %m");
log_debug("Created temporary file %s", temp);
fd = fdt;
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 317b662ca6..5c2a56d575 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -794,10 +794,8 @@ static int add_matches(sd_journal *j, char **args) {
p = canonicalize_file_name(*i);
path = p ? p : *i;
- if (stat(path, &st) < 0) {
- log_error_errno(errno, "Couldn't stat file: %m");
- return -errno;
- }
+ if (stat(path, &st) < 0)
+ return log_error_errno(errno, "Couldn't stat file: %m");
if (S_ISREG(st.st_mode) && (0111 & st.st_mode)) {
if (executable_is_script(path, &interpreter) > 0) {
@@ -1303,10 +1301,8 @@ static int setup_keys(void) {
struct stat st;
r = stat("/var/log/journal", &st);
- if (r < 0 && errno != ENOENT && errno != ENOTDIR) {
- log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal");
- return -errno;
- }
+ if (r < 0 && errno != ENOENT && errno != ENOTDIR)
+ return log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal");
if (r < 0 || !S_ISDIR(st.st_mode)) {
log_error("%s is not a directory, must be using persistent logging for FSS.",
@@ -1685,25 +1681,19 @@ static int flush_to_var(void) {
mkdir_p("/run/systemd/journal", 0755);
watch_fd = inotify_init1(IN_NONBLOCK|IN_CLOEXEC);
- if (watch_fd < 0) {
- log_error_errno(errno, "Failed to create inotify watch: %m");
- return -errno;
- }
+ if (watch_fd < 0)
+ return log_error_errno(errno, "Failed to create inotify watch: %m");
r = inotify_add_watch(watch_fd, "/run/systemd/journal", IN_CREATE|IN_DONT_FOLLOW|IN_ONLYDIR);
- if (r < 0) {
- log_error_errno(errno, "Failed to watch journal directory: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to watch journal directory: %m");
for (;;) {
if (access("/run/systemd/journal/flushed", F_OK) >= 0)
break;
- if (errno != ENOENT) {
- log_error_errno(errno, "Failed to check for existance of /run/systemd/journal/flushed: %m");
- return -errno;
- }
+ if (errno != ENOENT)
+ return log_error_errno(errno, "Failed to check for existance of /run/systemd/journal/flushed: %m");
r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY);
if (r < 0)
diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c
index ef4ad28833..69742fa59c 100644
--- a/src/journal/journald-audit.c
+++ b/src/journal/journald-audit.c
@@ -529,18 +529,14 @@ int server_open_audit(Server *s) {
}
r = bind(s->audit_fd, &sa.sa, sizeof(sa.nl));
- if (r < 0) {
- log_error_errno(errno, "Failed to join audit multicast group: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to join audit multicast group: %m");
} else
fd_nonblock(s->audit_fd, 1);
r = setsockopt(s->audit_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "Failed to set SO_PASSCRED on audit socket: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "Failed to set SO_PASSCRED on audit socket: %m");
r = sd_event_add_io(s->event, &s->audit_event_source, s->audit_fd, EPOLLIN, process_datagram, s);
if (r < 0)
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index a19f85d182..f982696255 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -424,28 +424,22 @@ int server_open_native_socket(Server*s) {
};
s->native_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (s->native_fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (s->native_fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
unlink(sa.un.sun_path);
r = bind(s->native_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
chmod(sa.un.sun_path, 0666);
} else
fd_nonblock(s->native_fd, 1);
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_PASSCRED failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_PASSCRED failed: %m");
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
@@ -456,10 +450,8 @@ int server_open_native_socket(Server*s) {
#endif
r = setsockopt(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_TIMESTAMP failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, process_datagram, s);
if (r < 0)
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 081ae7c08d..9ec425d2d4 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1431,10 +1431,8 @@ static int server_open_hostname(Server *s) {
assert(s);
s->hostname_fd = open("/proc/sys/kernel/hostname", O_RDONLY|O_CLOEXEC|O_NDELAY|O_NOCTTY);
- if (s->hostname_fd < 0) {
- log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
- return -errno;
- }
+ if (s->hostname_fd < 0)
+ return log_error_errno(errno, "Failed to open /proc/sys/kernel/hostname: %m");
r = sd_event_add_io(s->event, &s->hostname_event_source, s->hostname_fd, 0, dispatch_hostname_change, s);
if (r < 0) {
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 751b2f49b5..be498d4919 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -441,25 +441,19 @@ int server_open_stdout_socket(Server *s) {
};
s->stdout_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (s->stdout_fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (s->stdout_fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
unlink(sa.un.sun_path);
r = bind(s->stdout_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
chmod(sa.un.sun_path, 0666);
- if (listen(s->stdout_fd, SOMAXCONN) < 0) {
- log_error_errno(errno, "listen(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (listen(s->stdout_fd, SOMAXCONN) < 0)
+ return log_error_errno(errno, "listen(%s) failed: %m", sa.un.sun_path);
} else
fd_nonblock(s->stdout_fd, 1);
diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c
index 51ebd8192d..cc44d45949 100644
--- a/src/journal/journald-syslog.c
+++ b/src/journal/journald-syslog.c
@@ -428,28 +428,22 @@ int server_open_syslog_socket(Server *s) {
};
s->syslog_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
- if (s->syslog_fd < 0) {
- log_error_errno(errno, "socket() failed: %m");
- return -errno;
- }
+ if (s->syslog_fd < 0)
+ return log_error_errno(errno, "socket() failed: %m");
unlink(sa.un.sun_path);
r = bind(s->syslog_fd, &sa.sa, offsetof(union sockaddr_union, un.sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
chmod(sa.un.sun_path, 0666);
} else
fd_nonblock(s->syslog_fd, 1);
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_PASSCRED failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_PASSCRED failed: %m");
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
@@ -460,10 +454,8 @@ int server_open_syslog_socket(Server *s) {
#endif
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
- if (r < 0) {
- log_error_errno(errno, "SO_TIMESTAMP failed: %m");
- return -errno;
- }
+ if (r < 0)
+ return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
r = sd_event_add_io(s->event, &s->syslog_event_source, s->syslog_fd, EPOLLIN, process_datagram, s);
if (r < 0)