[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] pflash: Avoid warnings from coverity
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-trivial] [PATCH] pflash: Avoid warnings from coverity |
Date: |
Sat, 22 Sep 2012 17:29:20 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Sep 19, 2012 at 06:41:14PM +0200, Stefan Weil wrote:
> hw/pflash_cfi01.c:209:
> check_return: Calling function "bdrv_write" without checking return value (as
> is done elsewhere 35 out of 37 times).
>
> hw/pflash_cfi02.c:144:
> unterminated_default: The default case is not terminated by a 'break'
> statement.
>
> hw/pflash_cfi02.c:238:
> check_return: Calling function "bdrv_write" without checking return value (as
> is done elsewhere 35 out of 37 times).
>
> Signed-off-by: Stefan Weil <address@hidden>
> ---
> hw/pflash_cfi01.c | 6 ++++--
> hw/pflash_cfi02.c | 7 +++++--
> 2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/hw/pflash_cfi01.c b/hw/pflash_cfi01.c
> index 56ed33f..27ae4aa 100644
> --- a/hw/pflash_cfi01.c
> +++ b/hw/pflash_cfi01.c
> @@ -205,8 +205,10 @@ static void pflash_update(pflash_t *pfl, int offset,
> /* round to sectors */
> offset = offset >> 9;
> offset_end = (offset_end + 511) >> 9;
> - bdrv_write(pfl->bs, offset, pfl->storage + (offset << 9),
> - offset_end - offset);
> + if (bdrv_write(pfl->bs, offset, pfl->storage + (offset << 9),
> + offset_end - offset) == -1) {
bdrv_write() returns -errno, not -1.
> + fprintf(stderr, "pflash: Error writing to flash storage\n");
> + }
Please report the errno and possibly bdrv_get_device_name() to uniquely
identify this block device.
Peter's comments about reporting errors to the guest make sense to me.
I'm not sure how much work that involves, printing the error is a step
in the right direction but we shouldn't forget the TODO.
Stefan