]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: don't alter errno in unlink_tempfilep()
authorLennart Poettering <lennart@poettering.net>
Fri, 18 May 2018 18:14:54 +0000 (20:14 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 19 May 2018 13:50:02 +0000 (15:50 +0200)
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

index fc220b480886b9c31dc3e0c0b2265a5e6a7ad4dc..a0d7a43d274c35b570f038acb020943788db8fc2 100644 (file)
@@ -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) {