From: noxiouz Date: Tue, 7 Apr 2026 13:52:38 +0000 (+0100) Subject: coredumpctl: use loop_write() for dumping inline journal coredumps X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=874fbb870cdcf40e502165bc0f688cf2ec3d70b1;p=thirdparty%2Fsystemd.git coredumpctl: use loop_write() for dumping inline journal coredumps Replace the bare write() call with loop_write(), which handles short writes and EINTR retries. This also drops the now-unnecessary ssize_t variable and the redundant r = log_error_errno(r, ...) self-assignment, since loop_write() already stores its result in r. Co-developed-by: Codex (GPT-5) --- diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 96724de12b6..b7c687d996c 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -30,6 +30,7 @@ #include "fs-util.h" #include "glob-util.h" #include "image-policy.h" +#include "io-util.h" #include "journal-internal.h" #include "journal-util.h" #include "json-util.h" @@ -1109,8 +1110,6 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp) goto error; #endif } else { - ssize_t sz; - /* We want full data, nothing truncated. */ sd_journal_set_data_threshold(j, 0); @@ -1122,14 +1121,9 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp) data += 9; len -= 9; - sz = write(fd, data, len); - if (sz < 0) { - r = log_error_errno(errno, "Failed to write output: %m"); - goto error; - } - if (sz != (ssize_t) len) { - log_error("Short write to output."); - r = -EIO; + r = loop_write(fd, data, len); + if (r < 0) { + log_error_errno(r, "Failed to write output: %m"); goto error; } }