From 33b8b2bd3d2f124edf53713ddfc39d20fb9c1808 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 30 Apr 2025 14:50:20 +0500 Subject: [PATCH] Added a static_assert to enforce a maximum thread name length of 16 characters at compile time --- include/proxysql_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/proxysql_utils.h b/include/proxysql_utils.h index e03b01bbc..2d2ac3e1a 100644 --- a/include/proxysql_utils.h +++ b/include/proxysql_utils.h @@ -307,7 +307,9 @@ struct free_deleter { template using mf_unique_ptr = std::unique_ptr; -static inline void set_thread_name(const char name[16], const bool en = true) { +template +static inline void set_thread_name(const char(&name)[LEN], const bool en = true) { + static_assert(LEN < 17, "Thread name must not exceed 16 characters"); if (en == false) { return; }