On 25/7/22 16:05, Alex Bennée wrote:
From: Peter Maydell <peter.mayd...@linaro.org>

The documentation comment for qemu_semihosting_console_write() says
  * Returns: number of bytes written -- this should only ever be short
  * on some sort of i/o error.

and the callsites rely on this.  However, the implementation code
path which sends console output to a chardev doesn't honour this,
and will return negative values on error.  Bring it into line with
the other implementation codepaths and the documentation, so that
it returns 0 on error.

Spotted by Coverity, because console_write() passes the return value
to unlock_user(), which doesn't accept a negative length.

Resolves: Coverity CID 1490288
Signed-off-by: Peter Maydell <peter.mayd...@linaro.org>
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
Message-Id: <20220719121110.225657-2-peter.mayd...@linaro.org>
Signed-off-by: Alex Bennée <alex.ben...@linaro.org>
---
  semihosting/console.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org>

Reply via email to