diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-27 20:23:44 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-06-27 20:23:44 +1000 |
commit | 332983c97b7a729c4dc5f19aa9ee4a22c420f7d8 (patch) | |
tree | fd9c441b796b522bdd5c7f8fbd32f51b8eff2a28 /source/core/StarThread_unix.cpp | |
parent | 14b9689b6d4f4ad5276c88130dc6e449bedc0709 (diff) |
The Formatting String Catastrophe
Diffstat (limited to 'source/core/StarThread_unix.cpp')
-rw-r--r-- | source/core/StarThread_unix.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source/core/StarThread_unix.cpp b/source/core/StarThread_unix.cpp index ba635f9..22fd10d 100644 --- a/source/core/StarThread_unix.cpp +++ b/source/core/StarThread_unix.cpp @@ -31,21 +31,21 @@ struct ThreadImpl { #ifdef STAR_SYSTEM_MACOS // ensure the name is under the max allowed char tname[MAX_THREAD_NAMELEN]; - snprintf(tname, sizeof(tname), "%s", ptr->name.utf8Ptr()); + snprintf(tname, sizeof(tname), "{}", ptr->name.utf8Ptr()); pthread_setname_np(tname); #endif ptr->function(); } catch (std::exception const& e) { if (ptr->name.empty()) - Logger::error("Exception caught in Thread: %s", outputException(e, true)); + Logger::error("Exception caught in Thread: {}", outputException(e, true)); else - Logger::error("Exception caught in Thread %s: %s", ptr->name, outputException(e, true)); + Logger::error("Exception caught in Thread {}: {}", ptr->name, outputException(e, true)); } catch (...) { if (ptr->name.empty()) Logger::error("Unknown exception caught in Thread"); else - Logger::error("Unknown exception caught in Thread %s", ptr->name); + Logger::error("Unknown exception caught in Thread {}", ptr->name); } ptr->stopped = true; return nullptr; @@ -65,12 +65,12 @@ struct ThreadImpl { if (ret != 0) { stopped = true; joined = true; - throw StarException(strf("Failed to create thread, error %s", ret)); + throw StarException(strf("Failed to create thread, error {}", ret)); } // ensure the name is under the max allowed char tname[MAX_THREAD_NAMELEN]; - snprintf(tname, sizeof(tname), "%s", name.utf8Ptr()); + snprintf(tname, sizeof(tname), "{}", name.utf8Ptr()); #ifdef STAR_SYSTEM_FREEBSD pthread_set_name_np(pthread, tname); @@ -86,7 +86,7 @@ struct ThreadImpl { return false; int ret = pthread_join(pthread, NULL); if (ret != 0) - throw StarException(strf("Failed to join thread, error %s", ret)); + throw StarException(strf("Failed to join thread, error {}", ret)); joined = true; return true; } @@ -242,7 +242,7 @@ void Thread::yield() { unsigned Thread::numberOfProcessors() { long nprocs = sysconf(_SC_NPROCESSORS_ONLN); if (nprocs < 1) - throw StarException(strf("Could not determine number of CPUs online: %s\n", strerror(errno))); + throw StarException(strf("Could not determine number of CPUs online: {}\n", strerror(errno))); return nprocs; } |