qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] When updating the PFLASH file contents, we should check for


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] When updating the PFLASH file contents, we should check for a possible failure of blk_pwrite(). Similar to 3a68829 commit
Date: Sun, 12 Apr 2020 23:35:11 +0200

ping? rc3 is in 2 days.

On Wed, Apr 8, 2020 at 10:10 AM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> Hi Mansour,
>
> On 4/8/20 2:35 AM, Mansour Ahmadi wrote:
> > Signed-off-by: Mansour Ahmadi <address@hidden>
> > ---
> >   hw/block/pflash_cfi01.c | 6 +++++-
> >   hw/block/pflash_cfi02.c | 6 +++++-
> >   2 files changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
> > index 24f3bce7ef..31319cfd07 100644
> > --- a/hw/block/pflash_cfi01.c
> > +++ b/hw/block/pflash_cfi01.c
> > @@ -399,13 +399,17 @@ static void pflash_update(PFlashCFI01 *pfl, int 
> > offset,
> >                             int size)
> >   {
> >       int offset_end;
> > +    int ret;
> >       if (pfl->blk) {
> >           offset_end = offset + size;
> >           /* widen to sector boundaries */
> >           offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
> >           offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
> > -        blk_pwrite(pfl->blk, offset, pfl->storage + offset,
> > +        ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
> >                      offset_end - offset, 0);
> > +     if (ret < 0) {
> > +            error_report("Could not update PFLASH: %s", strerror(-ret));
>
> Thanks for your patch. Note that it doesn't compile:
>
> hw/block/pflash_cfi01.c:411:6: error: implicit declaration of function
> 'error_report' [-Werror=implicit-function-declaration]
>        error_report("Could not update PFLASH: %s", strerror(-ret));
>        ^
>
> Better than reporting the error is to set the error flag in the status
> register.
>
> > +        }
> >       }
> >   }
> >
> > diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c
> > index 12f18d401a..fee5b3497c 100644
> > --- a/hw/block/pflash_cfi02.c
> > +++ b/hw/block/pflash_cfi02.c
> > @@ -393,13 +393,17 @@ static uint64_t pflash_read(void *opaque, hwaddr 
> > offset, unsigned int width)
> >   static void pflash_update(PFlashCFI02 *pfl, int offset, int size)
> >   {
> >       int offset_end;
> > +    int ret;
> >       if (pfl->blk) {
> >           offset_end = offset + size;
> >           /* widen to sector boundaries */
> >           offset = QEMU_ALIGN_DOWN(offset, BDRV_SECTOR_SIZE);
> >           offset_end = QEMU_ALIGN_UP(offset_end, BDRV_SECTOR_SIZE);
> > -        blk_pwrite(pfl->blk, offset, pfl->storage + offset,
> > +        ret = blk_pwrite(pfl->blk, offset, pfl->storage + offset,
> >                      offset_end - offset, 0);
> > +     if (ret < 0) {
> > +         error_report("Could not update PFLASH: %s", strerror(-ret));
> > +        }
>
> Similar comments (does not compile, set error status register).
>
> >       }
> >   }
> >
> >
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]