mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
hw: remove error handling from qemu_malloc() callers (Avi Kivity)
Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6529 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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++;
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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++) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user