qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, patches@linaro.org,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	"Daniel P . Berrange" <berrange@redhat.com>,
	Li Zhijian <lizhijian@cn.fujitsu.com>,
	Philip Li <philip.li@intel.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Alexander Graf <agraf@suse.de>, Kevin Wolf <kwolf@redhat.com>,
	Max Reitz <mreitz@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
	Igor Mammedov <imammedo@redhat.com>,
	qemu-block@nongnu.org, qemu-ppc@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 01/10] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image()
Date: Sun, 2 Dec 2018 19:54:32 +1100	[thread overview]
Message-ID: <20181202085432.GK30479@umbus.fritz.box> (raw)
In-Reply-To: <20181130151712.2312-2-peter.maydell@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3193 bytes --]

On Fri, Nov 30, 2018 at 03:17:03PM +0000, Peter Maydell wrote:
> The load_image() function is deprecated, as it does not let the
> caller specify how large the buffer to read the file into is.
> Use the glib g_file_get_contents() function instead, which does
> the whole "allocate memory for the file and read it in" operation.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  hw/ppc/mac_newworld.c | 10 ++++------
>  hw/ppc/mac_oldworld.c | 10 ++++------
>  2 files changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 14273a123e5..7e45afae7c5 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -127,8 +127,7 @@ static void ppc_core99_init(MachineState *machine)
>      MACIOIDEState *macio_ide;
>      BusState *adb_bus;
>      MacIONVRAMState *nvr;
> -    int bios_size, ndrv_size;
> -    uint8_t *ndrv_file;
> +    int bios_size;
>      int ppc_boot_device;
>      DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>      void *fw_cfg;
> @@ -510,11 +509,10 @@ static void ppc_core99_init(MachineState *machine)
>      /* MacOS NDRV VGA driver */
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME);
>      if (filename) {
> -        ndrv_size = get_image_size(filename);
> -        if (ndrv_size != -1) {
> -            ndrv_file = g_malloc(ndrv_size);
> -            ndrv_size = load_image(filename, ndrv_file);
> +        gchar *ndrv_file;
> +        gsize ndrv_size;
>  
> +        if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
>              fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
>          }
>          g_free(filename);
> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> index 9891c325a9b..817f70e52cf 100644
> --- a/hw/ppc/mac_oldworld.c
> +++ b/hw/ppc/mac_oldworld.c
> @@ -99,8 +99,7 @@ static void ppc_heathrow_init(MachineState *machine)
>      SysBusDevice *s;
>      DeviceState *dev, *pic_dev;
>      BusState *adb_bus;
> -    int bios_size, ndrv_size;
> -    uint8_t *ndrv_file;
> +    int bios_size;
>      uint16_t ppc_boot_device;
>      DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
>      void *fw_cfg;
> @@ -361,11 +360,10 @@ static void ppc_heathrow_init(MachineState *machine)
>      /* MacOS NDRV VGA driver */
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME);
>      if (filename) {
> -        ndrv_size = get_image_size(filename);
> -        if (ndrv_size != -1) {
> -            ndrv_file = g_malloc(ndrv_size);
> -            ndrv_size = load_image(filename, ndrv_file);
> +        gchar *ndrv_file;
> +        gsize ndrv_size;
>  
> +        if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) {
>              fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
>          }
>          g_free(filename);

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2018-12-02  9:20 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-30 15:17 [Qemu-devel] [PATCH 00/10] Remove deprecated load_image() function Peter Maydell
2018-11-30 15:17 ` [Qemu-devel] [PATCH 01/10] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image() Peter Maydell
2018-11-30 20:08   ` Eric Blake
2018-12-02  8:54   ` David Gibson [this message]
2018-11-30 15:17 ` [Qemu-devel] [PATCH 02/10] hw/ppc/ppc405_boards: " Peter Maydell
2018-11-30 20:20   ` Eric Blake
2018-12-02  8:55   ` David Gibson
2018-11-30 15:17 ` [Qemu-devel] [PATCH 03/10] hw/smbios/smbios.c: " Peter Maydell
2018-11-30 20:21   ` Eric Blake
2018-11-30 15:17 ` [Qemu-devel] [PATCH 04/10] hw/pci/pci.c: " Peter Maydell
2018-11-30 20:22   ` Eric Blake
2018-11-30 15:17 ` [Qemu-devel] [PATCH 05/10] hw/i386/pc.c: " Peter Maydell
2018-11-30 20:26   ` Eric Blake
2018-12-01 11:52   ` Peter Maydell
2018-11-30 15:17 ` [Qemu-devel] [PATCH 06/10] hw/i386/multiboot.c: " Peter Maydell
2018-11-30 20:28   ` Eric Blake
2018-11-30 15:17 ` [Qemu-devel] [PATCH 07/10] hw/block/tc58128.c: " Peter Maydell
2018-11-30 20:30   ` Eric Blake
2018-11-30 15:17 ` [Qemu-devel] [PATCH 08/10] device_tree.c: " Peter Maydell
2018-11-30 20:31   ` Eric Blake
2018-11-30 15:17 ` [Qemu-devel] [PATCH 09/10] hw/core/loader.c: Remove load_image() Peter Maydell
2018-11-30 20:32   ` Eric Blake
2018-11-30 15:17 ` [Qemu-devel] [PATCH 10/10] include/hw/loader.h: Document load_image_size() Peter Maydell
2018-11-30 20:33   ` Eric Blake
2018-12-01  3:25 ` [Qemu-devel] [PATCH 00/10] Remove deprecated load_image() function no-reply
2018-12-03 15:45 ` Richard Henderson
2018-12-05 13:45 ` Stefan Hajnoczi
2018-12-05 13:58 ` Michael S. Tsirkin
2018-12-14 11:30 ` Peter Maydell

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=20181202085432.GK30479@umbus.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=agraf@suse.de \
    --cc=berrange@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=eblake@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lizhijian@cn.fujitsu.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=mst@redhat.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=philip.li@intel.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).