]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Fix DEFER usage
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 11 Mar 2026 19:15:56 +0000 (20:15 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 11 Mar 2026 19:28:56 +0000 (20:28 +0100)
src/ccache/execute.cpp
src/ccache/util/defer.hpp
test/storage/helper/main.cpp

index cd88d74124da703ecde63de4b547227c248a1cc6..c75cbc61e8232b6d3db3ae3087482f016f48a719 100644 (file)
@@ -207,11 +207,8 @@ win32execute(const char* const* argv,
   std::string commandline = util::format_argv_as_win32_command_string(argv);
 
   fs::path tmp_file_path;
-  DEFER([&] {
-    if (!tmp_file_path.empty()) {
-      std::ignore = util::remove(tmp_file_path);
-    }
-  });
+  DEFER(
+    if (!tmp_file_path.empty()) { std::ignore = util::remove(tmp_file_path); });
 
   if (commandline.length() > 8192) {
     auto tmp_file = util::value_or_throw<core::Fatal>(
index 8b1d122bb55d7cecbd675e271bce626b891f8334..ca6f2b2bb986a26a409891ffdb5330acad21e311 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020-2025 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2026 Joel Rosdahl and other contributors
 //
 // See doc/authors.adoc for a complete list of contributors.
 //
@@ -23,7 +23,7 @@
 #include <functional>
 
 #define DEFER(...)                                                             \
-  util::Deferrer UNIQUE_VARNAME(_deferrer_)([&] { (void)__VA_ARGS__; })
+  util::Deferrer UNIQUE_VARNAME(_deferrer_)([&] { __VA_ARGS__; })
 
 namespace util {
 
index 52684831caa67c0d0b7da95de03f39850066767f..83a773f2cf88c0b575bd22aa8195443ed224d961 100644 (file)
@@ -537,11 +537,7 @@ main()
       fail(FMT("Failed to open log file {}", log_path));
     }
   }
-  DEFER([] {
-    if (g_log_file) {
-      std::fclose(g_log_file);
-    }
-  });
+  DEFER(if (g_log_file) { std::fclose(g_log_file); });
 
   const char* ipc_endpoint = std::getenv("CRSH_IPC_ENDPOINT");
   if (!ipc_endpoint) {