Unify memory allocation failure handling
cover Unify memory allocation failure handling
Memory allocation failures are a very rare condition on virtual-memory hosts. They are also very difficult to handle correctly (especially in a hardware emulation context). Because of this, it is better to gracefully terminate emulation rather than executing untested or even unwritten recovery code paths.
This patchset modifies qemu_malloc() and related functions to terminate on error, and updates callers not to perform their own error handling. In many cases error handling was already missing or incorrect.
Avi Kivity (6):
Terminate emulation on memory allocation failure
block: remove error handling from qemu_malloc() callers
audio: remove error handling from qemu_malloc() callers
hw: remove error handling from qemu_malloc() callers
targets: remove error handling from qemu_malloc() callers
toplevel: remove error handling from qemu_malloc() callers
aio.c | 2 - audio/audio.c | 23 +-- audio/wavcapture.c | 5 - block-bochs.c | 2 - block-cloop.c | 9 +- block-dmg.c | 6 +- block-parallels.c | 2 - block-qcow2.c | 58 +------ block-raw-posix.c | 2 - block-vmdk.c | 10 - block-vpc.c | 4 - block-vvfat.c | 18 +- block.c | 6 - buffered_file.c | 2 - console.c | 23 --- cris-dis.c | 26 +-- curses.c | 2 - device_tree.c | 4 - exec.c | 25 +-- gdbstub.c | 8 - hw/adlib.c | 7 - hw/apic.c | 4 - hw/arm_gic.c | 2 - hw/arm_sysctl.c | 2 - hw/baum.c | 10 - hw/cs4231.c | 2 - hw/cs4231a.c | 5 - hw/ds1225y.c | 5 - hw/eccmemctl.c | 2 - hw/escc.c | 4 - hw/esp.c | 2 - hw/etraxfs_dma.c | 8 - hw/etraxfs_eth.c | 8 - hw/etraxfs_pic.c | 6 - hw/etraxfs_ser.c | 2 - hw/etraxfs_timer.c | 2 - hw/fdc.c | 6 - hw/fmopl.c | 27 +--- hw/fw_cfg.c | 8 - hw/g364fb.c | 2 - hw/gus.c | 11 - hw/i8259.c | 2 - hw/ide.c | 2 - hw/integratorcp.c | 2 - hw/iommu.c | 2 - hw/jazz_led.c | 2 - hw/m48t59.c | 6 - hw/mac_dbdma.c | 2 - hw/mac_nvram.c | 6 - hw/mc146818rtc.c | 4 - hw/mipsnet.c | 2 - hw/mpcore.c | 2 - hw/mst_fpga.c | 2 - hw/musicpal.c | 14 -- hw/ne2000.c | 2 - hw/parallel.c | 4 - hw/pci.c | 2 - hw/pcnet.c | 2 - hw/pflash_cfi01.c | 2 - hw/pflash_cfi02.c | 2 - hw/pl031.c | 2 - hw/ppc.c | 7 - hw/ppc405_boards.c | 24 +-- hw/ppc405_uc.c | 422 ++++++++++++++++++++----------------------- hw/ppc440_bamboo.c | 2 - hw/ppc4xx_devs.c | 72 ++++---- hw/ppc4xx_pci.c | 2 - hw/ppc_prep.c | 2 - hw/r2d.c | 2 - hw/rc4030.c | 2 - hw/sb16.c | 5 - hw/sbi.c | 2 - hw/serial.c | 4 - hw/sh_intc.c | 4 +- hw/sh_serial.c | 2 - hw/slavio_intctl.c | 4 - hw/slavio_misc.c | 2 - hw/slavio_timer.c | 2 - hw/sparc32_dma.c | 2 - hw/sun4c_intctl.c | 2 - hw/tcx.c | 2 - hw/usb-bt.c | 2 - hw/usb-hid.c | 6 - hw/usb-hub.c | 2 - hw/usb-msd.c | 2 - hw/usb-net.c | 2 - hw/usb-serial.c | 2 - hw/usb-uhci.c | 15 +- hw/usb-wacom.c | 2 - hw/versatilepb.c | 2 - hw/vga.c | 4 - hw/virtio-blk.c | 3 +- hw/virtio.c | 3 +- hw/vmmouse.c | 2 - keymaps.c | 10 +- kvm-all.c | 7 - loader.c | 4 - migration-exec.c | 5 - migration-tcp.c | 2 - monitor.c | 4 - net.c | 14 -- qemu-char.c | 59 ------ qemu-malloc.c | 16 +- qemu-nbd.c | 2 - qemu-tool.c | 6 +- readline.c | 2 - savevm.c | 19 -- sdl.c | 2 - target-alpha/translate.c | 2 - target-arm/helper.c | 4 - target-cris/translate.c | 2 - target-i386/helper.c | 2 - target-i386/kvm.c | 2 - target-m68k/helper.c | 2 - target-mips/translate.c | 2 - target-ppc/helper.c | 2 - target-ppc/kvm_ppc.c | 4 - target-ppc/translate_init.c | 2 - target-sh4/translate.c | 2 - target-sparc/helper.c | 2 - usb-bsd.c | 2 - usb-linux.c | 24 +--- vl.c | 16 -- vnc.c | 9 +- 124 files changed, 314 insertions(+), 956 deletions(-)
PATCH 1/6 Terminate emulation on memory allocation failure
Memory allocation failures are a very rare condition on virtual-memory hosts. They are also very difficult to handle correctly (especially in a hardware emulation context). Because of this, it is better to gracefully terminate emulation rather than executing untested or even unwritten recovery code paths.
This patch changes the qemu memory allocation routines to terminate emulation if an allocation failure is encountered.
--- qemu-malloc.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)
qemu-malloc.c +10 -6
@@ -22,6 +22,14 @@* THE SOFTWARE. */ #include "qemu-common.h" +#include <stdlib.h> + +static void *oom_check (void *ptr) +{ +if (ptr ==NULL ) +exit (13 ); +return ptr; +}void *get_mmap_addr (unsigned long size) {
@@ -35,20 +43,18 @@ void qemu_free(void *ptr)void *qemu_malloc (size_t size) { -return malloc (size); +return oom_check (malloc (size)); }void *qemu_realloc (void *ptr,size_t size) { -return realloc (ptr, size); +return oom_check (realloc (ptr, size)); }void *qemu_mallocz (size_t size) {void *ptr; ptr =qemu_malloc (size); -if (!ptr) -return NULL ;memset (ptr,0 , size);return ptr; }
@@ -58,8 +64,6 @@ char *qemu_strdup(const char *str)char *ptr;size_t len =strlen (str); ptr =qemu_malloc (len +1 ); -if (!ptr) -return NULL ;memcpy (ptr, str, len +1 );return ptr; }
Signature · 1 line
1.6.1.1
Re: [Qemu-devel] [PATCH 1/6] Terminate emulation on memory allocation failure
Quoted 20 lines · Avi Kivity
Memory allocation failures are a very rare condition on virtual-memory hosts. They are also very difficult to handle correctly (especially in a hardware emulation context). Because of this, it is better to gracefully terminate emulation rather than executing untested or even unwritten recovery code paths.
This patch changes the qemu memory allocation routines to terminate emulation if an allocation failure is encountered.
Signed-off-by Avi Kivity <[email protected]>--- qemu-malloc.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)qemu-malloc.c +0
-0@@ -22,6 +22,14 @@* THE SOFTWARE.
qemu-malloc.c line 32
Quoted 10 lines
qemu-malloc.c +8
-0*/ #include "qemu-common.h" +#include <stdlib.h> + +static void *oom_check (void *ptr) +{ +if (ptr ==NULL ) +exit (13 ); +return ptr; +}
Will all our atexit handlers cope with OOM too? In particular we don't want them calling qemu_malloc again, or this becomes re-entrant. If we want to go down this route, then abort() is probably safer.
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Re: [Qemu-devel] [PATCH 1/6] Terminate emulation on memory allocation failure
Quoted 30 lines · Daniel P. Berrange
Quoted 28 lines · Avi Kivity
Memory allocation failures are a very rare condition on virtual-memory hosts. They are also very difficult to handle correctly (especially in a hardware emulation context). Because of this, it is better to gracefully terminate emulation rather than executing untested or even unwritten recovery code paths.
This patch changes the qemu memory allocation routines to terminate emulation if an allocation failure is encountered.
Signed-off-by Avi Kivity <[email protected]>--- qemu-malloc.c | 16 ++++++++++------ 1 files changed, 10 insertions(+), 6 deletions(-)qemu-malloc.c +6
-0@@ -22,6 +22,14 @@* THE SOFTWARE. */ #include "qemu-common.h" +#include <stdlib.h> + +static void *oom_check (void *ptr) +{ +if (ptr ==NULL ) +exit (13 );
Quoted 8 lines
qemu-malloc.c line 33
Quoted 3 lines
qemu-malloc.c +2
-0+return ptr; +}Will all our atexit handlers cope with OOM too? In particular we don't want them calling
qemu_mallocagain, or this becomes re-entrant. If we want to go down this route, thenabort()is probably safer.
abort() is a little messy in leaving a core file (which would likely fail anyway if we're out of memory).
Maybe _exit() is better here.
Even exit() will work; if we are unable to allocate in the exit handler, worst case we overflow the stack and crash.
In any case, I didn't see any calls to qemu_malloc() in existing atexit handlers.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [Qemu-devel] [PATCH 1/6] Terminate emulation on memory allocation failure
Avi Kivity writes ("Re: [Qemu-devel] [PATCH 1/6] Terminate emulation on memory allocation failure"):
Quoted 1 line
Maybe
_exit()is better here.
Yes, I think _exit is correct - although it might be useful to at least fflush stderr.
Ian.
PATCH 2/6 block: remove error handling from qemu_malloc() callers
In reply to Avi Kivity--- block-bochs.c | 2 - block-cloop.c | 9 ++----- block-dmg.c | 6 +--- block-parallels.c | 2 - block-qcow2.c | 58 +---------------------------------------------------- block-raw-posix.c | 2 - block-vmdk.c | 10 --------- block-vpc.c | 4 --- block-vvfat.c | 18 +++++++--------- block.c | 6 ----- 10 files changed, 14 insertions(+), 103 deletions(-)
block-bochs.c +0 -2
@@ -149,8 +149,6 @@ static int bochs_open(BlockDriverState *bs, const char *filename, int flags) s->catalog_size =le32_to_cpu (bochs.extra.redolog.catalog); s->catalog_bitmap =qemu_malloc (s->catalog_size *4 ); -if (!s->catalog_bitmap) - goto fail;if (read (s->fd, s->catalog_bitmap, s->catalog_size *4 ) != s->catalog_size *4 ) goto fail;
block-cloop.c +3 -6
@@ -75,8 +75,7 @@ cloop_close:/* read offsets */ offsets_size=s->n_blocks*sizeof (uint64_t ); -if (!(s->offsets=(uint64_t *)malloc (offsets_size))) - goto cloop_close; + s->offsets=(uint64_t *)qemu_malloc (offsets_size);if (read (s->fd,s->offsets,offsets_size)<offsets_size) goto cloop_close;for (i=0 ;i<s->n_blocks;i++) {
@@ -89,10 +88,8 @@ cloop_close: }/* initialize zlib engine */ -if (!(s->compressed_block =malloc (max_compressed_block_size+1 ))) - goto cloop_close; -if (!(s->uncompressed_block =malloc (s->block_size))) - goto cloop_close; + s->compressed_block =qemu_malloc (max_compressed_block_size+1 ); + s->uncompressed_block =qemu_malloc (s->block_size);if (inflateInit (&s->zstream) !=Z_OK ) goto cloop_close; s->current_block=s->n_blocks;
block-dmg.c +2 -4
@@ -159,10 +159,8 @@ dmg_close: }/* initialize zlib engine */ -if (!(s->compressed_chunk =malloc (max_compressed_size+1 ))) - goto dmg_close; -if (!(s->uncompressed_chunk =malloc (512 *max_sectors_per_chunk))) - goto dmg_close; + s->compressed_chunk =qemu_malloc (max_compressed_size+1 ); + s->uncompressed_chunk =qemu_malloc (512 *max_sectors_per_chunk);if (inflateInit (&s->zstream) !=Z_OK ) goto dmg_close;
block-parallels.c +0 -2
@@ -101,8 +101,6 @@ static int parallels_open(BlockDriverState *bs, const char *filename, int flags) s->catalog_size =le32_to_cpu (ph.catalog_entries); s->catalog_bitmap =qemu_malloc (s->catalog_size *4 ); -if (!s->catalog_bitmap) - goto fail;if (read (s->fd, s->catalog_bitmap, s->catalog_size *4 ) != s->catalog_size *4 ) goto fail;
block-qcow2.c +1 -57
191 lines not on this page · raw message
block-raw-posix.c +0 -2
@@ -533,8 +533,6 @@ static int posix_aio_init(void)return 0 ; s =qemu_malloc (sizeof (PosixAioState)); -if (s ==NULL ) -return -ENOMEM ;sigfillset (&act.sa_mask); act.sa_flags =0 ;/* do not restart syscalls to interrupt select() */
block-vmdk.c +0 -10
@@ -276,8 +276,6 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)/* write RGD */ rgd_buf =qemu_malloc (gd_size); -if (!rgd_buf) - goto fail;if (lseek (p_fd, rgd_offset,SEEK_SET ) ==-1 ) goto fail_rgd;if (read (p_fd, rgd_buf, gd_size) != gd_size)
@@ -290,8 +288,6 @@ static int vmdk_snapshot_create(const char *filename, const char *backing_file)/* write GD */ gd_buf =qemu_malloc (gd_size); -if (!gd_buf) - goto fail_rgd;if (lseek (p_fd, gd_offset,SEEK_SET ) ==-1 ) goto fail_gd;if (read (p_fd, gd_buf, gd_size) != gd_size)
@@ -430,8 +426,6 @@ static int vmdk_open(BlockDriverState *bs, const char *filename, int flags)/* read the L1 table */ l1_size = s->l1_size *sizeof (uint32_t ); s->l1_table =qemu_malloc (l1_size); -if (!s->l1_table) - goto fail;if (bdrv_pread (s->hd, s->l1_table_offset, s->l1_table, l1_size) != l1_size) goto fail;for (i =0 ; i < s->l1_size; i++) {
@@ -440,8 +434,6 @@ static int vmdk_open(BlockDriverState *bs, const char *filename, int flags)if (s->l1_backup_table_offset) { s->l1_backup_table =qemu_malloc (l1_size); -if (!s->l1_backup_table) - goto fail;if (bdrv_pread (s->hd, s->l1_backup_table_offset, s->l1_backup_table, l1_size) != l1_size) goto fail;for (i =0 ; i < s->l1_size; i++) {
@@ -450,8 +442,6 @@ static int vmdk_open(BlockDriverState *bs, const char *filename, int flags) } s->l2_cache =qemu_malloc (s->l2_size *L2_CACHE_SIZE *sizeof (uint32_t )); -if (!s->l2_cache) - goto fail;return 0 ; fail:qemu_free (s->l1_backup_table);
block-vpc.c +0 -4
@@ -196,8 +196,6 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags) s->max_table_entries =be32_to_cpu (dyndisk_header->max_table_entries); s->pagetable =qemu_malloc (s->max_table_entries *4 ); -if (!s->pagetable) - goto fail; s->bat_offset =be64_to_cpu (dyndisk_header->table_offset); if (bdrv_pread(s->hd, s->bat_offset, s->pagetable,
@@ -222,8 +220,6 @@ static int vpc_open(BlockDriverState *bs, const char *filename, int flags)#ifdef CACHE s->pageentry_u8 =qemu_malloc (512 ); -if (!s->pageentry_u8) - goto fail; s->pageentry_u32 = s->pageentry_u8; s->pageentry_u16 = s->pageentry_u8; s->last_pagetable =-1 ;
block-vvfat.c +8 -10
@@ -159,7 +159,7 @@ static inline int array_roll(array_t* array,int index_to,int index_from,int coun is=array->item_size; from=array->pointer+index_from*is; to=array->pointer+index_to*is; - buf=malloc (is*count); + buf=qemu_malloc (is*count);memcpy (buf,from,is*count);if (index_to<index_from)
@@ -725,8 +725,7 @@ static int read_directory(BDRVVVFATState* s, int mapping_index)if (first_cluster ==0 && (is_dotdot || is_dot))continue ; - buffer=(char *)malloc (length); -assert (buffer); + buffer=(char *)qemu_malloc (length);snprintf (buffer,length,"%s/%s" ,dirname,entry->d_name);if (stat (buffer,&st)<0 ) {
@@ -847,8 +846,7 @@ static int init_directories(BDRVVVFATState* s,memset (&(s->first_sectors[0 ]),0 ,0x40 *0x200 ); s->cluster_size=s->sectors_per_cluster*0x200 ; - s->cluster_buffer=malloc (s->cluster_size); -assert (s->cluster_buffer); + s->cluster_buffer=qemu_malloc (s->cluster_size);/* * The formula: sc = spf+1+spf*spc*(512*8/fat_type),
@@ -1728,7 +1726,7 @@ static int check_directory_consistency(BDRVVVFATState *s, int cluster_num, const char* path) { int ret = 0; -unsigned char * cluster =malloc (s->cluster_size); +unsigned char * cluster =qemu_malloc (s->cluster_size);direntry_t * direntries = (direntry_t *)cluster;mapping_t * mapping =find_mapping_for_cluster (s, cluster_num);
@@ -1869,7 +1867,7 @@ DLOG(checkpoint());*/ if (s->fat2 ==NULL ) {int size =0x200 * s->sectors_per_fat; - s->fat2 =malloc (size); + s->fat2 =qemu_malloc (size);memcpy (s->fat2, s->fat.pointer, size); } check = vvfat_read(s->bs,
@@ -2211,7 +2209,7 @@ static int commit_one_file(BDRVVVFATState* s,uint32_t first_cluster = c;mapping_t * mapping =find_mapping_for_cluster (s, c);uint32_t size =filesize_of_direntry (direntry); -char * cluster =malloc (s->cluster_size); +char * cluster =qemu_malloc (s->cluster_size);uint32_t i;int fd =0 ;
@@ -2373,7 +2371,7 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s)mapping_t * m =find_mapping_for_cluster (s,begin_of_direntry (d));int l =strlen (m->path); -char * new_path =malloc (l + diff +1 ); +char * new_path =qemu_malloc (l + diff +1 );assert (!strncmp (m->path, mapping->path, l2));
@@ -2774,7 +2772,7 @@ static int enable_write_target(BDRVVVFATState *s)array_init (&(s->commits),sizeof (commit_t)); - s->qcow_filename =malloc (1024 ); + s->qcow_filename =qemu_malloc (1024 );get_tmp_filename (s->qcow_filename,1024 );if (bdrv_create (&bdrv_qcow, s->qcow_filename, s->sector_count,"fat:" ,0 ) <0 )
block.c +0 -6
@@ -151,8 +151,6 @@ BlockDriverState *bdrv_new(const char *device_name)BlockDriverState **pbs, *bs; bs =qemu_mallocz (sizeof (BlockDriverState)); -if (!bs) -return NULL ;pstrcpy (bs->device_name,sizeof (bs->device_name), device_name);if (device_name[0 ] !='\0' ) {/* insert at the end */
@@ -395,8 +393,6 @@ int bdrv_open2(BlockDriverState *bs, const char *filename, int flags, } bs->drv = drv; bs->opaque =qemu_mallocz (drv->instance_size); -if (bs->opaque ==NULL && drv->instance_size >0 ) -return -1 ;/* Note: for compatibility, we open disk image files as RDWR, and RDONLY as fallback */ if (!(flags &BDRV_O_FILE ))
@@ -1498,8 +1494,6 @@ void *qemu_aio_get(BlockDriverState *bs, BlockDriverCompletionFunc *cb, drv->free_aiocb = acb->next; }else { acb =qemu_mallocz (drv->aiocb_size); -if (!acb) -return NULL ; } acb->bs = bs; acb->cb = cb;
Signature · 1 line
1.6.1.1
PATCH 3/6 audio: remove error handling from qemu_malloc() callers
In reply to Avi Kivity--- audio/audio.c | 23 ++++++++--------------- audio/wavcapture.c | 5 ----- 2 files changed, 8 insertions(+), 20 deletions(-)
audio/audio.c +8 -15
@@ -197,8 +197,8 @@ void *audio_calloc (const char *funcname, int nmemb, size_t size)static char *audio_alloc_prefix (const char *s) {const char qemu_prefix[] ="QEMU_" ; -size_t len; -char *r; +size_t len, i; +char *r, *u;if (!s) {return NULL ;
@@ -207,17 +207,15 @@ static char *audio_alloc_prefix (const char *s) len =strlen (s); r =qemu_malloc (len +sizeof (qemu_prefix)); -if (r) { -size_t i; -char *u = r +sizeof (qemu_prefix) -1 ; + u = r +sizeof (qemu_prefix) -1 ; -pstrcpy (r, len +sizeof (qemu_prefix), qemu_prefix); -pstrcat (r, len +sizeof (qemu_prefix), s); +pstrcpy (r, len +sizeof (qemu_prefix), qemu_prefix); +pstrcat (r, len +sizeof (qemu_prefix), s); -for (i =0 ; i < len; ++i) { - u[i] =qemu_toupper (u[i]); - } +for (i =0 ; i < len; ++i) { + u[i] =qemu_toupper (u[i]); } +return r; }
@@ -460,11 +458,6 @@ static void audio_process_options (const char *prefix,* sizeof) */ optlen = len + preflen +sizeof (qemu_prefix) +1 ; optname =qemu_malloc (optlen); -if (!optname) { -dolog ("Could not allocate memory for option name `%s'\n" , - opt->name); -continue ; - }pstrcpy (optname, optlen, qemu_prefix);
audio/wavcapture.c +0 -5
@@ -120,11 +120,6 @@ int wav_start_capture (CaptureState *s, const char *path, int freq, ops.destroy = wav_destroy; wav =qemu_mallocz (sizeof (*wav)); -if (!wav) { -term_printf ("Could not allocate memory for wav capture (%zu bytes)" , -sizeof (*wav)); -return -1 ; - } shift = bits16 + stereo; hdr[34 ] = bits16 ?0x10 :0x08 ;
Signature · 1 line
1.6.1.1
PATCH 4/6 hw: remove error handling from qemu_malloc() callers
In reply to Avi Kivity--- hw/adlib.c | 7 - hw/apic.c | 4 - hw/arm_gic.c | 2 - hw/arm_sysctl.c | 2 - hw/baum.c | 10 -- hw/cs4231.c | 2 - hw/cs4231a.c | 5 - hw/ds1225y.c | 5 - hw/eccmemctl.c | 2 - hw/escc.c | 4 - hw/esp.c | 2 - hw/etraxfs_dma.c | 8 - hw/etraxfs_eth.c | 8 - hw/etraxfs_pic.c | 6 - hw/etraxfs_ser.c | 2 - hw/etraxfs_timer.c | 2 - hw/fdc.c | 6 - hw/fmopl.c | 27 +--- hw/fw_cfg.c | 8 - hw/g364fb.c | 2 - hw/gus.c | 11 -- hw/i8259.c | 2 - hw/ide.c | 2 - hw/integratorcp.c | 2 - hw/iommu.c | 2 - hw/jazz_led.c | 2 - hw/m48t59.c | 6 - hw/mac_dbdma.c | 2 - hw/mac_nvram.c | 6 - hw/mc146818rtc.c | 4 - hw/mipsnet.c | 2 - hw/mpcore.c | 2 - hw/mst_fpga.c | 2 - hw/musicpal.c | 14 -- hw/ne2000.c | 2 - hw/parallel.c | 4 - hw/pci.c | 2 - hw/pcnet.c | 2 - hw/pflash_cfi01.c | 2 - hw/pflash_cfi02.c | 2 - hw/pl031.c | 2 - hw/ppc.c | 7 - hw/ppc405_boards.c | 24 ++-- hw/ppc405_uc.c | 422 ++++++++++++++++++++++++--------------------------- hw/ppc440_bamboo.c | 2 - hw/ppc4xx_devs.c | 72 ++++----- hw/ppc4xx_pci.c | 2 - hw/ppc_prep.c | 2 - hw/r2d.c | 2 - hw/rc4030.c | 2 - hw/sb16.c | 5 - hw/sbi.c | 2 - hw/serial.c | 4 - hw/sh_intc.c | 4 +- hw/sh_serial.c | 2 - hw/slavio_intctl.c | 4 - hw/slavio_misc.c | 2 - hw/slavio_timer.c | 2 - hw/sparc32_dma.c | 2 - hw/sun4c_intctl.c | 2 - hw/tcx.c | 2 - hw/usb-bt.c | 2 - hw/usb-hid.c | 6 - hw/usb-hub.c | 2 - hw/usb-msd.c | 2 - hw/usb-net.c | 2 - hw/usb-serial.c | 2 - hw/usb-uhci.c | 15 +- hw/usb-wacom.c | 2 - hw/versatilepb.c | 2 - hw/vga.c | 4 - hw/virtio-blk.c | 3 +- hw/virtio.c | 3 +- hw/vmmouse.c | 2 - 74 files changed, 257 insertions(+), 545 deletions(-)
hw/adlib.c +0 -7
@@ -331,13 +331,6 @@ int Adlib_init (AudioState *audio, qemu_irq *pic) s->samples =AUD_get_buffer_size_out (s->voice) >>SHIFT ; s->mixbuf =qemu_mallocz (s->samples <<SHIFT ); -if (!s->mixbuf) { -dolog ("Could not allocate mixing buffer, %d samples (each %d bytes)\n" , - s->samples,1 <<SHIFT ); -Adlib_fini (s); -return -1 ; - } -register_ioport_read (0x388 ,4 ,1 , adlib_read, s);register_ioport_write (0x388 ,4 ,1 , adlib_write, s);
hw/apic.c +0 -4
@@ -898,8 +898,6 @@ int apic_init(CPUState *env)if (last_apic_id >=MAX_APICS )return -1 ; s =qemu_mallocz (sizeof (APICState)); -if (!s) -return -1 ; env->apic_state = s; s->id = last_apic_id++; env->cpuid_apic_id = s->id;
@@ -1124,8 +1122,6 @@ IOAPICState *ioapic_init(void)int io_memory; s =qemu_mallocz (sizeof (IOAPICState)); -if (!s) -return NULL ;ioapic_reset (s); s->id = last_apic_id++;
hw/arm_gic.c +0 -2
@@ -725,8 +725,6 @@ static gic_state *gic_init(uint32_t dist_base, qemu_irq *parent_irq)int i; s = (gic_state *)qemu_mallocz (sizeof (gic_state)); -if (!s) -return NULL ; s->in =qemu_allocate_irqs (gic_set_irq, s,GIC_NIRQ );for (i =0 ; i <NCPU ; i++) { s->parent_irq[i] = parent_irq[i];
hw/arm_sysctl.c +0 -2
@@ -194,8 +194,6 @@ void arm_sysctl_init(uint32_t base, uint32_t sys_id)int iomemtype; s = (arm_sysctl_state *)qemu_mallocz (sizeof (arm_sysctl_state)); -if (!s) -return ; s->sys_id = sys_id;/* The MPcore bootloader uses these flags to start secondary CPUs. We don't use a bootloader, so do this here. */
hw/baum.c +0 -10
@@ -575,12 +575,7 @@ CharDriverState *chr_baum_init(void)int tty; baum =qemu_mallocz (sizeof (BaumDriverState)); -if (!baum) -return NULL ; - baum->chr = chr =qemu_mallocz (sizeof (CharDriverState)); -if (!chr) - goto fail_baum; chr->opaque = baum; chr->chr_write = baum_write;
@@ -588,8 +583,6 @@ CharDriverState *chr_baum_init(void) chr->chr_accept_input = baum_accept_input; handle =qemu_mallocz (brlapi_getHandleSize ()); -if (!handle) - goto fail_chr; baum->brlapi = handle; baum->brlapi_fd =brlapi__openConnection (handle,NULL ,NULL );
@@ -628,11 +621,8 @@ CharDriverState *chr_baum_init(void) fail:qemu_free_timer (baum->cellCount_timer);brlapi__closeConnection (handle); -fail_handle:free (handle); -fail_chr:free (chr); -fail_baum:free (baum);return NULL ; }
hw/cs4231.c +0 -2
@@ -171,8 +171,6 @@ void cs_init(target_phys_addr_t base, int irq, void *intctl)CSState *s; s =qemu_mallocz (sizeof (CSState)); -if (!s) -return ; cs_io_memory =cpu_register_io_memory (0 , cs_mem_read, cs_mem_write, s);cpu_register_physical_memory (base,CS_SIZE , cs_io_memory);
hw/cs4231a.c +0 -5
@@ -647,11 +647,6 @@ int cs4231a_init (AudioState *audio, qemu_irq *pic) } s =qemu_mallocz (sizeof (*s)); -if (!s) { -lerr ("Could not allocate memory for cs4231a (%zu bytes)\n" , -sizeof (*s)); -return -1 ; - } s->pic = pic; s->irq = conf.irq;
hw/ds1225y.c +0 -5
@@ -152,13 +152,8 @@ void *ds1225y_init(target_phys_addr_t mem_base, const char *filename)QEMUFile *file; s =qemu_mallocz (sizeof (ds1225y_t)); -if (!s) -return NULL ; s->chip_size =0x2000 ;/* Fixed for ds1225y chip: 8 KiB */ s->contents =qemu_mallocz (s->chip_size); -if (!s->contents) { -return NULL ; - } s->protection =7 ;/* Read current file */
hw/eccmemctl.c +0 -2
@@ -320,8 +320,6 @@ void * ecc_init(target_phys_addr_t base, qemu_irq irq, uint32_t version)ECCState *s; s =qemu_mallocz (sizeof (ECCState)); -if (!s) -return NULL ; s->version = version; s->regs[0 ] = version;
hw/escc.c +0 -4
@@ -727,8 +727,6 @@ int escc_init(target_phys_addr_t base, qemu_irq irqA, qemu_irq irqB,SerialState *s; s =qemu_mallocz (sizeof (SerialState)); -if (!s) -return 0 ; escc_io_memory = cpu_register_io_memory(0, escc_mem_read, escc_mem_write,
@@ -909,8 +907,6 @@ void slavio_serial_ms_kbd_init(target_phys_addr_t base, qemu_irq irq,SerialState *s; s =qemu_mallocz (sizeof (SerialState)); -if (!s) -return ; s->it_shift = it_shift;for (i =0 ; i <2 ; i++) {
hw/esp.c +0 -2
@@ -653,8 +653,6 @@ void *esp_init(target_phys_addr_t espaddr, int it_shift,int esp_io_memory; s =qemu_mallocz (sizeof (ESPState)); -if (!s) -return NULL ; s->irq = irq; s->it_shift = it_shift;
hw/etraxfs_dma.c +0 -8
@@ -756,22 +756,14 @@ void *etraxfs_dmac_init(CPUState *env,struct fs_dma_ctrl *ctrl =NULL ; ctrl =qemu_mallocz (sizeof *ctrl); -if (!ctrl) -return NULL ; ctrl->bh =qemu_bh_new (DMA_run, ctrl); ctrl->env = env; ctrl->nr_channels = nr_channels; ctrl->channels =qemu_mallocz (sizeof ctrl->channels[0 ] * nr_channels); -if (!ctrl->channels) - goto err; ctrl->map =cpu_register_io_memory (0 , dma_read, dma_write, ctrl);cpu_register_physical_memory (base, nr_channels *0x2000 , ctrl->map);return ctrl; - err: -qemu_free (ctrl->channels); -qemu_free (ctrl); -return NULL ; }
hw/etraxfs_eth.c +0 -8
@@ -564,12 +564,8 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,qemu_check_nic_model (nd,"fseth" ); dma =qemu_mallocz (sizeof *dma *2 ); -if (!dma) -return NULL ; eth =qemu_mallocz (sizeof *eth); -if (!eth) - goto err; dma[0 ].client.push = eth_tx_push; dma[0 ].client.opaque = eth;
@@ -595,8 +591,4 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env, eth->vc->link_status_changed = eth_set_link;return dma; - err: -qemu_free (eth); -qemu_free (dma); -return NULL ; }
hw/etraxfs_pic.c +0 -6
@@ -192,8 +192,6 @@ struct etraxfs_pic *etraxfs_pic_init(CPUState *env, target_phys_addr_t base) pic =qemu_mallocz (sizeof *pic); pic->internal = fs =qemu_mallocz (sizeof *fs); -if (!fs || !pic) - goto err; fs->env = env; pic->irq =qemu_allocate_irqs (irq_handler, fs,30 );
@@ -204,8 +202,4 @@ struct etraxfs_pic *etraxfs_pic_init(CPUState *env, target_phys_addr_t base)cpu_register_physical_memory (base,0x14 , intr_vect_regs);return pic; - err: -free (pic); -free (fs); -return NULL ; }
hw/etraxfs_ser.c +0 -2
@@ -233,8 +233,6 @@ void etraxfs_ser_init(CPUState *env, qemu_irq *irq, CharDriverState *chr,int ser_regs; s =qemu_mallocz (sizeof *s); -if (!s) -return ; s->env = env; s->irq = irq;
hw/etraxfs_timer.c +0 -2
@@ -321,8 +321,6 @@ void etraxfs_timer_init(CPUState *env, qemu_irq *irqs, qemu_irq *nmi,int timer_regs; t =qemu_mallocz (sizeof *t); -if (!t) -return ; t->bh_t0 =qemu_bh_new (timer0_hit, t); t->bh_t1 =qemu_bh_new (timer1_hit, t);
hw/fdc.c +0 -6
@@ -1866,13 +1866,7 @@ static fdctrl_t *fdctrl_init_common (qemu_irq irq, int dma_chann,FLOPPY_DPRINTF ("init controller\n" ); fdctrl =qemu_mallocz (sizeof (fdctrl_t)); -if (!fdctrl) -return NULL ; fdctrl->fifo =qemu_memalign (512 ,FD_SECTOR_LEN ); -if (fdctrl->fifo ==NULL ) { -qemu_free (fdctrl); -return NULL ; - } fdctrl->result_timer =qemu_new_timer (vm_clock, fdctrl_result_timer, fdctrl);
hw/fmopl.c +5 -22
@@ -619,26 +619,10 @@ static int OPLOpenTable( void )double pom;/* allocate dynamic tables */ -if ( (TL_TABLE =malloc (TL_MAX *2 *sizeof (INT32 ))) ==NULL ) -return 0 ; -if ( (SIN_TABLE =malloc (SIN_ENT *4 *sizeof (INT32 *))) ==NULL ) - { -free (TL_TABLE ); -return 0 ; - } -if ( (AMS_TABLE =malloc (AMS_ENT *2 *sizeof (INT32 ))) ==NULL ) - { -free (TL_TABLE ); -free (SIN_TABLE ); -return 0 ; - } -if ( (VIB_TABLE =malloc (VIB_ENT *2 *sizeof (INT32 ))) ==NULL ) - { -free (TL_TABLE ); -free (SIN_TABLE ); -free (AMS_TABLE ); -return 0 ; - } +TL_TABLE =qemu_malloc (TL_MAX *2 *sizeof (INT32 )); +SIN_TABLE =qemu_malloc (SIN_ENT *4 *sizeof (INT32 *)); +AMS_TABLE =qemu_malloc (AMS_ENT *2 *sizeof (INT32 )); +VIB_TABLE =qemu_malloc (VIB_ENT *2 *sizeof (INT32 ));/* make total level table */ for (t =0 ;t <EG_ENT -1 ;t++){ rate = ((1 <<TL_BITS )-1 )/pow (10 ,EG_STEP *t/20 );/* dB -> voltage */
@@ -1221,8 +1205,7 @@ FM_OPL *OPLCreate(int type, int clock, int rate)if (type&OPL_TYPE_ADPCM ) state_size+=sizeof (YM_DELTAT );#endif /* allocate memory block */ - ptr =malloc (state_size); -if (ptr==NULL )return NULL ; + ptr =qemu_malloc (state_size);/* clear */ memset (ptr,0 ,state_size);OPL = (FM_OPL *)ptr; ptr+=sizeof (FM_OPL );
hw/fw_cfg.c +0 -8
@@ -206,8 +206,6 @@ int fw_cfg_add_i16(void *opaque, uint16_t key, uint16_t value)uint16_t *copy; copy =qemu_malloc (sizeof (value)); -if (!copy) -return 0 ; *copy =cpu_to_le16 (value);return fw_cfg_add_bytes (opaque, key, (uint8_t *)copy,sizeof (value)); }
@@ -217,8 +215,6 @@ int fw_cfg_add_i32(void *opaque, uint16_t key, uint32_t value)uint32_t *copy; copy =qemu_malloc (sizeof (value)); -if (!copy) -return 0 ; *copy =cpu_to_le32 (value);return fw_cfg_add_bytes (opaque, key, (uint8_t *)copy,sizeof (value)); }
@@ -228,8 +224,6 @@ int fw_cfg_add_i64(void *opaque, uint16_t key, uint64_t value)uint64_t *copy; copy =qemu_malloc (sizeof (value)); -if (!copy) -return 0 ; *copy =cpu_to_le64 (value);return fw_cfg_add_bytes (opaque, key, (uint8_t *)copy,sizeof (value)); }
@@ -263,8 +257,6 @@ void *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,int io_ctl_memory, io_data_memory; s =qemu_mallocz (sizeof (FWCfgState)); -if (!s) -return NULL ;if (ctl_port) {register_ioport_write (ctl_port,2 ,2 , fw_cfg_io_writew, s);
hw/g364fb.c +0 -2
@@ -593,8 +593,6 @@ int g364fb_mm_init(uint8_t *vram, ram_addr_t vram_offset,int io_ctrl; s =qemu_mallocz (sizeof (G364State)); -if (!s) -return -1 ; s->vram = vram; s->vram_offset = vram_offset;
hw/gus.c +0 -11
@@ -261,11 +261,6 @@ int GUS_init (AudioState *audio, qemu_irq *pic) } s =qemu_mallocz (sizeof (*s)); -if (!s) { -dolog ("Could not allocate memory for GUS (%zu bytes)\n" , -sizeof (*s)); -return -1 ; - }AUD_register_card (audio,"gus" , &s->card);
@@ -292,12 +287,6 @@ int GUS_init (AudioState *audio, qemu_irq *pic) s->shift =2 ; s->samples =AUD_get_buffer_size_out (s->voice) >> s->shift; s->mixbuf =qemu_mallocz (s->samples << s->shift); -if (!s->mixbuf) { -AUD_close_out (&s->card, s->voice); -AUD_remove_card (&s->card); -qemu_free (s); -return -1 ; - }register_ioport_write (conf.port,1 ,1 , gus_writeb, s);register_ioport_write (conf.port,1 ,2 , gus_writew, s);
hw/i8259.c +0 -2
@@ -550,8 +550,6 @@ qemu_irq *i8259_init(qemu_irq parent_irq)PicState2 *s; s =qemu_mallocz (sizeof (PicState2)); -if (!s) -return NULL ;pic_init1 (0x20 ,0x4d0 , &s->pics[0 ]);pic_init1 (0xa0 ,0x4d1 , &s->pics[1 ]); s->pics[0 ].elcr_mask =0xf8 ;
hw/ide.c +0 -2
@@ -2951,8 +2951,6 @@ void isa_ide_init(int iobase, int iobase2, qemu_irq irq,IDEState *ide_state; ide_state =qemu_mallocz (sizeof (IDEState) *2 ); -if (!ide_state) -return ;ide_init2 (ide_state, hd0, hd1, irq);ide_init_ioport (ide_state, iobase, iobase2);
hw/integratorcp.c +0 -2
@@ -378,8 +378,6 @@ static qemu_irq *icp_pic_init(uint32_t base,qemu_irq *qi; s = (icp_pic_state *)qemu_mallocz (sizeof (icp_pic_state)); -if (!s) -return NULL ; qi =qemu_allocate_irqs (icp_pic_set_irq, s,32 ); s->parent_irq = parent_irq; s->parent_fiq = parent_fiq;
hw/iommu.c +0 -2
@@ -371,8 +371,6 @@ void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)int iommu_io_memory; s =qemu_mallocz (sizeof (IOMMUState)); -if (!s) -return NULL ; s->version = version; s->irq = irq;
hw/jazz_led.c +0 -2
@@ -304,8 +304,6 @@ void jazz_led_init(target_phys_addr_t base)int io; s =qemu_mallocz (sizeof (LedState)); -if (!s) -return ; s->state =REDRAW_SEGMENTS |REDRAW_BACKGROUND ;
hw/m48t59.c +0 -6
@@ -622,13 +622,7 @@ m48t59_t *m48t59_init (qemu_irq IRQ, target_phys_addr_t mem_base,target_phys_addr_t save_base; s =qemu_mallocz (sizeof (m48t59_t)); -if (!s) -return NULL ; s->buffer =qemu_mallocz (size); -if (!s->buffer) { -qemu_free (s); -return NULL ; - } s->IRQ =IRQ ; s->size = size; s->io_base = io_base;
hw/mac_dbdma.c +0 -2
@@ -865,8 +865,6 @@ void* DBDMA_init (int *dbdma_mem_index)DBDMA_channel *s; s =qemu_mallocz (sizeof (DBDMA_channel) *DBDMA_CHANNELS ); -if (!s) -return NULL ; *dbdma_mem_index =cpu_register_io_memory (0 , dbdma_read, dbdma_write, s);register_savevm ("dbdma" ,-1 ,1 , dbdma_save, dbdma_load, s);
hw/mac_nvram.c +0 -6
@@ -132,13 +132,7 @@ MacIONVRAMState *macio_nvram_init (int *mem_index, target_phys_addr_t size)MacIONVRAMState *s; s =qemu_mallocz (sizeof (MacIONVRAMState)); -if (!s) -return NULL ; s->data =qemu_mallocz (size); -if (!s->data) { -qemu_free (s); -return NULL ; - } s->size = size; s->mem_index =cpu_register_io_memory (0 , nvram_read, nvram_write, s);
hw/mc146818rtc.c +0 -4
@@ -532,8 +532,6 @@ RTCState *rtc_init(int base, qemu_irq irq, int base_year)RTCState *s; s =qemu_mallocz (sizeof (RTCState)); -if (!s) -return NULL ; s->irq = irq; s->cmos_data[RTC_REG_A ] =0x26 ;
@@ -644,8 +642,6 @@ RTCState *rtc_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,int io_memory; s =qemu_mallocz (sizeof (RTCState)); -if (!s) -return NULL ; s->irq = irq; s->cmos_data[RTC_REG_A ] =0x26 ;
hw/mipsnet.c +0 -2
@@ -239,8 +239,6 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)qemu_check_nic_model (nd,"mipsnet" ); s =qemu_mallocz (sizeof (MIPSnetState)); -if (!s) -return ;register_ioport_write (base,36 ,1 , mipsnet_ioport_write, s);register_ioport_read (base,36 ,1 , mipsnet_ioport_read, s);
hw/mpcore.c +0 -2
@@ -265,8 +265,6 @@ static qemu_irq *mpcore_priv_init(uint32_t base, qemu_irq *pic_irq)int i; s = (mpcore_priv_state *)qemu_mallocz (sizeof (mpcore_priv_state)); -if (!s) -return NULL ; s->gic =gic_init (base +0x1000 , pic_irq);if (!s->gic)return NULL ;
hw/mst_fpga.c +0 -2
@@ -225,8 +225,6 @@ qemu_irq *mst_irq_init(struct pxa2xx_state_s *cpu, uint32_t base, int irq) s = (mst_irq_state *)qemu_mallocz (sizeof (mst_irq_state)); -if (!s) -return NULL ; s->parent = &cpu->pic[irq];/* alloc the external 16 irqs */
hw/musicpal.c +0 -14
@@ -443,13 +443,9 @@ static i2c_interface *musicpal_audio_init(uint32_t base, qemu_irq irq) } s =qemu_mallocz (sizeof (musicpal_audio_state)); -if (!s) -return NULL ; s->irq = irq; i2c =qemu_mallocz (sizeof (i2c_interface)); -if (!i2c) -return NULL ; i2c->bus =i2c_init_bus (); i2c->current_addr =-1 ;
@@ -717,8 +713,6 @@ static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq)qemu_check_nic_model (nd,"mv88w8618" ); s =qemu_mallocz (sizeof (mv88w8618_eth_state)); -if (!s) -return ; s->irq = irq; s->vc =qemu_new_vlan_client (nd->vlan, nd->model, nd->name, eth_receive, eth_can_receive, s);
@@ -911,8 +905,6 @@ static void musicpal_lcd_init(uint32_t base)int iomemtype; s =qemu_mallocz (sizeof (musicpal_lcd_state)); -if (!s) -return ; iomemtype =cpu_register_io_memory (0 , musicpal_lcd_readfn, musicpal_lcd_writefn, s);cpu_register_physical_memory (base,MP_LCD_SIZE , iomemtype);
@@ -1008,8 +1000,6 @@ static qemu_irq *mv88w8618_pic_init(uint32_t base, qemu_irq parent_irq)qemu_irq *qi; s =qemu_mallocz (sizeof (mv88w8618_pic_state)); -if (!s) -return NULL ; qi =qemu_allocate_irqs (mv88w8618_pic_set_irq, s,32 ); s->parent_irq = parent_irq; iomemtype = cpu_register_io_memory(0, mv88w8618_pic_readfn,
@@ -1134,8 +1124,6 @@ static void mv88w8618_pit_init(uint32_t base, qemu_irq *pic, int irq)mv88w8618_pit_state *s; s =qemu_mallocz (sizeof (mv88w8618_pit_state)); -if (!s) -return ;/* Letting them all run at 1 MHz is likely just a pragmatic * simplification. */
@@ -1200,8 +1188,6 @@ static void mv88w8618_flashcfg_init(uint32_t base)mv88w8618_flashcfg_state *s; s =qemu_mallocz (sizeof (mv88w8618_flashcfg_state)); -if (!s) -return ; s->cfgr0 =0xfffe4285 ;/* Default as set by U-Boot for 8 MB flash */ iomemtype = cpu_register_io_memory(0, mv88w8618_flashcfg_readfn,
hw/ne2000.c +0 -2
@@ -725,8 +725,6 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)qemu_check_nic_model (nd,"ne2k_isa" ); s =qemu_mallocz (sizeof (NE2000State)); -if (!s) -return ;register_ioport_write (base,16 ,1 , ne2000_ioport_write, s);register_ioport_read (base,16 ,1 , ne2000_ioport_read, s);
hw/parallel.c +0 -4
@@ -445,8 +445,6 @@ ParallelState *parallel_init(int base, qemu_irq irq, CharDriverState *chr)uint8_t dummy; s =qemu_mallocz (sizeof (ParallelState)); -if (!s) -return NULL ; s->irq = irq; s->chr = chr;parallel_reset (s);
@@ -539,8 +537,6 @@ ParallelState *parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irqint io_sw; s =qemu_mallocz (sizeof (ParallelState)); -if (!s) -return NULL ; s->irq = irq; s->chr = chr; s->it_shift = it_shift;
hw/pci.c +0 -2
@@ -178,8 +178,6 @@ PCIDevice *pci_register_device(PCIBus *bus, const char *name, found: ; } pci_dev =qemu_mallocz (instance_size); -if (!pci_dev) -return NULL ; pci_dev->bus = bus; pci_dev->devfn = devfn;pstrcpy (pci_dev->name,sizeof (pci_dev->name), name);
hw/pcnet.c +0 -2
@@ -2089,8 +2089,6 @@ void lance_init(NICInfo *nd, target_phys_addr_t leaddr, void *dma_opaque,qemu_check_nic_model (nd,"lance" ); d =qemu_mallocz (sizeof (PCNetState)); -if (!d) -return ; lance_io_memory =cpu_register_io_memory (0 , lance_mem_read, lance_mem_write, d);
hw/pflash_cfi01.c +0 -2
@@ -519,8 +519,6 @@ pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off, pfl =qemu_mallocz (sizeof (pflash_t)); -if (pfl ==NULL ) -return NULL ; pfl->storage = phys_ram_base + off; pfl->fl_mem =cpu_register_io_memory (0 , pflash_read_ops, pflash_write_ops, pfl);
hw/pflash_cfi02.c +0 -2
@@ -557,8 +557,6 @@ pflash_t *pflash_cfi02_register(target_phys_addr_t base, ram_addr_t off,return NULL ;#endif pfl =qemu_mallocz (sizeof (pflash_t)); -if (pfl ==NULL ) -return NULL ; pfl->storage = phys_ram_base + off; pfl->fl_mem =cpu_register_io_memory (0 , pflash_read_ops, pflash_write_ops, pfl);
hw/pl031.c +0 -2
@@ -193,8 +193,6 @@ void pl031_init(uint32_t base, qemu_irq irq)struct tm tm; s =qemu_mallocz (sizeof (pl031_state)); -if (!s) -cpu_abort (cpu_single_env,"pl031_init: Out of memory\n" ); iomemtype =cpu_register_io_memory (0 , pl031_readfn, pl031_writefn, s);if (iomemtype ==-1 )
hw/ppc.c +0 -7
@@ -645,8 +645,6 @@ clk_setup_cb cpu_ppc_tb_init (CPUState *env, uint32_t freq)ppc_tb_t *tb_env; tb_env =qemu_mallocz (sizeof (ppc_tb_t)); -if (tb_env ==NULL ) -return NULL ; env->tb_env = tb_env;/* Create new timer */ tb_env->decr_timer =qemu_new_timer (vm_clock, &cpu_ppc_decr_cb, env);
@@ -915,9 +913,6 @@ clk_setup_cb ppc_emb_timers_init (CPUState *env, uint32_t freq)ppcemb_timer_t *ppcemb_timer; tb_env =qemu_mallocz (sizeof (ppc_tb_t)); -if (tb_env ==NULL ) { -return NULL ; - } env->tb_env = tb_env; ppcemb_timer =qemu_mallocz (sizeof (ppcemb_timer_t)); tb_env->tb_freq = freq;
@@ -1024,8 +1019,6 @@ int ppc_dcr_init (CPUState *env, int (*read_error)(int dcrn),ppc_dcr_t *dcr_env; dcr_env =qemu_mallocz (sizeof (ppc_dcr_t)); -if (dcr_env ==NULL ) -return -1 ; dcr_env->read_error = read_error; dcr_env->write_error = write_error; env->dcr_env = dcr_env;
hw/ppc405_boards.c +10 -14
@@ -162,13 +162,11 @@ static void ref405ep_fpga_init (uint32_t base)int fpga_memory; fpga =qemu_mallocz (sizeof (ref405ep_fpga_t)); -if (fpga !=NULL ) { - fpga_memory =cpu_register_io_memory (0 , ref405ep_fpga_read, - ref405ep_fpga_write, fpga); -cpu_register_physical_memory (base,0x00000100 , fpga_memory); -ref405ep_fpga_reset (fpga); -qemu_register_reset (&ref405ep_fpga_reset, fpga); - } + fpga_memory =cpu_register_io_memory (0 , ref405ep_fpga_read, + ref405ep_fpga_write, fpga); +cpu_register_physical_memory (base,0x00000100 , fpga_memory); +ref405ep_fpga_reset (fpga); +qemu_register_reset (&ref405ep_fpga_reset, fpga); } static void ref405ep_init (ram_addr_t ram_size, int vga_ram_size,
@@ -486,13 +484,11 @@ static void taihu_cpld_init (uint32_t base)int cpld_memory; cpld =qemu_mallocz (sizeof (taihu_cpld_t)); -if (cpld !=NULL ) { - cpld_memory =cpu_register_io_memory (0 , taihu_cpld_read, - taihu_cpld_write, cpld); -cpu_register_physical_memory (base,0x00000100 , cpld_memory); -taihu_cpld_reset (cpld); -qemu_register_reset (&taihu_cpld_reset, cpld); - } + cpld_memory =cpu_register_io_memory (0 , taihu_cpld_read, + taihu_cpld_write, cpld); +cpu_register_physical_memory (base,0x00000100 , cpld_memory); +taihu_cpld_reset (cpld); +qemu_register_reset (&taihu_cpld_reset, cpld); } static void taihu_405ep_init(ram_addr_t ram_size, int vga_ram_size,
hw/ppc405_uc.c +199 -223
504 lines not on this page · raw message
hw/ppc440_bamboo.c +0 -2
@@ -42,8 +42,6 @@ static void *bamboo_load_device_tree(void *addr, pathlen =snprintf (NULL ,0 ,"%s/%s" , bios_dir,BINARY_DEVICE_TREE_FILE ) +1 ; path =qemu_malloc (pathlen); -if (path ==NULL ) -return NULL ;snprintf (path, pathlen,"%s/%s" , bios_dir,BINARY_DEVICE_TREE_FILE );
hw/ppc4xx_devs.c +33 -39
93 lines not on this page · raw message
hw/ppc4xx_pci.c +0 -2
@@ -369,8 +369,6 @@ PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],uint8_t *pci_conf; controller =qemu_mallocz (sizeof (PPC4xxPCIState)); -if (!controller) -return NULL ; controller->pci_state.bus = pci_register_bus(ppc4xx_pci_set_irq, ppc4xx_pci_map_irq,
hw/ppc_prep.c +0 -2
@@ -553,8 +553,6 @@ static void ppc_prep_init (ram_addr_t ram_size, int vga_ram_size,BlockDriverState *fd[MAX_FD ]; sysctrl =qemu_mallocz (sizeof (sysctrl_t)); -if (sysctrl ==NULL ) -return ; linux_boot = (kernel_filename !=NULL );
hw/r2d.c +0 -2
@@ -170,8 +170,6 @@ static qemu_irq *r2d_fpga_init(target_phys_addr_t base, qemu_irq irl)r2d_fpga_t *s; s =qemu_mallocz (sizeof (r2d_fpga_t)); -if (!s) -return NULL ; s->irl = irl;
hw/rc4030.c +0 -2
@@ -718,8 +718,6 @@ qemu_irq *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,int s_chipset, s_jazzio; s =qemu_mallocz (sizeof (rc4030State)); -if (!s) -return NULL ; *dmas =rc4030_allocate_dmas (s,4 ); *dma_read = rc4030_dma_read;
hw/sb16.c +0 -5
@@ -1411,11 +1411,6 @@ int SB16_init (AudioState *audio, qemu_irq *pic) } s =qemu_mallocz (sizeof (*s)); -if (!s) { -dolog ("Could not allocate memory for SB16 (%zu bytes)\n" , -sizeof (*s)); -return -1 ; - } s->cmd =-1 ; s->pic = pic;
hw/sbi.c +0 -2
@@ -146,8 +146,6 @@ void *sbi_init(target_phys_addr_t addr, qemu_irq **irq, qemu_irq **cpu_irq,SBIState *s; s =qemu_mallocz (sizeof (SBIState)); -if (!s) -return NULL ;for (i =0 ; i <MAX_CPUS ; i++) { s->cpu_irqs[i] = parent_irq[i];
hw/serial.c +0 -4
@@ -732,8 +732,6 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase,SerialState *s; s =qemu_mallocz (sizeof (SerialState)); -if (!s) -return NULL ;serial_init_core (s, irq, baudbase, chr);
@@ -824,8 +822,6 @@ SerialState *serial_mm_init (target_phys_addr_t base, int it_shift,int s_io_memory; s =qemu_mallocz (sizeof (SerialState)); -if (!s) -return NULL ; s->it_shift = it_shift;
hw/sh_intc.c +1 -3
@@ -432,9 +432,7 @@ int sh_intc_init(struct intc_desc *desc, desc->nr_prio_regs = nr_prio_regs; i =sizeof (struct intc_source ) * nr_sources; - desc->sources =malloc (i); -if (!desc->sources) -return -1 ; + desc->sources =qemu_malloc (i);memset (desc->sources,0 , i);for (i =0 ; i < desc->nr_sources; i++) {
hw/sh_serial.c +0 -2
@@ -376,8 +376,6 @@ void sh_serial_init (target_phys_addr_t base, int feat,int s_io_memory; s =qemu_mallocz (sizeof (sh_serial_state)); -if (!s) -return ; s->feat = feat; s->flags =SH_SERIAL_FLAG_TEND |SH_SERIAL_FLAG_TDE ;
hw/slavio_intctl.c +0 -4
@@ -381,14 +381,10 @@ void *slavio_intctl_init(target_phys_addr_t addr, target_phys_addr_t addrg,SLAVIO_CPUINTCTLState *slave; s =qemu_mallocz (sizeof (SLAVIO_INTCTLState)); -if (!s) -return NULL ; s->intbit_to_level = intbit_to_level;for (i =0 ; i <MAX_CPUS ; i++) { slave =qemu_mallocz (sizeof (SLAVIO_CPUINTCTLState)); -if (!slave) -return NULL ; slave->cpu = i; slave->master = s;
hw/slavio_misc.c +0 -2
@@ -446,8 +446,6 @@ void *slavio_misc_init(target_phys_addr_t base, target_phys_addr_t power_base,MiscState *s; s =qemu_mallocz (sizeof (MiscState)); -if (!s) -return NULL ;if (base) {/* 8 bit registers */
hw/slavio_timer.c +0 -2
@@ -372,8 +372,6 @@ static SLAVIO_TIMERState *slavio_timer_init(target_phys_addr_t addr,QEMUBH *bh; s =qemu_mallocz (sizeof (SLAVIO_TIMERState)); -if (!s) -return s; s->irq = irq; s->master = master; s->slave_index = slave_index;
hw/sparc32_dma.c +0 -2
@@ -248,8 +248,6 @@ void *sparc32_dma_init(target_phys_addr_t daddr, qemu_irq parent_irq,int dma_io_memory; s =qemu_mallocz (sizeof (DMAState)); -if (!s) -return NULL ; s->irq = parent_irq; s->iommu = iommu;
hw/sun4c_intctl.c +0 -2
@@ -204,8 +204,6 @@ void *sun4c_intctl_init(target_phys_addr_t addr, qemu_irq **irq,Sun4c_INTCTLState *s; s =qemu_mallocz (sizeof (Sun4c_INTCTLState)); -if (!s) -return NULL ; sun4c_intctl_io_memory =cpu_register_io_memory (0 , sun4c_intctl_mem_read, sun4c_intctl_mem_write, s);
hw/tcx.c +0 -2
@@ -499,8 +499,6 @@ void tcx_init(target_phys_addr_t addr, uint8_t *vram_base,int size; s =qemu_mallocz (sizeof (TCXState)); -if (!s) -return ; s->addr = addr; s->vram_offset = vram_offset; s->width = width;
hw/usb-bt.c +0 -2
@@ -625,8 +625,6 @@ USBDevice *usb_bt_init(HCIInfo *hci)if (!hci)return NULL ; s =qemu_mallocz (sizeof (struct USBBtState )); -if (!s) -return NULL ; s->dev.opaque = s; s->dev.speed =USB_SPEED_HIGH ; s->dev.handle_packet = usb_generic_handle_packet;
hw/usb-hid.c +0 -6
@@ -851,8 +851,6 @@ USBDevice *usb_tablet_init(void)USBHIDState *s; s =qemu_mallocz (sizeof (USBHIDState)); -if (!s) -return NULL ; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
@@ -874,8 +872,6 @@ USBDevice *usb_mouse_init(void)USBHIDState *s; s =qemu_mallocz (sizeof (USBHIDState)); -if (!s) -return NULL ; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
@@ -897,8 +893,6 @@ USBDevice *usb_keyboard_init(void)USBHIDState *s; s =qemu_mallocz (sizeof (USBHIDState)); -if (!s) -return NULL ; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
hw/usb-hub.c +0 -2
@@ -530,8 +530,6 @@ USBDevice *usb_hub_init(int nb_ports)if (nb_ports >MAX_PORTS )return NULL ; s =qemu_mallocz (sizeof (USBHubState)); -if (!s) -return NULL ; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_hub_handle_packet;
hw/usb-msd.c +0 -2
@@ -548,8 +548,6 @@ USBDevice *usb_msd_init(const char *filename) } s =qemu_mallocz (sizeof (MSDState)); -if (!s) -return NULL ; bdrv =bdrv_new ("usb" );if (bdrv_open2 (bdrv, filename,0 , drv) <0 )
hw/usb-net.c +0 -2
@@ -1430,8 +1430,6 @@ USBDevice *usb_net_init(NICInfo *nd)USBNetState *s; s =qemu_mallocz (sizeof (USBNetState)); -if (!s) -return NULL ; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
hw/usb-serial.c +0 -2
@@ -554,8 +554,6 @@ USBDevice *usb_serial_init(const char *filename) } filename++; s =qemu_mallocz (sizeof (USBSerialState)); -if (!s) -return NULL ;snprintf (label,sizeof (label),"usbserial%d" , index++); cdrv =qemu_chr_open (label, filename,NULL );
hw/usb-uhci.c +7 -8
@@ -155,14 +155,13 @@ typedef struct UHCI_QH {static UHCIAsync *uhci_async_alloc (UHCIState *s) {UHCIAsync *async =qemu_malloc (sizeof (UHCIAsync)); -if (async) { -memset (&async->packet,0 ,sizeof (async->packet)); - async->valid =0 ; - async->td =0 ; - async->token =0 ; - async->done =0 ; - async->next =NULL ; - } + +memset (&async->packet,0 ,sizeof (async->packet)); + async->valid =0 ; + async->td =0 ; + async->token =0 ; + async->done =0 ; + async->next =NULL ;return async; }
hw/usb-wacom.c +0 -2
@@ -397,8 +397,6 @@ USBDevice *usb_wacom_init(void)USBWacomState *s; s =qemu_mallocz (sizeof (USBWacomState)); -if (!s) -return NULL ; s->dev.speed =USB_SPEED_FULL ; s->dev.handle_packet = usb_generic_handle_packet;
hw/versatilepb.c +0 -2
@@ -135,8 +135,6 @@ static qemu_irq *vpb_sic_init(uint32_t base, qemu_irq *parent, int irq)int iomemtype; s = (vpb_sic_state *)qemu_mallocz (sizeof (vpb_sic_state)); -if (!s) -return NULL ; qi =qemu_allocate_irqs (vpb_sic_set_irq, s,32 ); s->parent = parent; s->irq = irq;
hw/vga.c +0 -4
@@ -2444,8 +2444,6 @@ int isa_vga_init(uint8_t *vga_ram_base,VGAState *s; s =qemu_mallocz (sizeof (VGAState)); -if (!s) -return -1 ;vga_common_init (s, vga_ram_base, vga_ram_offset, vga_ram_size);vga_init (s);
@@ -2469,8 +2467,6 @@ int isa_vga_mm_init(uint8_t *vga_ram_base,VGAState *s; s =qemu_mallocz (sizeof (VGAState)); -if (!s) -return -1 ;vga_common_init (s, vga_ram_base, vga_ram_offset, vga_ram_size);vga_mm_init (s, vram_base, ctrl_base, it_shift);
hw/virtio-blk.c +1 -2
@@ -104,8 +104,7 @@ static void virtio_blk_rw_complete(void *opaque, int ret)static VirtIOBlockReq *virtio_blk_alloc_request (VirtIOBlock *s) {VirtIOBlockReq *req =qemu_mallocz (sizeof (*req)); -if (req !=NULL ) - req->dev = s; + req->dev = s;return req; }
hw/virtio.c +1 -2
@@ -447,8 +447,7 @@ int virtqueue_pop(VirtQueue *vq, VirtQueueElement *elem) sg->iov_len =2 <<20 ; sg->iov_base =qemu_malloc (sg->iov_len); -if (sg->iov_base && - !(vring_desc_flags (vq, i) &VRING_DESC_F_WRITE )) { +if (!(vring_desc_flags (vq, i) &VRING_DESC_F_WRITE )) {cpu_physical_memory_read (vring_desc_addr (vq, i), sg->iov_base, sg->iov_len);
hw/vmmouse.c +0 -2
@@ -275,8 +275,6 @@ void *vmmouse_init(void *m)DPRINTF ("vmmouse_init\n" ); s =qemu_mallocz (sizeof (VMMouseState)); -if (!s) -return NULL ; s->status =0xffff ; s->ps2_mouse = m;
Signature · 1 line
1.6.1.1
PATCH 5/6 targets: remove error handling from qemu_malloc() callers
In reply to Avi Kivity--- target-alpha/translate.c | 2 -- target-arm/helper.c | 4 ---- target-cris/translate.c | 2 -- target-i386/helper.c | 2 -- target-i386/kvm.c | 2 -- target-m68k/helper.c | 2 -- target-mips/translate.c | 2 -- target-ppc/helper.c | 2 -- target-ppc/kvm_ppc.c | 4 ---- target-ppc/translate_init.c | 2 -- target-sh4/translate.c | 2 -- target-sparc/helper.c | 2 -- 12 files changed, 0 insertions(+), 28 deletions(-)
target-alpha/translate.c +0 -2
@@ -2466,8 +2466,6 @@ CPUAlphaState * cpu_alpha_init (const char *cpu_model)uint64_t hwpcb; env =qemu_mallocz (sizeof (CPUAlphaState)); -if (!env) -return NULL ;cpu_exec_init (env);alpha_translate_init ();tlb_flush (env,1 );
target-arm/helper.c +0 -4
@@ -248,8 +248,6 @@ CPUARMState *cpu_arm_init(const char *cpu_model)if (id ==0 )return NULL ; env =qemu_mallocz (sizeof (CPUARMState)); -if (!env) -return NULL ;cpu_exec_init (env);if (!inited) { inited =1 ;
@@ -468,8 +466,6 @@ int cpu_arm_handle_mmu_fault (CPUState *env, target_ulong address, int rw,static void allocate_mmon_state (CPUState *env) { env->mmon_entry =malloc (sizeof (mmon_state)); -if (!env->mmon_entry) -abort ();memset (env->mmon_entry,0 ,sizeof (mmon_state)); env->mmon_entry->cpu_env = env; mmon_head = env->mmon_entry;
target-cris/translate.c +0 -2
@@ -3400,8 +3400,6 @@ CPUCRISState *cpu_cris_init (const char *cpu_model)int i; env =qemu_mallocz (sizeof (CPUCRISState)); -if (!env) -return NULL ;cpu_exec_init (env);cpu_reset (env);
target-i386/helper.c +0 -2
@@ -1645,8 +1645,6 @@ CPUX86State *cpu_x86_init(const char *cpu_model)static int inited; env =qemu_mallocz (sizeof (CPUX86State)); -if (!env) -return NULL ;cpu_exec_init (env); env->cpu_model_str = cpu_model;
target-i386/kvm.c +0 -2
@@ -97,8 +97,6 @@ static int kvm_has_msr_star(CPUState *env) kvm_msr_list =qemu_mallocz (sizeof (msr_list) + msr_list.nmsrs *sizeof (msr_list.indices[0 ])); -if (kvm_msr_list ==NULL ) -return 0 ; kvm_msr_list->nmsrs = msr_list.nmsrs; ret =kvm_ioctl (env->kvm_state,KVM_GET_MSR_INDEX_LIST , kvm_msr_list);
target-m68k/helper.c +0 -2
@@ -166,8 +166,6 @@ CPUM68KState *cpu_m68k_init(const char *cpu_model)static int inited; env =qemu_mallocz (sizeof (CPUM68KState)); -if (!env) -return NULL ;cpu_exec_init (env);if (!inited) { inited =1 ;
target-mips/translate.c +0 -2
@@ -8476,8 +8476,6 @@ CPUMIPSState *cpu_mips_init (const char *cpu_model)if (!def)return NULL ; env =qemu_mallocz (sizeof (CPUMIPSState)); -if (!env) -return NULL ; env->cpu_model = def;cpu_exec_init (env);
target-ppc/helper.c +0 -2
@@ -2761,8 +2761,6 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model)return NULL ; env =qemu_mallocz (sizeof (CPUPPCState)); -if (!env) -return NULL ;cpu_exec_init (env);ppc_translate_init (); env->cpu_model_str = cpu_model;
target-ppc/kvm_ppc.c +0 -4
@@ -33,10 +33,6 @@ int kvmppc_read_host_property(const char *node_path, const char *prop, pathlen =snprintf (NULL ,0 ,"%s/%s/%s" ,PROC_DEVTREE_PATH , node_path, prop) +1 ; path =qemu_malloc (pathlen); -if (path ==NULL ) { - ret = -ENOMEM ; - goto out; - }snprintf (path, pathlen,"%s/%s/%s" ,PROC_DEVTREE_PATH , node_path, prop);
target-ppc/translate_init.c +0 -2
@@ -9040,8 +9040,6 @@ static int create_new_table (opc_handler_t **table, unsigned char idx)opc_handler_t **tmp; tmp =malloc (0x20 *sizeof (opc_handler_t)); -if (tmp ==NULL ) -return -1 ;fill_new_table (tmp,0x20 ); table[idx] = (opc_handler_t *)((unsigned long )tmp |PPC_INDIRECT );
target-sh4/translate.c +0 -2
@@ -277,8 +277,6 @@ CPUSH4State *cpu_sh4_init(const char *cpu_model)if (!def)return NULL ; env =qemu_mallocz (sizeof (CPUSH4State)); -if (!env) -return NULL ; env->features = def->features;cpu_exec_init (env);sh4_translate_init ();
target-sparc/helper.c +0 -2
@@ -713,8 +713,6 @@ CPUSPARCState *cpu_sparc_init(const char *cpu_model)CPUSPARCState *env; env =qemu_mallocz (sizeof (CPUSPARCState)); -if (!env) -return NULL ;cpu_exec_init (env);gen_intermediate_code_init (env);
Signature · 1 line
1.6.1.1
PATCH 6/6 toplevel: remove error handling from qemu_malloc() callers
In reply to Avi Kivity--- aio.c | 2 - buffered_file.c | 2 - console.c | 23 --------------------- cris-dis.c | 26 +++++++---------------- curses.c | 2 - device_tree.c | 4 --- exec.c | 25 ++++++---------------- gdbstub.c | 8 ------- keymaps.c | 10 ++------ kvm-all.c | 7 ------ loader.c | 4 --- migration-exec.c | 5 ---- migration-tcp.c | 2 - monitor.c | 4 --- net.c | 14 ------------ qemu-char.c | 59 ------------------------------------------------------ qemu-nbd.c | 2 - qemu-tool.c | 6 +--- readline.c | 2 - savevm.c | 19 ----------------- sdl.c | 2 - usb-bsd.c | 2 - usb-linux.c | 24 +-------------------- vl.c | 16 -------------- vnc.c | 9 ++----- 25 files changed, 25 insertions(+), 254 deletions(-)
aio.c +0 -2
@@ -79,8 +79,6 @@ int qemu_aio_set_fd_handler(int fd,if (node ==NULL ) {/* Alloc and insert if it's not already there */ node =qemu_mallocz (sizeof (AioHandler)); -if (node ==NULL ) -return -ENOMEM ; node->fd = fd;LIST_INSERT_HEAD (&aio_handlers, node, node); }
buffered_file.c +0 -2
@@ -228,8 +228,6 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque,QEMUFileBuffered *s; s =qemu_mallocz (sizeof (*s)); -if (s ==NULL ) -return NULL ; s->opaque = opaque; s->xfer_limit = bytes_per_sec /10 ;
console.c +0 -23
@@ -1246,9 +1246,6 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)if (nb_consoles >=MAX_CONSOLES )return NULL ; s =qemu_mallocz (sizeof (TextConsole)); -if (!s) { -return NULL ; - }if (!active_console || ((active_console->console_type !=GRAPHIC_CONSOLE ) && (console_type ==GRAPHIC_CONSOLE ))) { active_console = s;
@@ -1280,8 +1277,6 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,DisplayState *ds; ds = (DisplayState *)qemu_mallocz (sizeof (DisplayState)); -if (ds ==NULL ) -return NULL ; ds->surface =qemu_create_displaysurface (640 ,480 ,32 ,640 *4 ); s =new_console (ds,GRAPHIC_CONSOLE );
@@ -1402,8 +1397,6 @@ CharDriverState *text_console_init(const char *p)CharDriverState *chr; chr =qemu_mallocz (sizeof (CharDriverState)); -if (!chr) -return NULL ;if (n_text_consoles ==128 ) {fprintf (stderr,"Too many text consoles\n" );
@@ -1562,10 +1555,6 @@ PixelFormat qemu_default_pixelformat(int bpp)DisplaySurface *qemu_create_displaysurface (int width,int height,int bpp,int linesize) {DisplaySurface *surface = (DisplaySurface *)qemu_mallocz (sizeof (DisplaySurface)); -if (surface ==NULL ) { -fprintf (stderr,"qemu_create_displaysurface: malloc failed\n" ); -exit (1 ); - } surface->width = width; surface->height = height;
@@ -1577,10 +1566,6 @@ DisplaySurface* qemu_create_displaysurface(int width, int height, int bpp, int l surface->flags =QEMU_ALLOCATED_FLAG ;#endif surface->data = (uint8_t *)qemu_mallocz (surface->linesize * surface->height); -if (surface->data ==NULL ) { -fprintf (stderr,"qemu_create_displaysurface: malloc failed\n" ); -exit (1 ); - }return surface; }
@@ -1596,10 +1581,6 @@ DisplaySurface* qemu_resize_displaysurface(DisplaySurface *surface, surface->data = (uint8_t *)qemu_realloc (surface->data, surface->linesize * surface->height); else surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height); -if (surface->data ==NULL ) { -fprintf (stderr,"qemu_resize_displaysurface: malloc failed\n" ); -exit (1 ); - }#ifdef WORDS_BIGENDIAN surface->flags =QEMU_ALLOCATED_FLAG |QEMU_BIG_ENDIAN_FLAG ;#else
@@ -1613,10 +1594,6 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, int linesize, uint8_t *data) { DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface)); -if (surface ==NULL ) { -fprintf (stderr,"qemu_create_displaysurface_from: malloc failed\n" ); -exit (1 ); - } surface->width = width; surface->height = height;
cris-dis.c +2 -0
@@ -26,6 +26,8 @@//#include "libiberty.h" +void *qemu_malloc (size_t len);/* can't include qemu-common.h here */ +#define FALSE 0#define TRUE 1
#define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
@@ -1401,44 +1403,32 @@ get_opcode_entry (unsigned int insn,
/* Allocate and clear the opcode-table. */
if (opc_table == NULL)
{- opc_table = malloc (65536 * sizeof (opc_table[0]));
- if (opc_table == NULL)
- return NULL;
+ opc_table = qemu_malloc (65536 * sizeof (opc_table[0]));
memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
dip_prefixes- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (dip_prefixes == NULL)
- return NULL;
+ = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
bdapq_m1_prefixes- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (bdapq_m1_prefixes == NULL)
- return NULL;
+ = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
bdapq_m2_prefixes- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (bdapq_m2_prefixes == NULL)
- return NULL;
+ = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
bdapq_m4_prefixes- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (bdapq_m4_prefixes == NULL)
- return NULL;
+ = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
rest_prefixes- = malloc (65536 * sizeof (const struct cris_opcode **));
- if (rest_prefixes == NULL)
- return NULL;
+ = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
}curses.c +0 -2
@@ -361,8 +361,6 @@ void curses_display_init(DisplayState *ds, int full_screen)#endif dcl = (DisplayChangeListener *)qemu_mallocz (sizeof (DisplayChangeListener)); -if (!dcl) -exit (1 ); dcl->dpy_update = curses_update; dcl->dpy_resize = curses_resize; dcl->dpy_refresh = curses_refresh;
device_tree.c +0 -4
@@ -43,10 +43,6 @@ void *load_device_tree(const char *filename_path, void *load_addr)/* First allocate space in qemu for device tree */ dt_file =qemu_mallocz (dt_file_size); -if (dt_file ==NULL ) { -printf ("Unable to allocate memory in qemu for device tree\n" ); - goto fail; - } dt_file_load_size =load_image (filename_path, dt_file);
exec.c +7 -18
@@ -476,10 +476,6 @@ static void code_gen_alloc(unsigned long tb_size) }#else code_gen_buffer =qemu_malloc (code_gen_buffer_size); -if (!code_gen_buffer) { -fprintf (stderr,"Could not allocate dynamic translator buffer\n" ); -exit (1 ); - }map_exec (code_gen_buffer, code_gen_buffer_size);#endif #endif /* !USE_STATIC_CODE_GEN_BUFFER */
@@ -825,8 +821,6 @@ static void build_page_bitmap(PageDesc *p)TranslationBlock *tb; p->code_bitmap =qemu_mallocz (TARGET_PAGE_SIZE /8 ); -if (!p->code_bitmap) -return ; tb = p->first_tb;while (tb !=NULL ) {
@@ -1318,8 +1312,6 @@ int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,return -EINVAL ; } wp =qemu_malloc (sizeof (*wp)); -if (!wp) -return -ENOMEM ; wp->vaddr = addr; wp->len_mask = len_mask;
@@ -1384,8 +1376,6 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags,CPUBreakpoint *bp; bp =qemu_malloc (sizeof (*bp)); -if (!bp) -return -ENOMEM ; bp->pc = pc; bp->flags = flags;
@@ -2795,17 +2785,16 @@ static void *subpage_init (target_phys_addr_t base, ram_addr_t *phys,int subpage_memory; mmio =qemu_mallocz (sizeof (subpage_t)); -if (mmio !=NULL ) { - mmio->base = base; - subpage_memory =cpu_register_io_memory (0 , subpage_read, subpage_write, mmio); + + mmio->base = base; + subpage_memory =cpu_register_io_memory (0 , subpage_read, subpage_write, mmio);#if defined(DEBUG_SUBPAGE ) -printf ("%s: %p base " TARGET_FMT_plx" len %08x %d\n" , __func__, - mmio, base,TARGET_PAGE_SIZE , subpage_memory); +printf ("%s: %p base " TARGET_FMT_plx" len %08x %d\n" , __func__, + mmio, base,TARGET_PAGE_SIZE , subpage_memory);#endif - *phys = subpage_memory |IO_MEM_SUBPAGE ; -subpage_register (mmio,0 ,TARGET_PAGE_SIZE -1 , orig_memory, + *phys = subpage_memory |IO_MEM_SUBPAGE ; +subpage_register (mmio,0 ,TARGET_PAGE_SIZE -1 , orig_memory, region_offset); - }return mmio; }
gdbstub.c +0 -8
@@ -2189,11 +2189,6 @@ static void gdb_accept(void)setsockopt (fd,IPPROTO_TCP ,TCP_NODELAY , (char *)&val,sizeof (val)); s =qemu_mallocz (sizeof (GDBState)); -if (!s) { - errno =ENOMEM ; -perror ("accept" ); -return ; - }memset (s,0 ,sizeof (GDBState)); s->c_cpu = first_cpu;
@@ -2311,9 +2306,6 @@ int gdbserver_start(const char *port)return -1 ; s =qemu_mallocz (sizeof (GDBState)); -if (!s) { -return -1 ; - } s->c_cpu = first_cpu; s->g_cpu = first_cpu; s->chr = chr;
keymaps.c +3 -7
@@ -67,11 +67,9 @@ static void add_to_key_range(struct key_range **krp, int code) { }if (kr ==NULL ) { kr =qemu_mallocz (sizeof (*kr)); -if (kr) { - kr->start = kr->end = code; - kr->next = *krp; - *krp = kr; - } + kr->start = kr->end = code; + kr->next = *krp; + *krp = kr; } }
@@ -88,8 +86,6 @@ static kbd_layout_t *parse_keyboard_layout(const char *language,if (!k) k =qemu_mallocz (sizeof (kbd_layout_t)); -if (!k) -return 0 ;if (!(f =fopen (file_name,"r" ))) {fprintf (stderr,"Could not read keymap file: '%s'\n" , file_name);
kvm-all.c +0 -7
@@ -220,11 +220,6 @@ void kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_a alloc_size = mem->memory_size >>TARGET_PAGE_BITS /sizeof (d.dirty_bitmap); d.dirty_bitmap =qemu_mallocz (alloc_size); -if (d.dirty_bitmap ==NULL ) { -dprintf ("Could not allocate dirty bitmap\n" ); -return ; - } - d.slot = mem->slot;dprintf ("slot %d, phys_addr %llx, uaddr: %llx\n" , d.slot, mem->start_addr, mem->phys_offset);
@@ -295,8 +290,6 @@ int kvm_init(int smp_cpus)return -EINVAL ; s =qemu_mallocz (sizeof (KVMState)); -if (s ==NULL ) -return -ENOMEM ;for (i =0 ; i <ARRAY_SIZE (s->slots); i++) s->slots[i].slot = i;
loader.c +0 -4
@@ -266,8 +266,6 @@ static void *load_at(int fd, int offset, int size)if (lseek (fd, offset,SEEK_SET ) <0 )return NULL ; ptr =qemu_malloc (size); -if (!ptr) -return NULL ;if (read (fd, ptr, size) != size) {qemu_free (ptr);return NULL ;
@@ -505,8 +503,6 @@ int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr, *ep = hdr->ih_ep; data =qemu_malloc (hdr->ih_size); -if (!data) - goto out;if (read (fd, data, hdr->ih_size) != hdr->ih_size) {fprintf (stderr,"Error reading file\n" );
migration-exec.c +0 -5
@@ -61,10 +61,6 @@ MigrationState *exec_start_outgoing_migration(const char *command,FILE *f; s =qemu_mallocz (sizeof (*s)); -if (s ==NULL ) { -dprintf ("Unable to allocate FdMigrationState\n" ); - goto err; - } f =popen (command,"w" );if (f ==NULL ) {
@@ -109,7 +105,6 @@ err_after_open:pclose (f); err_after_alloc:qemu_free (s); -err:return NULL ; }
migration-tcp.c +0 -2
@@ -89,8 +89,6 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,return NULL ; s =qemu_mallocz (sizeof (*s)); -if (s ==NULL ) -return NULL ; s->get_error = socket_errno; s->write = socket_write;
monitor.c +0 -4
@@ -1371,10 +1371,6 @@ static void do_wav_capture (const char *path,CaptureState *s; s =qemu_mallocz (sizeof (*s)); -if (!s) { -term_printf ("Not enough memory to add wave capture\n" ); -return ; - } freq = has_freq ? freq :44100 ; bits = has_bits ? bits :16 ;
net.c +0 -14
@@ -333,8 +333,6 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan, {VLANClientState *vc, **pvc; vc =qemu_mallocz (sizeof (VLANClientState)); -if (!vc) -return NULL ; vc->model =strdup (model);if (name) vc->name =strdup (name);
@@ -728,8 +726,6 @@ static TAPState *net_tap_fd_init(VLANState *vlan,TAPState *s; s =qemu_mallocz (sizeof (TAPState)); -if (!s) -return NULL ; s->fd = fd; s->vc =qemu_new_vlan_client (vlan, model, name, tap_receive,NULL , s);#ifdef HAVE_IOVEC
@@ -1049,8 +1045,6 @@ static int net_vde_init(VLANState *vlan, const char *model, }; s =qemu_mallocz (sizeof (VDEState)); -if (!s) -return -1 ; s->vde =vde_open (init_sock,"QEMU" , &args);if (!s->vde){free (s);
@@ -1274,8 +1268,6 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, } s =qemu_mallocz (sizeof (NetSocketState)); -if (!s) -return NULL ; s->fd = fd; s->vc =qemu_new_vlan_client (vlan, model, name, net_socket_receive_dgram,NULL , s);
@@ -1304,8 +1296,6 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan, {NetSocketState *s; s =qemu_mallocz (sizeof (NetSocketState)); -if (!s) -return NULL ; s->fd = fd; s->vc =qemu_new_vlan_client (vlan, model, name, net_socket_receive,NULL , s);
@@ -1383,8 +1373,6 @@ static int net_socket_listen_init(VLANState *vlan,return -1 ; s =qemu_mallocz (sizeof (NetSocketListenState)); -if (!s) -return -1 ; fd =socket (PF_INET ,SOCK_STREAM ,0 );if (fd <0 ) {
@@ -1504,8 +1492,6 @@ VLANState *qemu_find_vlan(int id)return vlan; } vlan =qemu_mallocz (sizeof (VLANState)); -if (!vlan) -return NULL ; vlan->id = id; vlan->next =NULL ; pvlan = &first_vlan;
qemu-char.c +0 -59
137 lines not on this page · raw message
qemu-nbd.c +0 -2
@@ -409,8 +409,6 @@ int main(int argc, char **argv) } sharing_fds =qemu_malloc ((shared +1 ) *sizeof (int )); -if (sharing_fds ==NULL ) -errx (ENOMEM ,"Cannot allocate sharing fds" );if (socket) { sharing_fds[0 ] =unix_socket_incoming (socket);
qemu-tool.c +2 -4
@@ -43,10 +43,8 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)QEMUBH *bh; bh =qemu_malloc (sizeof (*bh)); -if (bh) { - bh->cb = cb; - bh->opaque = opaque; - } + bh->cb = cb; + bh->opaque = opaque;return bh; }
readline.c +0 -2
@@ -307,8 +307,6 @@ static void term_completion(void) nb_completions =0 ; cmdline =qemu_malloc (term_cmd_buf_index +1 ); -if (!cmdline) -return ;memcpy (cmdline, term_cmd_buf, term_cmd_buf_index); cmdline[term_cmd_buf_index] ='\0' ;readline_find_completion (cmdline);
savevm.c +0 -19
@@ -214,10 +214,6 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode) } s =qemu_mallocz (sizeof (QEMUFilePopen)); -if (!s) { -fprintf (stderr,"qemu_popen: malloc failed\n" ); -return NULL ; - } s->popen_file = popen_file;
@@ -246,9 +242,6 @@ QEMUFile *qemu_fopen_socket(int fd) {QEMUFileSocket *s =qemu_mallocz (sizeof (QEMUFileSocket)); -if (s ==NULL ) -return NULL ; - s->fd = fd; s->file =qemu_fopen_ops (s,NULL , socket_get_buffer, socket_close,NULL );return s->file;
@@ -288,8 +281,6 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)QEMUFileStdio *s; s =qemu_mallocz (sizeof (QEMUFileStdio)); -if (!s) -return NULL ; s->outfile =fopen (filename, mode);if (!s->outfile)
@@ -339,8 +330,6 @@ static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_wrQEMUFileBdrv *s; s =qemu_mallocz (sizeof (QEMUFileBdrv)); -if (!s) -return NULL ; s->bs = bs; s->base_offset = offset;
@@ -359,8 +348,6 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,QEMUFile *f; f =qemu_mallocz (sizeof (QEMUFile)); -if (!f) -return NULL ; f->opaque = opaque; f->put_buffer = put_buffer;
@@ -615,8 +602,6 @@ int register_savevm_live(const char *idstr,static int global_section_id; se =qemu_malloc (sizeof (SaveStateEntry)); -if (!se) -return -1 ;pstrcpy (se->idstr,sizeof (se->idstr), idstr); se->instance_id = (instance_id ==-1 ) ?0 : instance_id; se->version_id = version_id;
@@ -908,10 +893,6 @@ int qemu_loadvm_state(QEMUFile *f)/* Add entry */ le =qemu_mallocz (sizeof (*le)); -if (le ==NULL ) { - ret = -ENOMEM ; - goto out; - } le->se = se; le->section_id = section_id;
sdl.c +0 -2
@@ -638,8 +638,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) } dcl =qemu_mallocz (sizeof (DisplayChangeListener)); -if (!dcl) -exit (1 ); dcl->dpy_update = sdl_update; dcl->dpy_resize = sdl_resize; dcl->dpy_refresh = sdl_refresh;
usb-bsd.c +0 -2
@@ -340,8 +340,6 @@ USBDevice *usb_host_device_open(const char *devname)if (dfd >=0 ) { dev =qemu_mallocz (sizeof (USBHostDevice)); -if (!dev) - goto fail; dev->devfd = dfd;if (ioctl (dfd,USB_GET_DEVICEINFO , &dev_info) <0 ) {
usb-linux.c +2 -22
@@ -441,10 +441,6 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket *p)int ret; aurb =async_alloc (); -if (!aurb) { -dprintf ("husb: async malloc failed\n" ); -return USB_RET_NAK ; - } aurb->hdev = s; aurb->packet = p;
@@ -585,10 +581,6 @@ static int usb_host_handle_control(USBHostDevice *s, USBPacket *p)/* The rest are asynchronous */ aurb =async_alloc (); -if (!aurb) { -dprintf ("husb: async malloc failed\n" ); -return USB_RET_NAK ; - } aurb->hdev = s; aurb->packet = p;
@@ -898,8 +890,6 @@ static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *pchar buf[1024 ]; dev =qemu_mallocz (sizeof (USBHostDevice)); -if (!dev) - goto fail; dev->bus_num = bus_num; dev->addr = addr;
@@ -1308,14 +1298,8 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)/* the module setting (used later for opening devices) */ usb_host_device_path =qemu_mallocz (strlen (devpath)+1 ); -if (usb_host_device_path) { -strcpy (usb_host_device_path, devpath); -term_printf ("husb: using %s file-system with %s\n" , fs_type[usb_fs_type], usb_host_device_path); - }else { -/* out of memory? */ -perror ("husb: unable to allocate memory for device path" ); -return -ENOMEM ; - } +strcpy (usb_host_device_path, devpath); +term_printf ("husb: using %s file-system with %s\n" , fs_type[usb_fs_type], usb_host_device_path); }switch (usb_fs_type) {
@@ -1455,10 +1439,6 @@ static int usb_host_auto_add(const char *spec)return -1 ; f =qemu_mallocz (sizeof (*f)); -if (!f) { -fprintf (stderr,"husb: failed to allocate auto filter\n" ); -return -1 ; - } *f = filter;
vl.c +0 -16
@@ -546,8 +546,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,QEMUPutMouseEntry *s, *cursor; s =qemu_mallocz (sizeof (QEMUPutMouseEntry)); -if (!s) -return NULL ; s->qemu_put_mouse_event = func; s->qemu_put_mouse_event_opaque = opaque;
@@ -1098,8 +1096,6 @@ static QEMUClock *qemu_new_clock(int type) {QEMUClock *clock; clock =qemu_mallocz (sizeof (QEMUClock)); -if (!clock) -return NULL ; clock->type = type;return clock; }
@@ -2808,10 +2804,6 @@ DisplayState *get_displaystate(void)static void dumb_display_init (void ) {DisplayState *ds =qemu_mallocz (sizeof (DisplayState)); -if (ds ==NULL ) { -fprintf (stderr,"dumb_display_init: DisplayState allocation failed\n" ); -exit (1 ); - } ds->surface =qemu_create_displaysurface (640 ,480 ,32 ,640 *4 );register_displaystate (ds); }
@@ -2863,8 +2855,6 @@ int qemu_set_fd_handler2(int fd, goto found; } ioh =qemu_mallocz (sizeof (IOHandlerRecord)); -if (!ioh) -return -1 ; ioh->next = first_io_handler; first_io_handler = ioh; found:
@@ -2902,8 +2892,6 @@ int qemu_add_polling_cb(PollingFunc *func, void *opaque) {PollingEntry **ppe, *pe; pe =qemu_mallocz (sizeof (PollingEntry)); -if (!pe) -return -1 ; pe->func = func; pe->opaque = opaque;for (ppe = &first_polling_entry; *ppe !=NULL ; ppe = &(*ppe)->next);
@@ -3273,8 +3261,6 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) {QEMUBH *bh; bh =qemu_mallocz (sizeof (QEMUBH )); -if (!bh) -return NULL ; bh->cb = cb; bh->opaque = opaque; bh->next = first_bh;
@@ -3432,8 +3418,6 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,VMChangeStateEntry *e; e =qemu_mallocz (sizeof (*e)); -if (!e) -return NULL ; e->cb = cb; e->opaque = opaque;
vnc.c +3 -6
@@ -471,8 +471,8 @@ static void send_framebuffer_update_hextile(VncState *vs, int x, int y, int w, iint has_fg, has_bg;uint8_t *last_fg, *last_bg; - last_fg = (uint8_t *)malloc (vs->serverds.pf.bytes_per_pixel); - last_bg = (uint8_t *)malloc (vs->serverds.pf.bytes_per_pixel); + last_fg = (uint8_t *)qemu_malloc (vs->serverds.pf.bytes_per_pixel); + last_bg = (uint8_t *)qemu_malloc (vs->serverds.pf.bytes_per_pixel); has_fg = has_bg =0 ;for (j = y; j < (y + h); j +=16 ) {for (i = x; i < (x + w); i +=16 ) {
@@ -2237,8 +2237,6 @@ void vnc_display_init(DisplayState *ds) vs =qemu_mallocz (sizeof (VncState)); dcl =qemu_mallocz (sizeof (DisplayChangeListener)); -if (!vs || !dcl) -exit (1 ); ds->opaque = vs; dcl->idle =1 ;
@@ -2289,8 +2287,7 @@ static int vnc_set_x509_credential(VncState *vs, *cred =NULL ; } -if (!(*cred =qemu_malloc (strlen (certdir) +strlen (filename) +2 ))) -return -1 ; + *cred =qemu_malloc (strlen (certdir) +strlen (filename) +2 );strcpy (*cred, certdir);strcat (*cred,"/" );
Signature · 1 line
1.6.1.1
Avi Kivity writes ("[Qemu-devel] [PATCH 0/6] Unify memory allocation failure handling"):
Quoted 3 lines
This patchset modifies
qemu_malloc()and related functions to terminate on error, and updates callers not to perform their own error handling. In many cases error handling was already missing or incorrect.
Good idea.
(Although I haven't reviewed your patches in detail.)
Ian.
Anthony Liguori
AppliedQuoted 10 lines · Avi Kivity
Memory allocation failures are a very rare condition on virtual-memory hosts. They are also very difficult to handle correctly (especially in a hardware emulation context). Because of this, it is better to gracefully terminate emulation rather than executing untested or even unwritten recovery code paths.
This patchset modifies
qemu_malloc()and related functions to terminate on error, and updates callers not to perform their own error handling. In many cases error handling was already missing or incorrect.
Quoted 8 lines
Avi Kivity (6):
Terminate emulation on memory allocation failure
block: remove error handling fromqemu_malloc()callers
audio: remove error handling fromqemu_malloc()callers
hw: remove error handling fromqemu_malloc()callers
targets: remove error handling fromqemu_malloc()callers
toplevel: remove error handling fromqemu_malloc()callers
Applied all. Thanks.
Did you do this all by hand or were scripts involved?
Regards,
Anthony Liguori
Quoted 2 lines · Anthony Liguori
Did you do this all by hand or were scripts involved?
By hand, armed only with my trusty grep.
Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.