[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 07/22] hw/ppc/mac_newworld, mac_oldworld: Don't use l
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 07/22] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image() |
Date: |
Fri, 14 Dec 2018 14:41:59 +0000 |
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 <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Acked-by: David Gibson <address@hidden>
Message-id: address@hidden
---
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);
--
2.19.2
- [Qemu-devel] [PULL 00/22] misc queue, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 02/22] exec.c: Rename cpu_physical_memory_write_rom_internal(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 01/22] scripts/checkpatch.pl: Enforce multiline comment syntax, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 04/22] disas.c: Use address_space_read() to read memory, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 05/22] monitor: Use address_space_read() to read memory, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 06/22] elf_ops.h: Use address_space_write() to write memory, Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 03/22] Rename cpu_physical_memory_write_rom() to address_space_write_rom(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 07/22] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image(),
Peter Maydell <=
- [Qemu-devel] [PULL 09/22] hw/smbios/smbios.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 08/22] hw/ppc/ppc405_boards: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 11/22] hw/i386/pc.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 10/22] hw/pci/pci.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 12/22] hw/i386/multiboot.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 13/22] hw/block/tc58128.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 14/22] device_tree.c: Don't use load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 15/22] hw/core/loader.c: Remove load_image(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 19/22] hw/sd/sdhci: Don't leak memory region in sdhci_sysbus_realize(), Peter Maydell, 2018/12/14
- [Qemu-devel] [PULL 17/22] target/arm: Free name string in ARMCPRegInfo hashtable entries, Peter Maydell, 2018/12/14