From 1daf7b56bb9b01f03bb19a12e9aec5934116a72d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 11 Nov 2025 11:35:45 +0100 Subject: [PATCH] tmpfile-util: make sure errno is left untouched by CLEANUP_TMPFILE_AT() This mimics how rm_rf_physical_and_free() operate, and we should do the same here, and make clean-up error paths not touch errno needlessly. --- src/basic/tmpfile-util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/basic/tmpfile-util.c b/src/basic/tmpfile-util.c index c145e02221f..7eabc9c9007 100644 --- a/src/basic/tmpfile-util.c +++ b/src/basic/tmpfile-util.c @@ -447,7 +447,9 @@ void cleanup_tmpfile_data_done(struct cleanup_tmpfile_data *d) { !*d->filename) return; - (void) unlinkat(*d->dir_fd, *d->filename, 0); + PROTECT_ERRNO; + + (void) unlinkat(*d->dir_fd, *d->filename, /* flags= */ 0); d->dir_fd = NULL; d->filename = NULL; } -- 2.47.3