mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/3] console: don't count newlines twice in bytes written
Date: Thu, 22 Aug 2019 10:16:22 +0200	[thread overview]
Message-ID: <387a016b-c15f-8d26-0ec8-346d0a0b564b@pengutronix.de> (raw)
In-Reply-To: <d371c18e-3834-c559-2bde-1fcfd9b155dc@pengutronix.de>

Hello,

On 8/22/19 9:04 AM, Ahmad Fatoum wrote:
> 
> 
> On 8/5/19 11:11 AM, Sascha Hauer wrote:
>> On Wed, Jul 31, 2019 at 12:21:41PM +0200, Ahmad Fatoum wrote:
>>> 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.
>>
>> According to "man puts" puts() returns a non negative number on success.
>> I can't find a place where it's claimed that we have to return the
>> number of characters.
> 
> console_puts in common/console_simple.c and pbl/console.c already return the
> number of characters. Same for all the console_device puts members in the
> drivers.
> 
>> I also can't find a place where the return value
>> of any puts like function in barebox is ever evaluated. Given that it
>> might make more sense to just return zero in the absense of an error.
> 
> I too think there isn't, but it would be less surprising if common/console.c
> would behave like other puts's in barebox.

Sorry, I mixed it up. Ye, it's arguable whether they should return number
of input bytes written or zero. But no other puts in barebox counts new lines
twice, so I think the patch has its merit, even if a follow up patch in future
has puts functions return 0 instead.

> 
>>
>> Sascha
>>
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

      reply	other threads:[~2019-08-22  8:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=387a016b-c15f-8d26-0ec8-346d0a0b564b@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox