]> 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 19:54:06 +0000 (20:54 +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.

src/util.c

index 325a839504fcf0abefb6620839ea765cca3a7bfc..b6cce75efd643ec1754aae00d41f4491d35dcd24 100644 (file)
@@ -1573,7 +1573,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) {