From: Stefan Weil <sw@weilnetz.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH] pflash: Avoid warnings from coverity
Date: Wed, 19 Sep 2012 22:51:05 +0200 [thread overview]
Message-ID: <505A3039.3070404@weilnetz.de> (raw)
In-Reply-To: <CAFEAcA8Yc1V1jnqrsOPT-JVgNX2RmkM2RoZUg2DzAHtW+dWtUA@mail.gmail.com>
Am 19.09.2012 18:45, schrieb Peter Maydell:
> On 19 September 2012 17:41, Stefan Weil <sw@weilnetz.de> 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 <sw@weilnetz.de>
>> ---
>> 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) {
>> + fprintf(stderr, "pflash: Error writing to flash storage\n");
>> + }
> ...shouldn't we be propagating the write error up to the guest?
> It feels like this change is just silencing the coverity error
> without actually fixing the underlying problem.
>
> -- PMM
As far as I know, there is no concept how a flash memory
can report a write error. Flash memory which cannot be
written is unusable.
hw/nand.c uses a similar handling for write errors,
but writes the error message to stdout (no good idea).
- Stefan
WARNING: multiple messages have this Message-ID (diff)
From: Stefan Weil <sw@weilnetz.de>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] pflash: Avoid warnings from coverity
Date: Wed, 19 Sep 2012 22:51:05 +0200 [thread overview]
Message-ID: <505A3039.3070404@weilnetz.de> (raw)
In-Reply-To: <CAFEAcA8Yc1V1jnqrsOPT-JVgNX2RmkM2RoZUg2DzAHtW+dWtUA@mail.gmail.com>
Am 19.09.2012 18:45, schrieb Peter Maydell:
> On 19 September 2012 17:41, Stefan Weil <sw@weilnetz.de> 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 <sw@weilnetz.de>
>> ---
>> 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) {
>> + fprintf(stderr, "pflash: Error writing to flash storage\n");
>> + }
> ...shouldn't we be propagating the write error up to the guest?
> It feels like this change is just silencing the coverity error
> without actually fixing the underlying problem.
>
> -- PMM
As far as I know, there is no concept how a flash memory
can report a write error. Flash memory which cannot be
written is unusable.
hw/nand.c uses a similar handling for write errors,
but writes the error message to stdout (no good idea).
- Stefan
next prev parent reply other threads:[~2012-09-19 20:51 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-19 16:41 [Qemu-trivial] [PATCH] pflash: Avoid warnings from coverity Stefan Weil
2012-09-19 16:41 ` [Qemu-devel] " Stefan Weil
2012-09-19 16:45 ` [Qemu-trivial] " Peter Maydell
2012-09-19 16:45 ` Peter Maydell
2012-09-19 20:51 ` Stefan Weil [this message]
2012-09-19 20:51 ` Stefan Weil
2012-09-20 8:31 ` [Qemu-trivial] " Peter Maydell
2012-09-20 8:31 ` Peter Maydell
2012-09-22 16:29 ` [Qemu-trivial] " Stefan Hajnoczi
2012-09-22 16:29 ` [Qemu-devel] " Stefan Hajnoczi
2012-09-22 16:58 ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2012-09-22 16:58 ` [Qemu-devel] [Qemu-trivial] " Peter Maydell
2012-09-22 18:53 ` Stefan Weil
2012-09-22 18:53 ` [Qemu-devel] " Stefan Weil
2012-09-24 7:48 ` Kevin Wolf
2012-09-24 7:48 ` [Qemu-devel] " Kevin Wolf
2012-09-24 8:41 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2012-09-24 8:41 ` [Qemu-devel] [Qemu-trivial] " Markus Armbruster
2012-09-24 8:53 ` [Qemu-trivial] [Qemu-devel] " Kevin Wolf
2012-09-24 8:53 ` [Qemu-devel] [Qemu-trivial] " Kevin Wolf
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=505A3039.3070404@weilnetz.de \
--to=sw@weilnetz.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.