Re: [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]

 



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@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