diff mbox series

[v2,29/38] gdbserver: tidy poll()

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

Commit Message

Nicholas Piggin March 29, 2022, 3:49 p.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(-)
diff mbox series

Patch

diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 139b29e..d34a64e 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)