mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: "Gaël PORTAY" <gael.portay@savoirfairelinux.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] readline_simple: return -1 if getc fails
Date: Tue, 08 Aug 2017 09:51:54 +0200	[thread overview]
Message-ID: <1502178714.2934.21.camel@pengutronix.de> (raw)
In-Reply-To: <20170807221042.19700-2-gael.portay@savoirfairelinux.com>

Am Montag, den 07.08.2017, 18:10 -0400 schrieb Gaël PORTAY:
> The getc function may return an errno code if an error happens.
> 
> This patch prevents readline from printing a non printable character and
> from looping to infinity and beyong.
> 
> Signed-off-by: Gaël PORTAY <gael.portay@savoirfairelinux.com>
> ---
>  lib/readline_simple.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/readline_simple.c b/lib/readline_simple.c
> index c4d3d240e..1283c9602 100644
> --- a/lib/readline_simple.c
> +++ b/lib/readline_simple.c
> @@ -58,6 +58,8 @@ int readline (const char *prompt, char *line, int len)
>  
>  	for (;;) {
>  		c = getchar();
> +		if (c < 0)
> +			return (-1);

I don't like made up error codes. Is there any reason why we couldn't
just pass through the negative error code from getchar?

Regards,
Lucas


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

  reply	other threads:[~2017-08-08  7:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-07 22:10 [PATCH 0/2] " Gaël PORTAY
2017-08-07 22:10 ` [PATCH 1/2] " Gaël PORTAY
2017-08-08  7:51   ` Lucas Stach [this message]
2017-08-08 10:07     ` Ian Abbott
2017-08-08 15:21       ` Gaël PORTAY
2017-08-08 15:20     ` Gaël PORTAY
2017-08-08 15:36       ` Lucas Stach
2017-08-08 16:05         ` Ian Abbott
2017-08-08 16:49           ` Gaël PORTAY
2017-08-08 16:14         ` Gaël PORTAY
2017-08-07 22:10 ` [PATCH 2/2] readline_simple: remove obsolete documentation Gaël PORTAY

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=1502178714.2934.21.camel@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=gael.portay@savoirfairelinux.com \
    /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