From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 2/3] ratp: return 0 bytes written from puts if busy
Date: Mon, 5 Aug 2019 10:59:17 +0200 [thread overview]
Message-ID: <20190805085917.xvokyzpvpyc37tk6@pengutronix.de> (raw)
In-Reply-To: <20190731102143.20503-2-a.fatoum@pengutronix.de>
On Wed, Jul 31, 2019 at 12:21:42PM +0200, Ahmad Fatoum wrote:
> Prior behavior was to wrongly report all bytes written if enqueueing wasn't
> possible at the time. Instead we should either return 0 or an error code if
> users need to retry. write(2) returns 0 in such cases. Follow suit.
>
> As no current users run puts in a loop, this has no effect for now.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> Changes in v2:
> New commit.
> ---
> common/ratp/ratp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/ratp/ratp.c b/common/ratp/ratp.c
> index 9aea1786d684..8ac7dc98b6f8 100644
> --- a/common/ratp/ratp.c
> +++ b/common/ratp/ratp.c
> @@ -267,7 +267,7 @@ static int ratp_console_puts(struct console_device *cdev, const char *s)
> len = strlen(s);
>
> if (ratp_busy(&ctx->ratp))
> - return len;
> + return 0;
I'm not sure if this return value is ever used for something useful,
not sure how relevant this is. ratp_busy() however returns true when
it's called from inside the ratp code. This is necessary so that we
don't get stuck in an endless loop. If we start returning 0 for
"no characters sent" how should code evaluating this return value
react? Retrying it until all characters are sent obviously is not an
option.
I think the current behaviour of just returning 'len' is correct.
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
next prev parent reply other threads:[~2019-08-05 8:59 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=20190805085917.xvokyzpvpyc37tk6@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=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