[compiler-rt] 151e33c - [NFC][fuzzer] Cleanup SetThreadName after D156317

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 28 12:27:53 PDT 2023


Author: Vitaly Buka
Date: 2023-08-28T10:59:39-07:00
New Revision: 151e33c768a6d3d6d365286da449112e0cc879e7

URL: https://github.com/llvm/llvm-project/commit/151e33c768a6d3d6d365286da449112e0cc879e7
DIFF: https://github.com/llvm/llvm-project/commit/151e33c768a6d3d6d365286da449112e0cc879e7.diff

LOG: [NFC][fuzzer] Cleanup SetThreadName after D156317

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index c1b4f284b1375a..eed69d5d5b1195 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -234,11 +234,10 @@ size_t PageSize() {
 }
 
 void SetThreadName(std::thread &thread, const std::string &name) {
-  std::wstring wname;
   auto sz = MultiByteToWideChar(CP_UTF8, 0, name.data(), name.size(), nullptr, 0);
-  wname.resize(sz);
-  if (sz == MultiByteToWideChar(CP_UTF8, 0, name.data(), name.size(), &wname[0],
-                                sz) > 0) {
+  std::wstring wname(sz, L' ');
+  if ((sz == MultiByteToWideChar(CP_UTF8, 0, name.data(), name.size(),
+                                 &wname[0], sz)) > 0) {
     wname.resize(sz - 1);
     (void)SetThreadDescription(thread.native_handle(), wname.c_str());
   }


        


More information about the llvm-commits mailing list