qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: BALATON Zoltan <balaton@eik.bme.hu>, qemu-devel@nongnu.org
Subject: Re: [PATCH 4/4] hw/nvram/eeprom_at24c: Reorganise init to avoid overwriting values
Date: Mon, 3 Mar 2025 12:23:08 +0100	[thread overview]
Message-ID: <feff5b7e-0d56-4776-bec4-ffb745ae5120@linaro.org> (raw)
In-Reply-To: <fd8e0478febd60d5f48c58bc77c60e043d1c3cdc.1740839457.git.balaton@eik.bme.hu>

On 1/3/25 15:35, BALATON Zoltan wrote:
> The init_rom can write values to the beginning of the memory but these
> are overwritten by values from a backing file that covers the whole
> memory. Do the init_rom handling only if it would not be overwritten.
> 
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
>   hw/nvram/eeprom_at24c.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
> index 78c81bea77..ff7a21eee7 100644
> --- a/hw/nvram/eeprom_at24c.c
> +++ b/hw/nvram/eeprom_at24c.c
> @@ -191,10 +191,6 @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
>   
>       ee->mem = g_malloc0(ee->rsize);
>   
> -    if (ee->init_rom) {
> -        memcpy(ee->mem, ee->init_rom, MIN(ee->init_rom_size, ee->rsize));
> -    }
> -
>       if (ee->blk) {
>           int ret = blk_pread(ee->blk, 0, ee->rsize, ee->mem, 0);
>   
> @@ -204,6 +200,8 @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
>               return;
>           }
>           DPRINTK("Reset read backing file\n");
> +    } else if (ee->init_rom) {

Don't you want to keep overwritting the init_rom[] buffer?

IOW why not s/else//?

> +        memcpy(ee->mem, ee->init_rom, MIN(ee->init_rom_size, ee->rsize));
>       }
>   
>       /*



  reply	other threads:[~2025-03-03 11:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-01 14:35 [PATCH 0/4] Misc eeprom_at24c clean ups BALATON Zoltan
2025-03-01 14:35 ` [PATCH 1/4] hw/nvram/eeprom_at24c: Use OBJECT_DECLARE_SIMPLE_TYPE BALATON Zoltan
2025-03-03 11:19   ` Philippe Mathieu-Daudé
2025-03-01 14:35 ` [PATCH 2/4] hw/nvram/eeprom_at24c: Remove ERR macro that calls fprintf to stderr BALATON Zoltan
2025-03-03 11:24   ` Philippe Mathieu-Daudé
2025-03-01 14:35 ` [PATCH 3/4] hw/nvram/eeprom_at24c: Remove memset after g_malloc0 BALATON Zoltan
2025-03-03 11:20   ` Philippe Mathieu-Daudé
2025-03-01 14:35 ` [PATCH 4/4] hw/nvram/eeprom_at24c: Reorganise init to avoid overwriting values BALATON Zoltan
2025-03-03 11:23   ` Philippe Mathieu-Daudé [this message]
2025-03-03 12:32     ` BALATON Zoltan
2025-03-03 12:40       ` Philippe Mathieu-Daudé
2025-03-03 12:43         ` Philippe Mathieu-Daudé
2025-03-03 12:43 ` [PATCH 0/4] Misc eeprom_at24c clean ups Philippe Mathieu-Daudé

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=feff5b7e-0d56-4776-bec4-ffb745ae5120@linaro.org \
    --to=philmd@linaro.org \
    --cc=balaton@eik.bme.hu \
    --cc=qemu-devel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).