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) <noreply@openai.com>
This commit is contained in:
noxiouz
2026-04-07 14:52:38 +01:00
committed by Luca Boccassi
parent 388428f9d8
commit 874fbb870c

View File

@@ -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;
}
}