From 7086197c27f7c00544ca006561336d8d5791a482 Mon Sep 17 00:00:00 2001
From: Frans Kaashoek <kaashoek@mit.edu>
Date: Mon, 22 Aug 2022 19:36:11 -0400
Subject: [PATCH] Simplify uartputc slightly (thanks Harry Porter)

---
 kernel/uart.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/kernel/uart.c b/kernel/uart.c
index af571b1..e3b3b8a 100644
--- a/kernel/uart.c
+++ b/kernel/uart.c
@@ -92,22 +92,18 @@ uartputc(int c)
     for(;;)
       ;
   }
-
-  while(1){
-    if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
-      // buffer is full.
-      // wait for uartstart() to open up space in the buffer.
-      sleep(&uart_tx_r, &uart_tx_lock);
-    } else {
-      uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
-      uart_tx_w += 1;
-      uartstart();
-      release(&uart_tx_lock);
-      return;
-    }
+  while(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
+    // buffer is full.
+    // wait for uartstart() to open up space in the buffer.
+    sleep(&uart_tx_r, &uart_tx_lock);
   }
+  uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
+  uart_tx_w += 1;
+  uartstart();
+  release(&uart_tx_lock);
 }
 
+
 // alternate version of uartputc() that doesn't 
 // use interrupts, for use by kernel printf() and
 // to echo characters. it spins waiting for the uart's