diff options
Diffstat (limited to 'src/journal/journald-kmsg.c')
-rw-r--r-- | src/journal/journald-kmsg.c | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 05b128f843..35948ea754 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -428,19 +428,14 @@ int server_open_dev_kmsg(Server *s) { return 0; fail: - if (s->dev_kmsg_event_source) - s->dev_kmsg_event_source = sd_event_source_unref(s->dev_kmsg_event_source); - - if (s->dev_kmsg_fd >= 0) { - close_nointr_nofail(s->dev_kmsg_fd); - s->dev_kmsg_fd = -1; - } + s->dev_kmsg_event_source = sd_event_source_unref(s->dev_kmsg_event_source); + s->dev_kmsg_fd = safe_close(s->dev_kmsg_fd); return r; } int server_open_kernel_seqnum(Server *s) { - int fd; + _cleanup_close_ int fd; uint64_t *p; assert(s); @@ -457,18 +452,15 @@ int server_open_kernel_seqnum(Server *s) { if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) { log_error("Failed to allocate sequential number file, ignoring: %m"); - close_nointr_nofail(fd); return 0; } p = mmap(NULL, sizeof(uint64_t), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); if (p == MAP_FAILED) { log_error("Failed to map sequential number file, ignoring: %m"); - close_nointr_nofail(fd); return 0; } - close_nointr_nofail(fd); s->kernel_seqnum = p; return 0; |