[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SY
From: |
Peter Maydell |
Subject: |
Re: [PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SYS_READC |
Date: |
Fri, 24 Jan 2020 12:58:40 +0000 |
On Thu, 9 Jan 2020 at 14:19, Alex Bennée <address@hidden> wrote:
>
> From: Keith Packard <address@hidden>
>
> Provides a blocking call to read a character from the console using
> semihosting.chardev, if specified. This takes some careful command
> line options to use stdio successfully as the serial ports, monitor
> and semihost all want to use stdio. Here's a sample set of command
> line options which share stdio between semihost, monitor and serial
> ports:
Hi; Coverity has some complaints about this code, and
specifically the use of getchar():
> +/*
> + * For linux-user we can safely block. However as we want to return as
> + * soon as a character is read we need to tweak the termio to disable
> + * line buffering. We restore the old mode afterwards in case the
> + * program is expecting more normal behaviour. This is slow but
> + * nothing using semihosting console reading is expecting to be fast.
> + */
> +target_ulong qemu_semihosting_console_inc(CPUArchState *env)
> +{
> + uint8_t c;
> + struct termios old_tio, new_tio;
> +
> + /* Disable line-buffering and echo */
> + tcgetattr(STDIN_FILENO, &old_tio);
> + new_tio = old_tio;
> + new_tio.c_lflag &= (~ICANON & ~ECHO);
> + tcsetattr(STDIN_FILENO, TCSANOW, &new_tio);
> +
> + c = getchar();
CID 1412794 points out that this assigns the result
of getchar() to a uint8_t, which drops the distinction
between EOF and a legitimate byte.
CID 1412795 is then kind of a run-on error from that,
complaining that the int result from getchar() is
truncated before returning it.
I'm not sure what we should do with EOF, but presumably
we should handle it in some way.
thanks
-- PMM
- [PULL v2 04/14] travis.yml: avocado: Print logs of non-pass tests only, (continued)
- [PULL v2 04/14] travis.yml: avocado: Print logs of non-pass tests only, Alex Bennée, 2020/01/09
- [PULL v2 05/14] travis.yml: Detach build and test steps, Alex Bennée, 2020/01/09
- [PULL v2 06/14] travis.yml: duplicate before_script for MacOSX, Alex Bennée, 2020/01/09
- [PULL v2 07/14] travis.yml: install homebrew python for OS X, Alex Bennée, 2020/01/09
- [PULL v2 09/14] target/arm: remove unused EXCP_SEMIHOST leg, Alex Bennée, 2020/01/09
- [PULL v2 08/14] testing: don't nest build for fp-test, Alex Bennée, 2020/01/09
- [PULL v2 13/14] tests/tcg: extract __semi_call into a header and expand, Alex Bennée, 2020/01/09
- [PULL v2 10/14] target/arm: only update pc after semihosting completes, Alex Bennée, 2020/01/09
- [PULL v2 14/14] tests/tcg: add user version of dumb-as-bricks semiconsole test, Alex Bennée, 2020/01/09
- [PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SYS_READC, Alex Bennée, 2020/01/09
- Re: [PULL v2 11/14] semihosting: add qemu_semihosting_console_inc for SYS_READC,
Peter Maydell <=
- [PULL v2 12/14] tests/tcg: add a dumb-as-bricks semihosting console test, Alex Bennée, 2020/01/09
- Re: [PULL v2 00/14] testing fixes and semihosting console support, Peter Maydell, 2020/01/10