toplevel: 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@6531 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/aio.c b/aio.c
index 70d3cdc..200320c 100644
--- a/aio.c
+++ b/aio.c
@@ -79,8 +79,6 @@
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);
}
diff --git a/buffered_file.c b/buffered_file.c
index be5baea..ec4f664 100644
--- a/buffered_file.c
+++ b/buffered_file.c
@@ -228,8 +228,6 @@
QEMUFileBuffered *s;
s = qemu_mallocz(sizeof(*s));
- if (s == NULL)
- return NULL;
s->opaque = opaque;
s->xfer_limit = bytes_per_sec / 10;
diff --git a/console.c b/console.c
index 68ac970..3f2794e 100644
--- a/console.c
+++ b/console.c
@@ -1246,9 +1246,6 @@
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 *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 *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 @@
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 @@
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 @@
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 @@
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;
diff --git a/cris-dis.c b/cris-dis.c
index 0781b08..ba69907 100644
--- a/cris-dis.c
+++ b/cris-dis.c
@@ -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 @@
/* 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]));
}
diff --git a/curses.c b/curses.c
index 97ab412..d699b5e 100644
--- a/curses.c
+++ b/curses.c
@@ -361,8 +361,6 @@
#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;
diff --git a/device_tree.c b/device_tree.c
index 2238682..4fc0781 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -43,10 +43,6 @@
/* 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);
diff --git a/exec.c b/exec.c
index 302da34..9852bdc 100644
--- a/exec.c
+++ b/exec.c
@@ -476,10 +476,6 @@
}
#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 @@
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 @@
return -EINVAL;
}
wp = qemu_malloc(sizeof(*wp));
- if (!wp)
- return -ENOMEM;
wp->vaddr = addr;
wp->len_mask = len_mask;
@@ -1384,8 +1376,6 @@
CPUBreakpoint *bp;
bp = qemu_malloc(sizeof(*bp));
- if (!bp)
- return -ENOMEM;
bp->pc = pc;
bp->flags = flags;
@@ -2795,17 +2785,16 @@
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;
}
diff --git a/gdbstub.c b/gdbstub.c
index b4b8292..239f2e0 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2189,11 +2189,6 @@
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 @@
return -1;
s = qemu_mallocz(sizeof(GDBState));
- if (!s) {
- return -1;
- }
s->c_cpu = first_cpu;
s->g_cpu = first_cpu;
s->chr = chr;
diff --git a/keymaps.c b/keymaps.c
index 38e50f0..216e378 100644
--- a/keymaps.c
+++ b/keymaps.c
@@ -67,11 +67,9 @@
}
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 @@
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);
diff --git a/kvm-all.c b/kvm-all.c
index 9fb295c..0b17427 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -220,11 +220,6 @@
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 @@
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;
diff --git a/loader.c b/loader.c
index cf603cc..71b9ba7 100644
--- a/loader.c
+++ b/loader.c
@@ -266,8 +266,6 @@
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 @@
*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");
diff --git a/migration-exec.c b/migration-exec.c
index caeed4b..6ed322a 100644
--- a/migration-exec.c
+++ b/migration-exec.c
@@ -61,10 +61,6 @@
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 @@
pclose(f);
err_after_alloc:
qemu_free(s);
-err:
return NULL;
}
diff --git a/migration-tcp.c b/migration-tcp.c
index 6fc1943..3f5b104 100644
--- a/migration-tcp.c
+++ b/migration-tcp.c
@@ -89,8 +89,6 @@
return NULL;
s = qemu_mallocz(sizeof(*s));
- if (s == NULL)
- return NULL;
s->get_error = socket_errno;
s->write = socket_write;
diff --git a/monitor.c b/monitor.c
index 8815688..354a792 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1371,10 +1371,6 @@
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;
diff --git a/net.c b/net.c
index 8d9b3de..e7c097e 100644
--- a/net.c
+++ b/net.c
@@ -333,8 +333,6 @@
{
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 @@
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 @@
};
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 @@
}
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 @@
{
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 @@
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 @@
return vlan;
}
vlan = qemu_mallocz(sizeof(VLANState));
- if (!vlan)
- return NULL;
vlan->id = id;
vlan->next = NULL;
pvlan = &first_vlan;
diff --git a/qemu-char.c b/qemu-char.c
index f849187..6e10c67 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -193,8 +193,6 @@
CharDriverState *chr;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
chr->chr_write = null_chr_write;
return chr;
}
@@ -425,13 +423,7 @@
MuxDriver *d;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
d = qemu_mallocz(sizeof(MuxDriver));
- if (!d) {
- free(chr);
- return NULL;
- }
chr->opaque = d;
d->drv = drv;
@@ -576,13 +568,7 @@
FDCharDriver *s;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
s = qemu_mallocz(sizeof(FDCharDriver));
- if (!s) {
- free(chr);
- return NULL;
- }
s->fd_in = fd_in;
s->fd_out = fd_out;
chr->opaque = s;
@@ -929,13 +915,7 @@
#endif
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
s = qemu_mallocz(sizeof(PtyCharDriver));
- if (!s) {
- qemu_free(chr);
- return NULL;
- }
if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
return NULL;
@@ -1246,19 +1226,10 @@
}
drv = qemu_mallocz(sizeof(ParallelCharDriver));
- if (!drv) {
- close(fd);
- return NULL;
- }
drv->fd = fd;
drv->mode = IEEE1284_MODE_COMPAT;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr) {
- qemu_free(drv);
- close(fd);
- return NULL;
- }
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
@@ -1318,10 +1289,6 @@
return NULL;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr) {
- close(fd);
- return NULL;
- }
chr->opaque = (void *)fd;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
@@ -1535,13 +1502,7 @@
WinCharState *s;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
s = qemu_mallocz(sizeof(WinCharState));
- if (!s) {
- free(chr);
- return NULL;
- }
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
@@ -1640,13 +1601,7 @@
WinCharState *s;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
s = qemu_mallocz(sizeof(WinCharState));
- if (!s) {
- free(chr);
- return NULL;
- }
chr->opaque = s;
chr->chr_write = win_chr_write;
chr->chr_close = win_chr_close;
@@ -1666,13 +1621,7 @@
WinCharState *s;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- return NULL;
s = qemu_mallocz(sizeof(WinCharState));
- if (!s) {
- free(chr);
- return NULL;
- }
s->hcom = fd_out;
chr->opaque = s;
chr->chr_write = win_chr_write;
@@ -1774,11 +1723,7 @@
struct sockaddr_in saddr;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- goto return_err;
s = qemu_mallocz(sizeof(NetCharDriver));
- if (!s)
- goto return_err;
fd = socket(PF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
@@ -2044,11 +1989,7 @@
is_waitconnect = 0;
chr = qemu_mallocz(sizeof(CharDriverState));
- if (!chr)
- goto fail;
s = qemu_mallocz(sizeof(TCPCharDriver));
- if (!s)
- goto fail;
if (is_listen) {
chr->filename = qemu_malloc(256);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 59bd2f1..0af97ca 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -409,8 +409,6 @@
}
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);
diff --git a/qemu-tool.c b/qemu-tool.c
index c0b1cad..4dda5af 100644
--- a/qemu-tool.c
+++ b/qemu-tool.c
@@ -43,10 +43,8 @@
QEMUBH *bh;
bh = qemu_malloc(sizeof(*bh));
- if (bh) {
- bh->cb = cb;
- bh->opaque = opaque;
- }
+ bh->cb = cb;
+ bh->opaque = opaque;
return bh;
}
diff --git a/readline.c b/readline.c
index 7bf9a5e..8572841 100644
--- a/readline.c
+++ b/readline.c
@@ -307,8 +307,6 @@
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);
diff --git a/savevm.c b/savevm.c
index 729e849..3eb2000 100644
--- a/savevm.c
+++ b/savevm.c
@@ -214,10 +214,6 @@
}
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 @@
{
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 @@
QEMUFileStdio *s;
s = qemu_mallocz(sizeof(QEMUFileStdio));
- if (!s)
- return NULL;
s->outfile = fopen(filename, mode);
if (!s->outfile)
@@ -339,8 +330,6 @@
QEMUFileBdrv *s;
s = qemu_mallocz(sizeof(QEMUFileBdrv));
- if (!s)
- return NULL;
s->bs = bs;
s->base_offset = offset;
@@ -359,8 +348,6 @@
QEMUFile *f;
f = qemu_mallocz(sizeof(QEMUFile));
- if (!f)
- return NULL;
f->opaque = opaque;
f->put_buffer = put_buffer;
@@ -615,8 +602,6 @@
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 @@
/* Add entry */
le = qemu_mallocz(sizeof(*le));
- if (le == NULL) {
- ret = -ENOMEM;
- goto out;
- }
le->se = se;
le->section_id = section_id;
diff --git a/sdl.c b/sdl.c
index cfdf852..266fbcc 100644
--- a/sdl.c
+++ b/sdl.c
@@ -638,8 +638,6 @@
}
dcl = qemu_mallocz(sizeof(DisplayChangeListener));
- if (!dcl)
- exit(1);
dcl->dpy_update = sdl_update;
dcl->dpy_resize = sdl_resize;
dcl->dpy_refresh = sdl_refresh;
diff --git a/usb-bsd.c b/usb-bsd.c
index a8a805f..fa4093c 100644
--- a/usb-bsd.c
+++ b/usb-bsd.c
@@ -340,8 +340,6 @@
if (dfd >= 0) {
dev = qemu_mallocz(sizeof(USBHostDevice));
- if (!dev)
- goto fail;
dev->devfd = dfd;
if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) {
diff --git a/usb-linux.c b/usb-linux.c
index fb1153b..f19f0c4 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -441,10 +441,6 @@
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 @@
/* 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 @@
char buf[1024];
dev = qemu_mallocz(sizeof(USBHostDevice));
- if (!dev)
- goto fail;
dev->bus_num = bus_num;
dev->addr = addr;
@@ -1308,14 +1298,8 @@
/* 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 @@
return -1;
f = qemu_mallocz(sizeof(*f));
- if (!f) {
- fprintf(stderr, "husb: failed to allocate auto filter\n");
- return -1;
- }
*f = filter;
diff --git a/vl.c b/vl.c
index 3676537..aff2b2c 100644
--- a/vl.c
+++ b/vl.c
@@ -546,8 +546,6 @@
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 @@
{
QEMUClock *clock;
clock = qemu_mallocz(sizeof(QEMUClock));
- if (!clock)
- return NULL;
clock->type = type;
return clock;
}
@@ -2808,10 +2804,6 @@
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 @@
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 @@
{
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 *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 *e;
e = qemu_mallocz(sizeof (*e));
- if (!e)
- return NULL;
e->cb = cb;
e->opaque = opaque;
diff --git a/vnc.c b/vnc.c
index 0c4d96e..68df599 100644
--- a/vnc.c
+++ b/vnc.c
@@ -471,8 +471,8 @@
int 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 @@
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 @@
*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, "/");