[PATCH v2 1/3] console: don't count newlines twice in bytes written

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both the PBL and simple console only return number of input bytes, not
number of bytes actually written out. These differ, because each LF is
converted to CRLF pairs.

The behavior of not counting actual written out characters is more sensible,
because otherwise callers interested in finding out if all bytes have been
written (e.g. to avoid incomplete writes with ratp) would need to keep count
of all line feeds in the string.
Therefore change the normal console to behave like its less featureful
brethren.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
Changes in v2:
	New commit.
---
 common/console.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/common/console.c b/common/console.c
index 47ccf2e54de0..52162df23b04 100644
--- a/common/console.c
+++ b/common/console.c
@@ -258,10 +258,9 @@ static int __console_puts(struct console_device *cdev, const char *s)
 	int n = 0;
 
 	while (*s) {
-		if (*s == '\n') {
+		if (*s == '\n')
 			cdev->putc(cdev, '\r');
-			n++;
-		}
+
 		cdev->putc(cdev, *s);
 		n++;
 		s++;
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux