mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] console: don't count newlines twice in bytes written
@ 2019-07-31 10:21 Ahmad Fatoum
  2019-07-31 10:21 ` [PATCH v2 2/3] ratp: return 0 bytes written from puts if busy Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Ahmad Fatoum @ 2019-07-31 10:21 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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@pengutronix.de>
---
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-08-23  9:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-31 10:21 [PATCH v2 1/3] console: don't count newlines twice in bytes written Ahmad Fatoum
2019-07-31 10:21 ` [PATCH v2 2/3] ratp: return 0 bytes written from puts if busy Ahmad Fatoum
2019-08-05  8:59   ` Sascha Hauer
2019-08-22  6:57     ` Ahmad Fatoum
2019-07-31 10:21 ` [PATCH v2 3/3] console: fix out-of-bounds read in dputc(/dev/*, ...) Ahmad Fatoum
2019-08-22  7:06   ` Ahmad Fatoum
2019-08-23  7:07     ` Sascha Hauer
2019-08-23  9:28       ` Ahmad Fatoum
2019-08-05  9:11 ` [PATCH v2 1/3] console: don't count newlines twice in bytes written Sascha Hauer
2019-08-22  7:04   ` Ahmad Fatoum
2019-08-22  8:16     ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox