From 69821560449cec9134d1506a2524f50cceea1b52 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 18 May 2018 20:14:54 +0200 Subject: [PATCH] fs-util: don't alter errno in unlink_tempfilep() Functions whose only purpose is to be used with _cleanup_() should not touch errno, so that failing removals do not alter errno at unexpected places. This is already done in unlink_and_freep(), rmdir_and_freep(), rm_rf_physical_and_freep(), hence do so for unlink_tempfilep(), too. Follow-up for #9013 --- src/basic/fs-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index fc220b4808..a0d7a43d27 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -1072,7 +1072,7 @@ void unlink_tempfilep(char (*p)[]) { * successfully created. We ignore both the rare case where the * original suffix is used and unlink failures. */ if (!endswith(*p, ".XXXXXX")) - (void) unlink(*p); + (void) unlink_noerrno(*p); } int unlinkat_deallocate(int fd, const char *name, int flags) {