mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Gaël PORTAY" <gael.portay@savoirfairelinux.com>
To: Ian Abbott <abbotti@mev.co.uk>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] readline_simple: return -1 if getc fails
Date: Tue, 8 Aug 2017 12:49:49 -0400	[thread overview]
Message-ID: <20170808164949.zgkj7vxz7urddcc5@gportay> (raw)
In-Reply-To: <c72bc837-b2e0-2d95-ed1d-39b6a51befec@mev.co.uk>

On Tue, Aug 08, 2017 at 05:05:35PM +0100, Ian Abbott wrote:
> On 08/08/17 16:36, Lucas Stach wrote:
> > Am Dienstag, den 08.08.2017, 11:20 -0400 schrieb Gaël PORTAY:
> > > Hi Lucas,
> > > 
> > > On Tue, Aug 08, 2017 at 09:51:54AM +0200, Lucas Stach wrote:
> > > > (...)
> > > > 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?
> > > > 
> > > 
> > > The thing here is that getchar() may return an error, and that error is not
> > > tested. This causes readline to print the character 0xea (-EINVAL) which is not
> > > printable.
> > 
> > So why wouldn't the following fix the issue?
> > 
> > signed char c;
> 
> `int` would be better to allow non-ASCII characters.
> 
> > 
> > if (c < 0)
> > 	return c;
> 
> There are places where the return value is checked for `-1` for example in
> get_user_input() ("common/hush.c"), and in run_shell() ("common/parser.c").
> 
> I think Gaël's patch is reasonable, although perhaps it should also set
> `line[0] = '\0';` before returning.
> 

Indeed, or `line[n] = '\0';` to preserve characters already entered.

BTW, it already performed by get_user_input in hush.c (n is reset to 0).

console_buffer[n] = '\n';
console_buffer[n + 1]= '\0';

> Off topic: there is another oddity in the the "simple" version of
> readline(). It ignores the `len` parameter and uses `CONFIG_CBSIZE` instead.
> 

I made a patch for this; but I have not tested yet all cases.

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

  reply	other threads:[~2017-08-08 16:50 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
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 [this message]
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=20170808164949.zgkj7vxz7urddcc5@gportay \
    --to=gael.portay@savoirfairelinux.com \
    --cc=abbotti@mev.co.uk \
    --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