From: Joel Rosdahl Date: Mon, 12 Feb 2024 20:35:15 +0000 (+0100) Subject: chore: Tweak formatting and comments X-Git-Tag: v4.10~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be79f630ee6d3b835ce678edd3d2efcfcea7deda;p=thirdparty%2Fccache.git chore: Tweak formatting and comments --- diff --git a/doc/MANUAL.adoc b/doc/MANUAL.adoc index 787f1be4..3372187f 100644 --- a/doc/MANUAL.adoc +++ b/doc/MANUAL.adoc @@ -832,7 +832,8 @@ might be incorrect. requires <> to be located on a local filesystem of a supported type. + -NOTE: Support for the inode cache feature on Windows is experimental. On Windows the default is false. +NOTE: Support for the inode cache feature on Windows is experimental. On Windows +the default is false. [#config_keep_comments_cpp] *keep_comments_cpp* (*CCACHE_COMMENTS* or *CCACHE_NOCOMMENTS*, see _<>_ above):: diff --git a/src/Config.hpp b/src/Config.hpp index cabf5920..17015526 100644 --- a/src/Config.hpp +++ b/src/Config.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2023 Joel Rosdahl and other contributors +// Copyright (C) 2019-2024 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -192,7 +192,7 @@ private: #ifndef _WIN32 bool m_inode_cache = true; #else - // Support is experimental on Windows so usage is off by default + // Support is experimental on Windows so usage is off by default. bool m_inode_cache = false; #endif bool m_keep_comments_cpp = false; diff --git a/src/InodeCache.cpp b/src/InodeCache.cpp index 0cc4e59d..1f86f522 100644 --- a/src/InodeCache.cpp +++ b/src/InodeCache.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2023 Joel Rosdahl and other contributors +// Copyright (C) 2020-2024 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -52,6 +52,8 @@ #include #include +using pstr = util::PathString; + // The inode cache resides on a file that is mapped into shared memory by // running processes. It is implemented as a two level structure, where the top // level is a hash table consisting of buckets. Each bucket contains entries @@ -159,10 +161,9 @@ fd_is_on_known_to_work_file_system(int fd) return false; } - // Try to get information about remote protocol for this file. - // If the call succeeds, this is a remote file. - // If the call fails with invalid parameter error, consider that it is a local - // file + // Try to get information about remote protocol for this file. If the call + // succeeds, this is a remote file. If the call fails with invalid parameter + // error, consider whether it is a local file. FILE_REMOTE_PROTOCOL_INFO infos; if (GetFileInformationByHandleEx( file, FileRemoteProtocolInfo, &infos, sizeof(infos))) { @@ -320,7 +321,7 @@ InodeCache::hash_inode(const std::string& path, key.st_ino = de.inode(); key.st_mode = de.mode(); // Note: Manually copying sec and nsec of mtime and ctime to prevent copying - // the padding bytes + // the padding bytes. auto mtime = de.mtime().to_timespec(); key.st_mtim.tv_sec = mtime.tv_sec; key.st_mtim.tv_nsec = mtime.tv_nsec; @@ -377,8 +378,7 @@ InodeCache::create_new_file(const std::string& filename) return false; } - util::Finalizer temp_file_remover( - [&] { unlink(util::PathString(tmp_file->path).c_str()); }); + util::Finalizer temp_file_remover([&] { unlink(pstr(tmp_file->path)); }); if (!fd_is_on_known_to_work_file_system(*tmp_file->fd)) { return false; @@ -425,7 +425,7 @@ InodeCache::create_new_file(const std::string& filename) unsigned error = GetLastError(); if (error == ERROR_FILE_EXISTS) { // Not an error, another process won the race. Remove the file we just - // created + // created. DeleteFileA(util::PathString(tmp_file->path).c_str()); LOG("Another process created inode cache {}", filename); return true; diff --git a/src/util/MemoryMap.hpp b/src/util/MemoryMap.hpp index 2fba3f9d..91025b14 100644 --- a/src/util/MemoryMap.hpp +++ b/src/util/MemoryMap.hpp @@ -31,6 +31,7 @@ class MemoryMap : util::NonCopyable public: MemoryMap() = default; ~MemoryMap(); + MemoryMap(MemoryMap&& other) noexcept; MemoryMap& operator=(MemoryMap&& other) noexcept; @@ -49,4 +50,5 @@ private: nullptr; // On Windows a handle on a file mapping is needed #endif }; + } // namespace util