gdbserver: convert locals to bool in captured_main

Within gdbserver/server.cc, in captured_main, convert some locals to
bool.  Move the declaration of some locals into the body of the
function.

There should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Andrew Burgess
2025-07-12 11:35:47 +01:00
parent 7116674721
commit 7a45c8e030

View File

@@ -4103,14 +4103,12 @@ static void test_registers_raw_compare_zero_length ()
[[noreturn]] static void [[noreturn]] static void
captured_main (int argc, char *argv[]) captured_main (int argc, char *argv[])
{ {
int bad_attach;
int pid; int pid;
char *arg_end; char *arg_end;
const char *port = NULL; const char *port = NULL;
char **next_arg = &argv[1]; char **next_arg = &argv[1];
volatile int multi_mode = 0; volatile bool multi_mode = false;
volatile int attach = 0; volatile bool attach = false;
int was_running;
bool selftest = false; bool selftest = false;
#if GDB_SELF_TEST #if GDB_SELF_TEST
std::vector<const char *> selftest_filters; std::vector<const char *> selftest_filters;
@@ -4143,9 +4141,9 @@ captured_main (int argc, char *argv[])
exit (0); exit (0);
} }
else if (strcmp (*next_arg, "--attach") == 0) else if (strcmp (*next_arg, "--attach") == 0)
attach = 1; attach = true;
else if (strcmp (*next_arg, "--multi") == 0) else if (strcmp (*next_arg, "--multi") == 0)
multi_mode = 1; multi_mode = true;
else if (strcmp (*next_arg, "--wrapper") == 0) else if (strcmp (*next_arg, "--wrapper") == 0)
{ {
char **tmp; char **tmp;
@@ -4328,14 +4326,14 @@ captured_main (int argc, char *argv[])
if (port != NULL) if (port != NULL)
remote_prepare (port); remote_prepare (port);
bad_attach = 0; bool bad_attach = false;
pid = 0; pid = 0;
/* --attach used to come after PORT, so allow it there for /* --attach used to come after PORT, so allow it there for
compatibility. */ compatibility. */
if (*next_arg != NULL && strcmp (*next_arg, "--attach") == 0) if (*next_arg != NULL && strcmp (*next_arg, "--attach") == 0)
{ {
attach = 1; attach = true;
next_arg++; next_arg++;
} }
@@ -4345,7 +4343,7 @@ captured_main (int argc, char *argv[])
|| (pid = strtoul (*next_arg, &arg_end, 0)) == 0 || (pid = strtoul (*next_arg, &arg_end, 0)) == 0
|| *arg_end != '\0' || *arg_end != '\0'
|| next_arg[1] != NULL)) || next_arg[1] != NULL))
bad_attach = 1; bad_attach = true;
if (bad_attach) if (bad_attach)
{ {
@@ -4410,11 +4408,12 @@ captured_main (int argc, char *argv[])
if (current_thread != nullptr) if (current_thread != nullptr)
current_process ()->dlls_changed = false; current_process ()->dlls_changed = false;
bool was_running;
if (cs.last_status.kind () == TARGET_WAITKIND_EXITED if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
|| cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED) || cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
was_running = 0; was_running = false;
else else
was_running = 1; was_running = true;
if (!was_running && !multi_mode) if (!was_running && !multi_mode)
error ("No program to debug"); error ("No program to debug");