]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Handle 0 return value from std::thread::hardware_concurrency
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 9 May 2026 14:29:52 +0000 (16:29 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 9 May 2026 14:30:23 +0000 (16:30 +0200)
src/ccache/core/mainoptions.cpp

index 06691e97b0cc6a236f1ace0bf1b1ab81099f3215..4b6523ba6fc4014f92bcdc60cd9cb73a29490ee1 100644 (file)
@@ -512,7 +512,7 @@ process_main_options(int argc, const char* const* argv)
   uint8_t verbosity = 0;
 
   StatisticsFormat format = StatisticsFormat::Tab;
-  uint32_t threads = std::thread::hardware_concurrency();
+  uint32_t threads = std::max<uint32_t>(2, std::thread::hardware_concurrency());
   std::optional<uint64_t> trim_max_size;
   std::optional<util::SizeUnitPrefixType> trim_suffix_type;
   bool trim_lru_mtime = false;