[PATCH 08/25] efi-stdio: return bytes actually consumed

Sascha Hauer s.hauer at pengutronix.de
Mon Dec 13 13:08:48 PST 2021


efi_process_square_bracket() returns the number of characters consumed
including the escape character which starts the escape sequence. That
escape character is not passed to efi_process_square_bracket(), so it
seems more consistent to return the number of characters without the
escape.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/serial/efi-stdio.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/serial/efi-stdio.c b/drivers/serial/efi-stdio.c
index dec633a7d6..0c804a5d97 100644
--- a/drivers/serial/efi-stdio.c
+++ b/drivers/serial/efi-stdio.c
@@ -195,27 +195,27 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
 		/* home */
 	case 'F':
 		/* end */
-		return 3;
+		return 2;
 	case 'K':
 		clear_to_eol(priv);
-		return 3;
+		return 2;
 	}
 
 	if (*inp == '2' && *(inp + 1) == 'J') {
 		priv->out->clear_screen(priv->out);
-		return 4;
+		return 3;
 	}
 
 	if (*inp == '0' && *(inp + 1) == 'm') {
 		priv->out->set_attribute(priv->out,
 				EFI_TEXT_ATTR(EFI_WHITE, EFI_BLACK));
-		return 4;
+		return 3;
 	}
 
 	if (*inp == '7' && *(inp + 1) == 'm') {
 		priv->out->set_attribute(priv->out,
 				EFI_TEXT_ATTR(EFI_BLACK, priv->current_color));
-		return 4;
+		return 3;
 	}
 
 	if (*inp == '1' &&
@@ -239,7 +239,7 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
 
 		priv->out->set_attribute(priv->out,
 				EFI_TEXT_ATTR(color, EFI_BLACK));
-		return 7;
+		return 6;
 	}
 
 	y = simple_strtoul(inp, &endp, 10);
@@ -247,11 +247,11 @@ static int efi_process_square_bracket(struct efi_console_priv *priv, const char
 		x = simple_strtoul(endp + 1, &endp, 10);
 		if (*endp == 'H') {
 			priv->out->set_cursor_position(priv->out, x - 1, y - 1);
-			return endp - inp + 3;
+			return endp - inp + 2;
 		}
 	}
 
-	return 8;
+	return 7;
 }
 
 static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
@@ -263,7 +263,7 @@ static int efi_process_escape(struct efi_console_priv *priv, const char *inp)
 	inp++;
 
 	if (*inp == '[')
-		return efi_process_square_bracket(priv, inp);
+		return efi_process_square_bracket(priv, inp) + 1;
 
 	return 1;
 }
-- 
2.30.2




More information about the barebox mailing list