]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Improve name of tmp file in x_unlink
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 22 Mar 2020 13:41:44 +0000 (14:41 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 22 Mar 2020 21:18:09 +0000 (22:18 +0100)
There is no need to generate a unique temporary name in x_unlink since
we don’t care whether the temporary file is clobbered on NFS. The
previous usage of tmp_string() was not quite correct since the returned
string is supposed to be passed to mkstemp, not used as is.

(cherry picked from commit e7776305184c9338ee97334078153f298f6cfea7)

src/legacy_util.cpp

index 656d91f8ea225f742477c8679ab8377e2344bb33..fc9134c206f82d13d43c0cf5f585918302d0f086 100644 (file)
@@ -829,7 +829,7 @@ do_x_unlink(const char* path, bool log_failure)
   // If path is on an NFS share, unlink isn't atomic, so we rename to a temp
   // file. We don't care if the temp file is trashed, so it's always safe to
   // unlink it first.
-  char* tmp_name = format("%s.rm.%s", path, tmp_string());
+  char* tmp_name = format("%s.ccache.rm.tmp", path);
 
   int result = 0;
   if (x_rename(path, tmp_name) == -1) {