From: Joel Rosdahl Date: Sun, 22 Mar 2020 13:41:44 +0000 (+0100) Subject: Improve name of tmp file in x_unlink X-Git-Tag: v4.0~562 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76f63d8a148bf1219b21cbb49d3963f6a776380e;p=thirdparty%2Fccache.git Improve name of tmp file in x_unlink 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) --- diff --git a/src/legacy_util.cpp b/src/legacy_util.cpp index 656d91f8e..fc9134c20 100644 --- a/src/legacy_util.cpp +++ b/src/legacy_util.cpp @@ -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) {