diff mbox series

[v2,30/39] gdbserver: tidy poll()

Message ID 20220420065013.222816-31-npiggin@gmail.com
State New
Headers show
Series gdbserver multi-threaded debugging and POWER9/10 support | expand

Commit Message

Nicholas Piggin April 20, 2022, 6:50 a.m. UTC
Remove the pointless case statement and reduce indentation.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 src/pdbgproxy.c | 46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

Comments

Joel Stanley May 3, 2022, 7:32 a.m. UTC | #1
On Wed, 20 Apr 2022 at 06:51, Nicholas Piggin <npiggin@gmail.com> wrote:
>
> Remove the pointless case statement and reduce indentation.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Reviewed-by: Joel Stanley <joel@jms.id.au>

> ---
>  src/pdbgproxy.c | 46 +++++++++++++++++++++-------------------------
>  1 file changed, 21 insertions(+), 25 deletions(-)
>
> diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
> index 01419108..c5870091 100644
> --- a/src/pdbgproxy.c
> +++ b/src/pdbgproxy.c
> @@ -708,40 +708,36 @@ static void poll(void)
>  {
>         struct thread_state status;
>
> +       if (state != SIGNAL_WAIT)
> +               return;
> +
>         thread_target->probe(thread_target);
>         status = thread_status(thread_target);
>
> -       switch (state) {
> -       case IDLE:
> -               break;
> -
> -       case SIGNAL_WAIT:
> -               if (!(status.quiesced))
> -                       break;
> -
> -               set_attn(false);
> +       if (!(status.quiesced))
> +               return;
>
> -               state = IDLE;
> -               poll_interval = VCONT_POLL_DELAY;
> +       set_attn(false);
>
> -               if (thread_check_attn(thread_target)) {
> -                       uint64_t nia;
> +       state = IDLE;
> +       poll_interval = VCONT_POLL_DELAY;
>
> -                       if (!(status.active)) {
> -                               PR_ERROR("Thread inactive after trap\n");
> -                               send_response(fd, ERROR(EPERM));
> -                               return;
> -                       }
> +       if (thread_check_attn(thread_target)) {
> +               uint64_t nia;
>
> -                       /* Restore NIA */
> -                       if (thread_getnia(thread_target, &nia))
> -                               PR_ERROR("Error during getnia\n");
> -                       if (thread_putnia(thread_target, nia - 4))
> -                               PR_ERROR("Error during putnia\n");
> +               if (!(status.active)) {
> +                       PR_ERROR("Thread inactive after trap\n");
> +                       send_response(fd, ERROR(EPERM));
> +                       return;
>                 }
> -               send_response(fd, TRAP);
> -               break;
> +
> +               /* Restore NIA */
> +               if (thread_getnia(thread_target, &nia))
> +                       PR_ERROR("Error during getnia\n");
> +               if (thread_putnia(thread_target, nia - 4))
> +                       PR_ERROR("Error during putnia\n");
>         }
> +       send_response(fd, TRAP);
>  }
>
>  static void cmd_default(uint64_t *stack, void *priv)
> --
> 2.35.1
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
diff mbox series

Patch

diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 01419108..c5870091 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -708,40 +708,36 @@  static void poll(void)
 {
 	struct thread_state status;
 
+	if (state != SIGNAL_WAIT)
+		return;
+
 	thread_target->probe(thread_target);
 	status = thread_status(thread_target);
 
-	switch (state) {
-	case IDLE:
-		break;
-
-	case SIGNAL_WAIT:
-		if (!(status.quiesced))
-			break;
-
-		set_attn(false);
+	if (!(status.quiesced))
+		return;
 
-		state = IDLE;
-		poll_interval = VCONT_POLL_DELAY;
+	set_attn(false);
 
-		if (thread_check_attn(thread_target)) {
-			uint64_t nia;
+	state = IDLE;
+	poll_interval = VCONT_POLL_DELAY;
 
-			if (!(status.active)) {
-				PR_ERROR("Thread inactive after trap\n");
-				send_response(fd, ERROR(EPERM));
-				return;
-			}
+	if (thread_check_attn(thread_target)) {
+		uint64_t nia;
 
-			/* Restore NIA */
-			if (thread_getnia(thread_target, &nia))
-				PR_ERROR("Error during getnia\n");
-			if (thread_putnia(thread_target, nia - 4))
-				PR_ERROR("Error during putnia\n");
+		if (!(status.active)) {
+			PR_ERROR("Thread inactive after trap\n");
+			send_response(fd, ERROR(EPERM));
+			return;
 		}
-		send_response(fd, TRAP);
-		break;
+
+		/* Restore NIA */
+		if (thread_getnia(thread_target, &nia))
+			PR_ERROR("Error during getnia\n");
+		if (thread_putnia(thread_target, nia - 4))
+			PR_ERROR("Error during putnia\n");
 	}
+	send_response(fd, TRAP);
 }
 
 static void cmd_default(uint64_t *stack, void *priv)