[1/2] Rename variable main_thread to main_thread_id

Message ID 20230728105945.13909-1-tdevries@suse.de
State Committed
Headers
Series [1/2] Rename variable main_thread to main_thread_id |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 warning Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-arm warning Patch failed to apply

Commit Message

Tom de Vries July 28, 2023, 10:59 a.m. UTC
  I noticed that the variable main_thread:
...
/* The main thread.  */

static std::thread::id main_thread;
...
has a confusing name and corresponding comment, because it doesn't contain the
main thread, but rather the main thread's std::thread::id.

Fix this by renaming to main_thread_id.

Tested on x86_64-linux.
---
 gdb/run-on-main-thread.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)


base-commit: 29c108c9610640439daa5244a573348b7c47d994
  

Comments

Tom Tromey July 28, 2023, 1:06 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> I noticed that the variable main_thread:
Tom> ...
Tom> /* The main thread.  */

Tom> static std::thread::id main_thread;
Tom> ...
Tom> has a confusing name and corresponding comment, because it doesn't contain the
Tom> main thread, but rather the main thread's std::thread::id.

Tom> Fix this by renaming to main_thread_id.

Thanks.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
index c7d9de0afc8..91d25dae28f 100644
--- a/gdb/run-on-main-thread.c
+++ b/gdb/run-on-main-thread.c
@@ -39,9 +39,9 @@  static std::vector<std::function<void ()>> runnables;
 
 static std::mutex runnable_mutex;
 
-/* The main thread.  */
+/* The main thread's thread id.  */
 
-static std::thread::id main_thread;
+static std::thread::id main_thread_id;
 
 #endif
 
@@ -100,7 +100,7 @@  bool
 is_main_thread ()
 {
 #if CXX_STD_THREAD
-  return std::this_thread::get_id () == main_thread;
+  return std::this_thread::get_id () == main_thread_id;
 #else
   return true;
 #endif
@@ -111,7 +111,7 @@  void
 _initialize_run_on_main_thread ()
 {
 #if CXX_STD_THREAD
-  main_thread = std::this_thread::get_id ();
+  main_thread_id = std::this_thread::get_id ();
 #endif
   runnable_event = make_serial_event ();
   add_file_handler (serial_event_fd (runnable_event), run_events, nullptr,