Commit 1eec614b36390be66430ed6dd0ce47a6f2f0ae1a

Authored by aliguori
1 parent 0d0266a5

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
@@ -79,8 +79,6 @@ int qemu_aio_set_fd_handler(int fd, @@ -79,8 +79,6 @@ int qemu_aio_set_fd_handler(int fd,
79 if (node == NULL) { 79 if (node == NULL) {
80 /* Alloc and insert if it's not already there */ 80 /* Alloc and insert if it's not already there */
81 node = qemu_mallocz(sizeof(AioHandler)); 81 node = qemu_mallocz(sizeof(AioHandler));
82 - if (node == NULL)  
83 - return -ENOMEM;  
84 node->fd = fd; 82 node->fd = fd;
85 LIST_INSERT_HEAD(&aio_handlers, node, node); 83 LIST_INSERT_HEAD(&aio_handlers, node, node);
86 } 84 }
buffered_file.c
@@ -228,8 +228,6 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque, @@ -228,8 +228,6 @@ QEMUFile *qemu_fopen_ops_buffered(void *opaque,
228 QEMUFileBuffered *s; 228 QEMUFileBuffered *s;
229 229
230 s = qemu_mallocz(sizeof(*s)); 230 s = qemu_mallocz(sizeof(*s));
231 - if (s == NULL)  
232 - return NULL;  
233 231
234 s->opaque = opaque; 232 s->opaque = opaque;
235 s->xfer_limit = bytes_per_sec / 10; 233 s->xfer_limit = bytes_per_sec / 10;
console.c
@@ -1246,9 +1246,6 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type) @@ -1246,9 +1246,6 @@ static TextConsole *new_console(DisplayState *ds, console_type_t console_type)
1246 if (nb_consoles >= MAX_CONSOLES) 1246 if (nb_consoles >= MAX_CONSOLES)
1247 return NULL; 1247 return NULL;
1248 s = qemu_mallocz(sizeof(TextConsole)); 1248 s = qemu_mallocz(sizeof(TextConsole));
1249 - if (!s) {  
1250 - return NULL;  
1251 - }  
1252 if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && 1249 if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) &&
1253 (console_type == GRAPHIC_CONSOLE))) { 1250 (console_type == GRAPHIC_CONSOLE))) {
1254 active_console = s; 1251 active_console = s;
@@ -1280,8 +1277,6 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update, @@ -1280,8 +1277,6 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update,
1280 DisplayState *ds; 1277 DisplayState *ds;
1281 1278
1282 ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState)); 1279 ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState));
1283 - if (ds == NULL)  
1284 - return NULL;  
1285 ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4); 1280 ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4);
1286 1281
1287 s = new_console(ds, GRAPHIC_CONSOLE); 1282 s = new_console(ds, GRAPHIC_CONSOLE);
@@ -1402,8 +1397,6 @@ CharDriverState *text_console_init(const char *p) @@ -1402,8 +1397,6 @@ CharDriverState *text_console_init(const char *p)
1402 CharDriverState *chr; 1397 CharDriverState *chr;
1403 1398
1404 chr = qemu_mallocz(sizeof(CharDriverState)); 1399 chr = qemu_mallocz(sizeof(CharDriverState));
1405 - if (!chr)  
1406 - return NULL;  
1407 1400
1408 if (n_text_consoles == 128) { 1401 if (n_text_consoles == 128) {
1409 fprintf(stderr, "Too many text consoles\n"); 1402 fprintf(stderr, "Too many text consoles\n");
@@ -1562,10 +1555,6 @@ PixelFormat qemu_default_pixelformat(int bpp) @@ -1562,10 +1555,6 @@ PixelFormat qemu_default_pixelformat(int bpp)
1562 DisplaySurface* qemu_create_displaysurface(int width, int height, int bpp, int linesize) 1555 DisplaySurface* qemu_create_displaysurface(int width, int height, int bpp, int linesize)
1563 { 1556 {
1564 DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface)); 1557 DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
1565 - if (surface == NULL) {  
1566 - fprintf(stderr, "qemu_create_displaysurface: malloc failed\n");  
1567 - exit(1);  
1568 - }  
1569 1558
1570 surface->width = width; 1559 surface->width = width;
1571 surface->height = height; 1560 surface->height = height;
@@ -1577,10 +1566,6 @@ DisplaySurface* qemu_create_displaysurface(int width, int height, int bpp, int l @@ -1577,10 +1566,6 @@ DisplaySurface* qemu_create_displaysurface(int width, int height, int bpp, int l
1577 surface->flags = QEMU_ALLOCATED_FLAG; 1566 surface->flags = QEMU_ALLOCATED_FLAG;
1578 #endif 1567 #endif
1579 surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height); 1568 surface->data = (uint8_t*) qemu_mallocz(surface->linesize * surface->height);
1580 - if (surface->data == NULL) {  
1581 - fprintf(stderr, "qemu_create_displaysurface: malloc failed\n");  
1582 - exit(1);  
1583 - }  
1584 1569
1585 return surface; 1570 return surface;
1586 } 1571 }
@@ -1596,10 +1581,6 @@ DisplaySurface* qemu_resize_displaysurface(DisplaySurface *surface, @@ -1596,10 +1581,6 @@ DisplaySurface* qemu_resize_displaysurface(DisplaySurface *surface,
1596 surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height); 1581 surface->data = (uint8_t*) qemu_realloc(surface->data, surface->linesize * surface->height);
1597 else 1582 else
1598 surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height); 1583 surface->data = (uint8_t*) qemu_malloc(surface->linesize * surface->height);
1599 - if (surface->data == NULL) {  
1600 - fprintf(stderr, "qemu_resize_displaysurface: malloc failed\n");  
1601 - exit(1);  
1602 - }  
1603 #ifdef WORDS_BIGENDIAN 1584 #ifdef WORDS_BIGENDIAN
1604 surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG; 1585 surface->flags = QEMU_ALLOCATED_FLAG | QEMU_BIG_ENDIAN_FLAG;
1605 #else 1586 #else
@@ -1613,10 +1594,6 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp, @@ -1613,10 +1594,6 @@ DisplaySurface* qemu_create_displaysurface_from(int width, int height, int bpp,
1613 int linesize, uint8_t *data) 1594 int linesize, uint8_t *data)
1614 { 1595 {
1615 DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface)); 1596 DisplaySurface *surface = (DisplaySurface*) qemu_mallocz(sizeof(DisplaySurface));
1616 - if (surface == NULL) {  
1617 - fprintf(stderr, "qemu_create_displaysurface_from: malloc failed\n");  
1618 - exit(1);  
1619 - }  
1620 1597
1621 surface->width = width; 1598 surface->width = width;
1622 surface->height = height; 1599 surface->height = height;
cris-dis.c
@@ -26,6 +26,8 @@ @@ -26,6 +26,8 @@
26 //#include "libiberty.h" 26 //#include "libiberty.h"
27 27
28 28
  29 +void *qemu_malloc(size_t len); /* can't include qemu-common.h here */
  30 +
29 #define FALSE 0 31 #define FALSE 0
30 #define TRUE 1 32 #define TRUE 1
31 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0) 33 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) == 0)
@@ -1401,44 +1403,32 @@ get_opcode_entry (unsigned int insn, @@ -1401,44 +1403,32 @@ get_opcode_entry (unsigned int insn,
1401 /* Allocate and clear the opcode-table. */ 1403 /* Allocate and clear the opcode-table. */
1402 if (opc_table == NULL) 1404 if (opc_table == NULL)
1403 { 1405 {
1404 - opc_table = malloc (65536 * sizeof (opc_table[0]));  
1405 - if (opc_table == NULL)  
1406 - return NULL; 1406 + opc_table = qemu_malloc (65536 * sizeof (opc_table[0]));
1407 1407
1408 memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *)); 1408 memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
1409 1409
1410 dip_prefixes 1410 dip_prefixes
1411 - = malloc (65536 * sizeof (const struct cris_opcode **));  
1412 - if (dip_prefixes == NULL)  
1413 - return NULL; 1411 + = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1414 1412
1415 memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0])); 1413 memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
1416 1414
1417 bdapq_m1_prefixes 1415 bdapq_m1_prefixes
1418 - = malloc (65536 * sizeof (const struct cris_opcode **));  
1419 - if (bdapq_m1_prefixes == NULL)  
1420 - return NULL; 1416 + = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1421 1417
1422 memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0])); 1418 memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
1423 1419
1424 bdapq_m2_prefixes 1420 bdapq_m2_prefixes
1425 - = malloc (65536 * sizeof (const struct cris_opcode **));  
1426 - if (bdapq_m2_prefixes == NULL)  
1427 - return NULL; 1421 + = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1428 1422
1429 memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0])); 1423 memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
1430 1424
1431 bdapq_m4_prefixes 1425 bdapq_m4_prefixes
1432 - = malloc (65536 * sizeof (const struct cris_opcode **));  
1433 - if (bdapq_m4_prefixes == NULL)  
1434 - return NULL; 1426 + = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1435 1427
1436 memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0])); 1428 memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
1437 1429
1438 rest_prefixes 1430 rest_prefixes
1439 - = malloc (65536 * sizeof (const struct cris_opcode **));  
1440 - if (rest_prefixes == NULL)  
1441 - return NULL; 1431 + = qemu_malloc (65536 * sizeof (const struct cris_opcode **));
1442 1432
1443 memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0])); 1433 memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
1444 } 1434 }
curses.c
@@ -361,8 +361,6 @@ void curses_display_init(DisplayState *ds, int full_screen) @@ -361,8 +361,6 @@ void curses_display_init(DisplayState *ds, int full_screen)
361 #endif 361 #endif
362 362
363 dcl = (DisplayChangeListener *) qemu_mallocz(sizeof(DisplayChangeListener)); 363 dcl = (DisplayChangeListener *) qemu_mallocz(sizeof(DisplayChangeListener));
364 - if (!dcl)  
365 - exit(1);  
366 dcl->dpy_update = curses_update; 364 dcl->dpy_update = curses_update;
367 dcl->dpy_resize = curses_resize; 365 dcl->dpy_resize = curses_resize;
368 dcl->dpy_refresh = curses_refresh; 366 dcl->dpy_refresh = curses_refresh;
device_tree.c
@@ -43,10 +43,6 @@ void *load_device_tree(const char *filename_path, void *load_addr) @@ -43,10 +43,6 @@ void *load_device_tree(const char *filename_path, void *load_addr)
43 43
44 /* First allocate space in qemu for device tree */ 44 /* First allocate space in qemu for device tree */
45 dt_file = qemu_mallocz(dt_file_size); 45 dt_file = qemu_mallocz(dt_file_size);
46 - if (dt_file == NULL) {  
47 - printf("Unable to allocate memory in qemu for device tree\n");  
48 - goto fail;  
49 - }  
50 46
51 dt_file_load_size = load_image(filename_path, dt_file); 47 dt_file_load_size = load_image(filename_path, dt_file);
52 48
@@ -476,10 +476,6 @@ static void code_gen_alloc(unsigned long tb_size) @@ -476,10 +476,6 @@ static void code_gen_alloc(unsigned long tb_size)
476 } 476 }
477 #else 477 #else
478 code_gen_buffer = qemu_malloc(code_gen_buffer_size); 478 code_gen_buffer = qemu_malloc(code_gen_buffer_size);
479 - if (!code_gen_buffer) {  
480 - fprintf(stderr, "Could not allocate dynamic translator buffer\n");  
481 - exit(1);  
482 - }  
483 map_exec(code_gen_buffer, code_gen_buffer_size); 479 map_exec(code_gen_buffer, code_gen_buffer_size);
484 #endif 480 #endif
485 #endif /* !USE_STATIC_CODE_GEN_BUFFER */ 481 #endif /* !USE_STATIC_CODE_GEN_BUFFER */
@@ -825,8 +821,6 @@ static void build_page_bitmap(PageDesc *p) @@ -825,8 +821,6 @@ static void build_page_bitmap(PageDesc *p)
825 TranslationBlock *tb; 821 TranslationBlock *tb;
826 822
827 p->code_bitmap = qemu_mallocz(TARGET_PAGE_SIZE / 8); 823 p->code_bitmap = qemu_mallocz(TARGET_PAGE_SIZE / 8);
828 - if (!p->code_bitmap)  
829 - return;  
830 824
831 tb = p->first_tb; 825 tb = p->first_tb;
832 while (tb != NULL) { 826 while (tb != NULL) {
@@ -1318,8 +1312,6 @@ int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len, @@ -1318,8 +1312,6 @@ int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len,
1318 return -EINVAL; 1312 return -EINVAL;
1319 } 1313 }
1320 wp = qemu_malloc(sizeof(*wp)); 1314 wp = qemu_malloc(sizeof(*wp));
1321 - if (!wp)  
1322 - return -ENOMEM;  
1323 1315
1324 wp->vaddr = addr; 1316 wp->vaddr = addr;
1325 wp->len_mask = len_mask; 1317 wp->len_mask = len_mask;
@@ -1384,8 +1376,6 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags, @@ -1384,8 +1376,6 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags,
1384 CPUBreakpoint *bp; 1376 CPUBreakpoint *bp;
1385 1377
1386 bp = qemu_malloc(sizeof(*bp)); 1378 bp = qemu_malloc(sizeof(*bp));
1387 - if (!bp)  
1388 - return -ENOMEM;  
1389 1379
1390 bp->pc = pc; 1380 bp->pc = pc;
1391 bp->flags = flags; 1381 bp->flags = flags;
@@ -2795,17 +2785,16 @@ static void *subpage_init (target_phys_addr_t base, ram_addr_t *phys, @@ -2795,17 +2785,16 @@ static void *subpage_init (target_phys_addr_t base, ram_addr_t *phys,
2795 int subpage_memory; 2785 int subpage_memory;
2796 2786
2797 mmio = qemu_mallocz(sizeof(subpage_t)); 2787 mmio = qemu_mallocz(sizeof(subpage_t));
2798 - if (mmio != NULL) {  
2799 - mmio->base = base;  
2800 - subpage_memory = cpu_register_io_memory(0, subpage_read, subpage_write, mmio); 2788 +
  2789 + mmio->base = base;
  2790 + subpage_memory = cpu_register_io_memory(0, subpage_read, subpage_write, mmio);
2801 #if defined(DEBUG_SUBPAGE) 2791 #if defined(DEBUG_SUBPAGE)
2802 - printf("%s: %p base " TARGET_FMT_plx " len %08x %d\n", __func__,  
2803 - mmio, base, TARGET_PAGE_SIZE, subpage_memory); 2792 + printf("%s: %p base " TARGET_FMT_plx " len %08x %d\n", __func__,
  2793 + mmio, base, TARGET_PAGE_SIZE, subpage_memory);
2804 #endif 2794 #endif
2805 - *phys = subpage_memory | IO_MEM_SUBPAGE;  
2806 - subpage_register(mmio, 0, TARGET_PAGE_SIZE - 1, orig_memory, 2795 + *phys = subpage_memory | IO_MEM_SUBPAGE;
  2796 + subpage_register(mmio, 0, TARGET_PAGE_SIZE - 1, orig_memory,
2807 region_offset); 2797 region_offset);
2808 - }  
2809 2798
2810 return mmio; 2799 return mmio;
2811 } 2800 }
gdbstub.c
@@ -2189,11 +2189,6 @@ static void gdb_accept(void) @@ -2189,11 +2189,6 @@ static void gdb_accept(void)
2189 setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val)); 2189 setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
2190 2190
2191 s = qemu_mallocz(sizeof(GDBState)); 2191 s = qemu_mallocz(sizeof(GDBState));
2192 - if (!s) {  
2193 - errno = ENOMEM;  
2194 - perror("accept");  
2195 - return;  
2196 - }  
2197 2192
2198 memset (s, 0, sizeof (GDBState)); 2193 memset (s, 0, sizeof (GDBState));
2199 s->c_cpu = first_cpu; 2194 s->c_cpu = first_cpu;
@@ -2311,9 +2306,6 @@ int gdbserver_start(const char *port) @@ -2311,9 +2306,6 @@ int gdbserver_start(const char *port)
2311 return -1; 2306 return -1;
2312 2307
2313 s = qemu_mallocz(sizeof(GDBState)); 2308 s = qemu_mallocz(sizeof(GDBState));
2314 - if (!s) {  
2315 - return -1;  
2316 - }  
2317 s->c_cpu = first_cpu; 2309 s->c_cpu = first_cpu;
2318 s->g_cpu = first_cpu; 2310 s->g_cpu = first_cpu;
2319 s->chr = chr; 2311 s->chr = chr;
keymaps.c
@@ -67,11 +67,9 @@ static void add_to_key_range(struct key_range **krp, int code) { @@ -67,11 +67,9 @@ static void add_to_key_range(struct key_range **krp, int code) {
67 } 67 }
68 if (kr == NULL) { 68 if (kr == NULL) {
69 kr = qemu_mallocz(sizeof(*kr)); 69 kr = qemu_mallocz(sizeof(*kr));
70 - if (kr) {  
71 - kr->start = kr->end = code;  
72 - kr->next = *krp;  
73 - *krp = kr;  
74 - } 70 + kr->start = kr->end = code;
  71 + kr->next = *krp;
  72 + *krp = kr;
75 } 73 }
76 } 74 }
77 75
@@ -88,8 +86,6 @@ static kbd_layout_t *parse_keyboard_layout(const char *language, @@ -88,8 +86,6 @@ static kbd_layout_t *parse_keyboard_layout(const char *language,
88 86
89 if (!k) 87 if (!k)
90 k = qemu_mallocz(sizeof(kbd_layout_t)); 88 k = qemu_mallocz(sizeof(kbd_layout_t));
91 - if (!k)  
92 - return 0;  
93 if (!(f = fopen(file_name, "r"))) { 89 if (!(f = fopen(file_name, "r"))) {
94 fprintf(stderr, 90 fprintf(stderr,
95 "Could not read keymap file: '%s'\n", file_name); 91 "Could not read keymap file: '%s'\n", file_name);
kvm-all.c
@@ -220,11 +220,6 @@ void kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_a @@ -220,11 +220,6 @@ void kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, target_phys_a
220 alloc_size = mem->memory_size >> TARGET_PAGE_BITS / sizeof(d.dirty_bitmap); 220 alloc_size = mem->memory_size >> TARGET_PAGE_BITS / sizeof(d.dirty_bitmap);
221 d.dirty_bitmap = qemu_mallocz(alloc_size); 221 d.dirty_bitmap = qemu_mallocz(alloc_size);
222 222
223 - if (d.dirty_bitmap == NULL) {  
224 - dprintf("Could not allocate dirty bitmap\n");  
225 - return;  
226 - }  
227 -  
228 d.slot = mem->slot; 223 d.slot = mem->slot;
229 dprintf("slot %d, phys_addr %llx, uaddr: %llx\n", 224 dprintf("slot %d, phys_addr %llx, uaddr: %llx\n",
230 d.slot, mem->start_addr, mem->phys_offset); 225 d.slot, mem->start_addr, mem->phys_offset);
@@ -295,8 +290,6 @@ int kvm_init(int smp_cpus) @@ -295,8 +290,6 @@ int kvm_init(int smp_cpus)
295 return -EINVAL; 290 return -EINVAL;
296 291
297 s = qemu_mallocz(sizeof(KVMState)); 292 s = qemu_mallocz(sizeof(KVMState));
298 - if (s == NULL)  
299 - return -ENOMEM;  
300 293
301 for (i = 0; i < ARRAY_SIZE(s->slots); i++) 294 for (i = 0; i < ARRAY_SIZE(s->slots); i++)
302 s->slots[i].slot = i; 295 s->slots[i].slot = i;
loader.c
@@ -266,8 +266,6 @@ static void *load_at(int fd, int offset, int size) @@ -266,8 +266,6 @@ static void *load_at(int fd, int offset, int size)
266 if (lseek(fd, offset, SEEK_SET) < 0) 266 if (lseek(fd, offset, SEEK_SET) < 0)
267 return NULL; 267 return NULL;
268 ptr = qemu_malloc(size); 268 ptr = qemu_malloc(size);
269 - if (!ptr)  
270 - return NULL;  
271 if (read(fd, ptr, size) != size) { 269 if (read(fd, ptr, size) != size) {
272 qemu_free(ptr); 270 qemu_free(ptr);
273 return NULL; 271 return NULL;
@@ -505,8 +503,6 @@ int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr, @@ -505,8 +503,6 @@ int load_uimage(const char *filename, target_ulong *ep, target_ulong *loadaddr,
505 503
506 *ep = hdr->ih_ep; 504 *ep = hdr->ih_ep;
507 data = qemu_malloc(hdr->ih_size); 505 data = qemu_malloc(hdr->ih_size);
508 - if (!data)  
509 - goto out;  
510 506
511 if (read(fd, data, hdr->ih_size) != hdr->ih_size) { 507 if (read(fd, data, hdr->ih_size) != hdr->ih_size) {
512 fprintf(stderr, "Error reading file\n"); 508 fprintf(stderr, "Error reading file\n");
migration-exec.c
@@ -61,10 +61,6 @@ MigrationState *exec_start_outgoing_migration(const char *command, @@ -61,10 +61,6 @@ MigrationState *exec_start_outgoing_migration(const char *command,
61 FILE *f; 61 FILE *f;
62 62
63 s = qemu_mallocz(sizeof(*s)); 63 s = qemu_mallocz(sizeof(*s));
64 - if (s == NULL) {  
65 - dprintf("Unable to allocate FdMigrationState\n");  
66 - goto err;  
67 - }  
68 64
69 f = popen(command, "w"); 65 f = popen(command, "w");
70 if (f == NULL) { 66 if (f == NULL) {
@@ -109,7 +105,6 @@ err_after_open: @@ -109,7 +105,6 @@ err_after_open:
109 pclose(f); 105 pclose(f);
110 err_after_alloc: 106 err_after_alloc:
111 qemu_free(s); 107 qemu_free(s);
112 -err:  
113 return NULL; 108 return NULL;
114 } 109 }
115 110
migration-tcp.c
@@ -89,8 +89,6 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port, @@ -89,8 +89,6 @@ MigrationState *tcp_start_outgoing_migration(const char *host_port,
89 return NULL; 89 return NULL;
90 90
91 s = qemu_mallocz(sizeof(*s)); 91 s = qemu_mallocz(sizeof(*s));
92 - if (s == NULL)  
93 - return NULL;  
94 92
95 s->get_error = socket_errno; 93 s->get_error = socket_errno;
96 s->write = socket_write; 94 s->write = socket_write;
monitor.c
@@ -1371,10 +1371,6 @@ static void do_wav_capture (const char *path, @@ -1371,10 +1371,6 @@ static void do_wav_capture (const char *path,
1371 CaptureState *s; 1371 CaptureState *s;
1372 1372
1373 s = qemu_mallocz (sizeof (*s)); 1373 s = qemu_mallocz (sizeof (*s));
1374 - if (!s) {  
1375 - term_printf ("Not enough memory to add wave capture\n");  
1376 - return;  
1377 - }  
1378 1374
1379 freq = has_freq ? freq : 44100; 1375 freq = has_freq ? freq : 44100;
1380 bits = has_bits ? bits : 16; 1376 bits = has_bits ? bits : 16;
@@ -333,8 +333,6 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan, @@ -333,8 +333,6 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
333 { 333 {
334 VLANClientState *vc, **pvc; 334 VLANClientState *vc, **pvc;
335 vc = qemu_mallocz(sizeof(VLANClientState)); 335 vc = qemu_mallocz(sizeof(VLANClientState));
336 - if (!vc)  
337 - return NULL;  
338 vc->model = strdup(model); 336 vc->model = strdup(model);
339 if (name) 337 if (name)
340 vc->name = strdup(name); 338 vc->name = strdup(name);
@@ -728,8 +726,6 @@ static TAPState *net_tap_fd_init(VLANState *vlan, @@ -728,8 +726,6 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
728 TAPState *s; 726 TAPState *s;
729 727
730 s = qemu_mallocz(sizeof(TAPState)); 728 s = qemu_mallocz(sizeof(TAPState));
731 - if (!s)  
732 - return NULL;  
733 s->fd = fd; 729 s->fd = fd;
734 s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, s); 730 s->vc = qemu_new_vlan_client(vlan, model, name, tap_receive, NULL, s);
735 #ifdef HAVE_IOVEC 731 #ifdef HAVE_IOVEC
@@ -1049,8 +1045,6 @@ static int net_vde_init(VLANState *vlan, const char *model, @@ -1049,8 +1045,6 @@ static int net_vde_init(VLANState *vlan, const char *model,
1049 }; 1045 };
1050 1046
1051 s = qemu_mallocz(sizeof(VDEState)); 1047 s = qemu_mallocz(sizeof(VDEState));
1052 - if (!s)  
1053 - return -1;  
1054 s->vde = vde_open(init_sock, "QEMU", &args); 1048 s->vde = vde_open(init_sock, "QEMU", &args);
1055 if (!s->vde){ 1049 if (!s->vde){
1056 free(s); 1050 free(s);
@@ -1274,8 +1268,6 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, @@ -1274,8 +1268,6 @@ static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan,
1274 } 1268 }
1275 1269
1276 s = qemu_mallocz(sizeof(NetSocketState)); 1270 s = qemu_mallocz(sizeof(NetSocketState));
1277 - if (!s)  
1278 - return NULL;  
1279 s->fd = fd; 1271 s->fd = fd;
1280 1272
1281 s->vc = qemu_new_vlan_client(vlan, model, name, net_socket_receive_dgram, NULL, s); 1273 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, @@ -1304,8 +1296,6 @@ static NetSocketState *net_socket_fd_init_stream(VLANState *vlan,
1304 { 1296 {
1305 NetSocketState *s; 1297 NetSocketState *s;
1306 s = qemu_mallocz(sizeof(NetSocketState)); 1298 s = qemu_mallocz(sizeof(NetSocketState));
1307 - if (!s)  
1308 - return NULL;  
1309 s->fd = fd; 1299 s->fd = fd;
1310 s->vc = qemu_new_vlan_client(vlan, model, name, 1300 s->vc = qemu_new_vlan_client(vlan, model, name,
1311 net_socket_receive, NULL, s); 1301 net_socket_receive, NULL, s);
@@ -1383,8 +1373,6 @@ static int net_socket_listen_init(VLANState *vlan, @@ -1383,8 +1373,6 @@ static int net_socket_listen_init(VLANState *vlan,
1383 return -1; 1373 return -1;
1384 1374
1385 s = qemu_mallocz(sizeof(NetSocketListenState)); 1375 s = qemu_mallocz(sizeof(NetSocketListenState));
1386 - if (!s)  
1387 - return -1;  
1388 1376
1389 fd = socket(PF_INET, SOCK_STREAM, 0); 1377 fd = socket(PF_INET, SOCK_STREAM, 0);
1390 if (fd < 0) { 1378 if (fd < 0) {
@@ -1504,8 +1492,6 @@ VLANState *qemu_find_vlan(int id) @@ -1504,8 +1492,6 @@ VLANState *qemu_find_vlan(int id)
1504 return vlan; 1492 return vlan;
1505 } 1493 }
1506 vlan = qemu_mallocz(sizeof(VLANState)); 1494 vlan = qemu_mallocz(sizeof(VLANState));
1507 - if (!vlan)  
1508 - return NULL;  
1509 vlan->id = id; 1495 vlan->id = id;
1510 vlan->next = NULL; 1496 vlan->next = NULL;
1511 pvlan = &first_vlan; 1497 pvlan = &first_vlan;
qemu-char.c
@@ -193,8 +193,6 @@ static CharDriverState *qemu_chr_open_null(void) @@ -193,8 +193,6 @@ static CharDriverState *qemu_chr_open_null(void)
193 CharDriverState *chr; 193 CharDriverState *chr;
194 194
195 chr = qemu_mallocz(sizeof(CharDriverState)); 195 chr = qemu_mallocz(sizeof(CharDriverState));
196 - if (!chr)  
197 - return NULL;  
198 chr->chr_write = null_chr_write; 196 chr->chr_write = null_chr_write;
199 return chr; 197 return chr;
200 } 198 }
@@ -425,13 +423,7 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv) @@ -425,13 +423,7 @@ static CharDriverState *qemu_chr_open_mux(CharDriverState *drv)
425 MuxDriver *d; 423 MuxDriver *d;
426 424
427 chr = qemu_mallocz(sizeof(CharDriverState)); 425 chr = qemu_mallocz(sizeof(CharDriverState));
428 - if (!chr)  
429 - return NULL;  
430 d = qemu_mallocz(sizeof(MuxDriver)); 426 d = qemu_mallocz(sizeof(MuxDriver));
431 - if (!d) {  
432 - free(chr);  
433 - return NULL;  
434 - }  
435 427
436 chr->opaque = d; 428 chr->opaque = d;
437 d->drv = drv; 429 d->drv = drv;
@@ -576,13 +568,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out) @@ -576,13 +568,7 @@ static CharDriverState *qemu_chr_open_fd(int fd_in, int fd_out)
576 FDCharDriver *s; 568 FDCharDriver *s;
577 569
578 chr = qemu_mallocz(sizeof(CharDriverState)); 570 chr = qemu_mallocz(sizeof(CharDriverState));
579 - if (!chr)  
580 - return NULL;  
581 s = qemu_mallocz(sizeof(FDCharDriver)); 571 s = qemu_mallocz(sizeof(FDCharDriver));
582 - if (!s) {  
583 - free(chr);  
584 - return NULL;  
585 - }  
586 s->fd_in = fd_in; 572 s->fd_in = fd_in;
587 s->fd_out = fd_out; 573 s->fd_out = fd_out;
588 chr->opaque = s; 574 chr->opaque = s;
@@ -929,13 +915,7 @@ static CharDriverState *qemu_chr_open_pty(void) @@ -929,13 +915,7 @@ static CharDriverState *qemu_chr_open_pty(void)
929 #endif 915 #endif
930 916
931 chr = qemu_mallocz(sizeof(CharDriverState)); 917 chr = qemu_mallocz(sizeof(CharDriverState));
932 - if (!chr)  
933 - return NULL;  
934 s = qemu_mallocz(sizeof(PtyCharDriver)); 918 s = qemu_mallocz(sizeof(PtyCharDriver));
935 - if (!s) {  
936 - qemu_free(chr);  
937 - return NULL;  
938 - }  
939 919
940 if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) { 920 if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
941 return NULL; 921 return NULL;
@@ -1246,19 +1226,10 @@ static CharDriverState *qemu_chr_open_pp(const char *filename) @@ -1246,19 +1226,10 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
1246 } 1226 }
1247 1227
1248 drv = qemu_mallocz(sizeof(ParallelCharDriver)); 1228 drv = qemu_mallocz(sizeof(ParallelCharDriver));
1249 - if (!drv) {  
1250 - close(fd);  
1251 - return NULL;  
1252 - }  
1253 drv->fd = fd; 1229 drv->fd = fd;
1254 drv->mode = IEEE1284_MODE_COMPAT; 1230 drv->mode = IEEE1284_MODE_COMPAT;
1255 1231
1256 chr = qemu_mallocz(sizeof(CharDriverState)); 1232 chr = qemu_mallocz(sizeof(CharDriverState));
1257 - if (!chr) {  
1258 - qemu_free(drv);  
1259 - close(fd);  
1260 - return NULL;  
1261 - }  
1262 chr->chr_write = null_chr_write; 1233 chr->chr_write = null_chr_write;
1263 chr->chr_ioctl = pp_ioctl; 1234 chr->chr_ioctl = pp_ioctl;
1264 chr->chr_close = pp_close; 1235 chr->chr_close = pp_close;
@@ -1318,10 +1289,6 @@ static CharDriverState *qemu_chr_open_pp(const char *filename) @@ -1318,10 +1289,6 @@ static CharDriverState *qemu_chr_open_pp(const char *filename)
1318 return NULL; 1289 return NULL;
1319 1290
1320 chr = qemu_mallocz(sizeof(CharDriverState)); 1291 chr = qemu_mallocz(sizeof(CharDriverState));
1321 - if (!chr) {  
1322 - close(fd);  
1323 - return NULL;  
1324 - }  
1325 chr->opaque = (void *)fd; 1292 chr->opaque = (void *)fd;
1326 chr->chr_write = null_chr_write; 1293 chr->chr_write = null_chr_write;
1327 chr->chr_ioctl = pp_ioctl; 1294 chr->chr_ioctl = pp_ioctl;
@@ -1535,13 +1502,7 @@ static CharDriverState *qemu_chr_open_win(const char *filename) @@ -1535,13 +1502,7 @@ static CharDriverState *qemu_chr_open_win(const char *filename)
1535 WinCharState *s; 1502 WinCharState *s;
1536 1503
1537 chr = qemu_mallocz(sizeof(CharDriverState)); 1504 chr = qemu_mallocz(sizeof(CharDriverState));
1538 - if (!chr)  
1539 - return NULL;  
1540 s = qemu_mallocz(sizeof(WinCharState)); 1505 s = qemu_mallocz(sizeof(WinCharState));
1541 - if (!s) {  
1542 - free(chr);  
1543 - return NULL;  
1544 - }  
1545 chr->opaque = s; 1506 chr->opaque = s;
1546 chr->chr_write = win_chr_write; 1507 chr->chr_write = win_chr_write;
1547 chr->chr_close = win_chr_close; 1508 chr->chr_close = win_chr_close;
@@ -1640,13 +1601,7 @@ static CharDriverState *qemu_chr_open_win_pipe(const char *filename) @@ -1640,13 +1601,7 @@ static CharDriverState *qemu_chr_open_win_pipe(const char *filename)
1640 WinCharState *s; 1601 WinCharState *s;
1641 1602
1642 chr = qemu_mallocz(sizeof(CharDriverState)); 1603 chr = qemu_mallocz(sizeof(CharDriverState));
1643 - if (!chr)  
1644 - return NULL;  
1645 s = qemu_mallocz(sizeof(WinCharState)); 1604 s = qemu_mallocz(sizeof(WinCharState));
1646 - if (!s) {  
1647 - free(chr);  
1648 - return NULL;  
1649 - }  
1650 chr->opaque = s; 1605 chr->opaque = s;
1651 chr->chr_write = win_chr_write; 1606 chr->chr_write = win_chr_write;
1652 chr->chr_close = win_chr_close; 1607 chr->chr_close = win_chr_close;
@@ -1666,13 +1621,7 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out) @@ -1666,13 +1621,7 @@ static CharDriverState *qemu_chr_open_win_file(HANDLE fd_out)
1666 WinCharState *s; 1621 WinCharState *s;
1667 1622
1668 chr = qemu_mallocz(sizeof(CharDriverState)); 1623 chr = qemu_mallocz(sizeof(CharDriverState));
1669 - if (!chr)  
1670 - return NULL;  
1671 s = qemu_mallocz(sizeof(WinCharState)); 1624 s = qemu_mallocz(sizeof(WinCharState));
1672 - if (!s) {  
1673 - free(chr);  
1674 - return NULL;  
1675 - }  
1676 s->hcom = fd_out; 1625 s->hcom = fd_out;
1677 chr->opaque = s; 1626 chr->opaque = s;
1678 chr->chr_write = win_chr_write; 1627 chr->chr_write = win_chr_write;
@@ -1774,11 +1723,7 @@ static CharDriverState *qemu_chr_open_udp(const char *def) @@ -1774,11 +1723,7 @@ static CharDriverState *qemu_chr_open_udp(const char *def)
1774 struct sockaddr_in saddr; 1723 struct sockaddr_in saddr;
1775 1724
1776 chr = qemu_mallocz(sizeof(CharDriverState)); 1725 chr = qemu_mallocz(sizeof(CharDriverState));
1777 - if (!chr)  
1778 - goto return_err;  
1779 s = qemu_mallocz(sizeof(NetCharDriver)); 1726 s = qemu_mallocz(sizeof(NetCharDriver));
1780 - if (!s)  
1781 - goto return_err;  
1782 1727
1783 fd = socket(PF_INET, SOCK_DGRAM, 0); 1728 fd = socket(PF_INET, SOCK_DGRAM, 0);
1784 if (fd < 0) { 1729 if (fd < 0) {
@@ -2044,11 +1989,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str, @@ -2044,11 +1989,7 @@ static CharDriverState *qemu_chr_open_tcp(const char *host_str,
2044 is_waitconnect = 0; 1989 is_waitconnect = 0;
2045 1990
2046 chr = qemu_mallocz(sizeof(CharDriverState)); 1991 chr = qemu_mallocz(sizeof(CharDriverState));
2047 - if (!chr)  
2048 - goto fail;  
2049 s = qemu_mallocz(sizeof(TCPCharDriver)); 1992 s = qemu_mallocz(sizeof(TCPCharDriver));
2050 - if (!s)  
2051 - goto fail;  
2052 1993
2053 if (is_listen) { 1994 if (is_listen) {
2054 chr->filename = qemu_malloc(256); 1995 chr->filename = qemu_malloc(256);
qemu-nbd.c
@@ -409,8 +409,6 @@ int main(int argc, char **argv) @@ -409,8 +409,6 @@ int main(int argc, char **argv)
409 } 409 }
410 410
411 sharing_fds = qemu_malloc((shared + 1) * sizeof(int)); 411 sharing_fds = qemu_malloc((shared + 1) * sizeof(int));
412 - if (sharing_fds == NULL)  
413 - errx(ENOMEM, "Cannot allocate sharing fds");  
414 412
415 if (socket) { 413 if (socket) {
416 sharing_fds[0] = unix_socket_incoming(socket); 414 sharing_fds[0] = unix_socket_incoming(socket);
qemu-tool.c
@@ -43,10 +43,8 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) @@ -43,10 +43,8 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
43 QEMUBH *bh; 43 QEMUBH *bh;
44 44
45 bh = qemu_malloc(sizeof(*bh)); 45 bh = qemu_malloc(sizeof(*bh));
46 - if (bh) {  
47 - bh->cb = cb;  
48 - bh->opaque = opaque;  
49 - } 46 + bh->cb = cb;
  47 + bh->opaque = opaque;
50 48
51 return bh; 49 return bh;
52 } 50 }
readline.c
@@ -307,8 +307,6 @@ static void term_completion(void) @@ -307,8 +307,6 @@ static void term_completion(void)
307 nb_completions = 0; 307 nb_completions = 0;
308 308
309 cmdline = qemu_malloc(term_cmd_buf_index + 1); 309 cmdline = qemu_malloc(term_cmd_buf_index + 1);
310 - if (!cmdline)  
311 - return;  
312 memcpy(cmdline, term_cmd_buf, term_cmd_buf_index); 310 memcpy(cmdline, term_cmd_buf, term_cmd_buf_index);
313 cmdline[term_cmd_buf_index] = '\0'; 311 cmdline[term_cmd_buf_index] = '\0';
314 readline_find_completion(cmdline); 312 readline_find_completion(cmdline);
savevm.c
@@ -214,10 +214,6 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode) @@ -214,10 +214,6 @@ QEMUFile *qemu_popen(FILE *popen_file, const char *mode)
214 } 214 }
215 215
216 s = qemu_mallocz(sizeof(QEMUFilePopen)); 216 s = qemu_mallocz(sizeof(QEMUFilePopen));
217 - if (!s) {  
218 - fprintf(stderr, "qemu_popen: malloc failed\n");  
219 - return NULL;  
220 - }  
221 217
222 s->popen_file = popen_file; 218 s->popen_file = popen_file;
223 219
@@ -246,9 +242,6 @@ QEMUFile *qemu_fopen_socket(int fd) @@ -246,9 +242,6 @@ QEMUFile *qemu_fopen_socket(int fd)
246 { 242 {
247 QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket)); 243 QEMUFileSocket *s = qemu_mallocz(sizeof(QEMUFileSocket));
248 244
249 - if (s == NULL)  
250 - return NULL;  
251 -  
252 s->fd = fd; 245 s->fd = fd;
253 s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close, NULL); 246 s->file = qemu_fopen_ops(s, NULL, socket_get_buffer, socket_close, NULL);
254 return s->file; 247 return s->file;
@@ -288,8 +281,6 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode) @@ -288,8 +281,6 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
288 QEMUFileStdio *s; 281 QEMUFileStdio *s;
289 282
290 s = qemu_mallocz(sizeof(QEMUFileStdio)); 283 s = qemu_mallocz(sizeof(QEMUFileStdio));
291 - if (!s)  
292 - return NULL;  
293 284
294 s->outfile = fopen(filename, mode); 285 s->outfile = fopen(filename, mode);
295 if (!s->outfile) 286 if (!s->outfile)
@@ -339,8 +330,6 @@ static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_wr @@ -339,8 +330,6 @@ static QEMUFile *qemu_fopen_bdrv(BlockDriverState *bs, int64_t offset, int is_wr
339 QEMUFileBdrv *s; 330 QEMUFileBdrv *s;
340 331
341 s = qemu_mallocz(sizeof(QEMUFileBdrv)); 332 s = qemu_mallocz(sizeof(QEMUFileBdrv));
342 - if (!s)  
343 - return NULL;  
344 333
345 s->bs = bs; 334 s->bs = bs;
346 s->base_offset = offset; 335 s->base_offset = offset;
@@ -359,8 +348,6 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer, @@ -359,8 +348,6 @@ QEMUFile *qemu_fopen_ops(void *opaque, QEMUFilePutBufferFunc *put_buffer,
359 QEMUFile *f; 348 QEMUFile *f;
360 349
361 f = qemu_mallocz(sizeof(QEMUFile)); 350 f = qemu_mallocz(sizeof(QEMUFile));
362 - if (!f)  
363 - return NULL;  
364 351
365 f->opaque = opaque; 352 f->opaque = opaque;
366 f->put_buffer = put_buffer; 353 f->put_buffer = put_buffer;
@@ -615,8 +602,6 @@ int register_savevm_live(const char *idstr, @@ -615,8 +602,6 @@ int register_savevm_live(const char *idstr,
615 static int global_section_id; 602 static int global_section_id;
616 603
617 se = qemu_malloc(sizeof(SaveStateEntry)); 604 se = qemu_malloc(sizeof(SaveStateEntry));
618 - if (!se)  
619 - return -1;  
620 pstrcpy(se->idstr, sizeof(se->idstr), idstr); 605 pstrcpy(se->idstr, sizeof(se->idstr), idstr);
621 se->instance_id = (instance_id == -1) ? 0 : instance_id; 606 se->instance_id = (instance_id == -1) ? 0 : instance_id;
622 se->version_id = version_id; 607 se->version_id = version_id;
@@ -908,10 +893,6 @@ int qemu_loadvm_state(QEMUFile *f) @@ -908,10 +893,6 @@ int qemu_loadvm_state(QEMUFile *f)
908 893
909 /* Add entry */ 894 /* Add entry */
910 le = qemu_mallocz(sizeof(*le)); 895 le = qemu_mallocz(sizeof(*le));
911 - if (le == NULL) {  
912 - ret = -ENOMEM;  
913 - goto out;  
914 - }  
915 896
916 le->se = se; 897 le->se = se;
917 le->section_id = section_id; 898 le->section_id = section_id;
@@ -638,8 +638,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) @@ -638,8 +638,6 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
638 } 638 }
639 639
640 dcl = qemu_mallocz(sizeof(DisplayChangeListener)); 640 dcl = qemu_mallocz(sizeof(DisplayChangeListener));
641 - if (!dcl)  
642 - exit(1);  
643 dcl->dpy_update = sdl_update; 641 dcl->dpy_update = sdl_update;
644 dcl->dpy_resize = sdl_resize; 642 dcl->dpy_resize = sdl_resize;
645 dcl->dpy_refresh = sdl_refresh; 643 dcl->dpy_refresh = sdl_refresh;
usb-bsd.c
@@ -340,8 +340,6 @@ USBDevice *usb_host_device_open(const char *devname) @@ -340,8 +340,6 @@ USBDevice *usb_host_device_open(const char *devname)
340 340
341 if (dfd >= 0) { 341 if (dfd >= 0) {
342 dev = qemu_mallocz(sizeof(USBHostDevice)); 342 dev = qemu_mallocz(sizeof(USBHostDevice));
343 - if (!dev)  
344 - goto fail;  
345 dev->devfd = dfd; 343 dev->devfd = dfd;
346 344
347 if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) { 345 if (ioctl(dfd, USB_GET_DEVICEINFO, &dev_info) < 0) {
usb-linux.c
@@ -441,10 +441,6 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket *p) @@ -441,10 +441,6 @@ static int usb_host_handle_data(USBHostDevice *s, USBPacket *p)
441 int ret; 441 int ret;
442 442
443 aurb = async_alloc(); 443 aurb = async_alloc();
444 - if (!aurb) {  
445 - dprintf("husb: async malloc failed\n");  
446 - return USB_RET_NAK;  
447 - }  
448 aurb->hdev = s; 444 aurb->hdev = s;
449 aurb->packet = p; 445 aurb->packet = p;
450 446
@@ -585,10 +581,6 @@ static int usb_host_handle_control(USBHostDevice *s, USBPacket *p) @@ -585,10 +581,6 @@ static int usb_host_handle_control(USBHostDevice *s, USBPacket *p)
585 /* The rest are asynchronous */ 581 /* The rest are asynchronous */
586 582
587 aurb = async_alloc(); 583 aurb = async_alloc();
588 - if (!aurb) {  
589 - dprintf("husb: async malloc failed\n");  
590 - return USB_RET_NAK;  
591 - }  
592 aurb->hdev = s; 584 aurb->hdev = s;
593 aurb->packet = p; 585 aurb->packet = p;
594 586
@@ -898,8 +890,6 @@ static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *p @@ -898,8 +890,6 @@ static USBDevice *usb_host_device_open_addr(int bus_num, int addr, const char *p
898 char buf[1024]; 890 char buf[1024];
899 891
900 dev = qemu_mallocz(sizeof(USBHostDevice)); 892 dev = qemu_mallocz(sizeof(USBHostDevice));
901 - if (!dev)  
902 - goto fail;  
903 893
904 dev->bus_num = bus_num; 894 dev->bus_num = bus_num;
905 dev->addr = addr; 895 dev->addr = addr;
@@ -1308,14 +1298,8 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) @@ -1308,14 +1298,8 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
1308 1298
1309 /* the module setting (used later for opening devices) */ 1299 /* the module setting (used later for opening devices) */
1310 usb_host_device_path = qemu_mallocz(strlen(devpath)+1); 1300 usb_host_device_path = qemu_mallocz(strlen(devpath)+1);
1311 - if (usb_host_device_path) {  
1312 - strcpy(usb_host_device_path, devpath);  
1313 - term_printf("husb: using %s file-system with %s\n", fs_type[usb_fs_type], usb_host_device_path);  
1314 - } else {  
1315 - /* out of memory? */  
1316 - perror("husb: unable to allocate memory for device path");  
1317 - return -ENOMEM;  
1318 - } 1301 + strcpy(usb_host_device_path, devpath);
  1302 + term_printf("husb: using %s file-system with %s\n", fs_type[usb_fs_type], usb_host_device_path);
1319 } 1303 }
1320 1304
1321 switch (usb_fs_type) { 1305 switch (usb_fs_type) {
@@ -1455,10 +1439,6 @@ static int usb_host_auto_add(const char *spec) @@ -1455,10 +1439,6 @@ static int usb_host_auto_add(const char *spec)
1455 return -1; 1439 return -1;
1456 1440
1457 f = qemu_mallocz(sizeof(*f)); 1441 f = qemu_mallocz(sizeof(*f));
1458 - if (!f) {  
1459 - fprintf(stderr, "husb: failed to allocate auto filter\n");  
1460 - return -1;  
1461 - }  
1462 1442
1463 *f = filter; 1443 *f = filter;
1464 1444
@@ -546,8 +546,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func, @@ -546,8 +546,6 @@ QEMUPutMouseEntry *qemu_add_mouse_event_handler(QEMUPutMouseEvent *func,
546 QEMUPutMouseEntry *s, *cursor; 546 QEMUPutMouseEntry *s, *cursor;
547 547
548 s = qemu_mallocz(sizeof(QEMUPutMouseEntry)); 548 s = qemu_mallocz(sizeof(QEMUPutMouseEntry));
549 - if (!s)  
550 - return NULL;  
551 549
552 s->qemu_put_mouse_event = func; 550 s->qemu_put_mouse_event = func;
553 s->qemu_put_mouse_event_opaque = opaque; 551 s->qemu_put_mouse_event_opaque = opaque;
@@ -1098,8 +1096,6 @@ static QEMUClock *qemu_new_clock(int type) @@ -1098,8 +1096,6 @@ static QEMUClock *qemu_new_clock(int type)
1098 { 1096 {
1099 QEMUClock *clock; 1097 QEMUClock *clock;
1100 clock = qemu_mallocz(sizeof(QEMUClock)); 1098 clock = qemu_mallocz(sizeof(QEMUClock));
1101 - if (!clock)  
1102 - return NULL;  
1103 clock->type = type; 1099 clock->type = type;
1104 return clock; 1100 return clock;
1105 } 1101 }
@@ -2808,10 +2804,6 @@ DisplayState *get_displaystate(void) @@ -2808,10 +2804,6 @@ DisplayState *get_displaystate(void)
2808 static void dumb_display_init(void) 2804 static void dumb_display_init(void)
2809 { 2805 {
2810 DisplayState *ds = qemu_mallocz(sizeof(DisplayState)); 2806 DisplayState *ds = qemu_mallocz(sizeof(DisplayState));
2811 - if (ds == NULL) {  
2812 - fprintf(stderr, "dumb_display_init: DisplayState allocation failed\n");  
2813 - exit(1);  
2814 - }  
2815 ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4); 2807 ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4);
2816 register_displaystate(ds); 2808 register_displaystate(ds);
2817 } 2809 }
@@ -2863,8 +2855,6 @@ int qemu_set_fd_handler2(int fd, @@ -2863,8 +2855,6 @@ int qemu_set_fd_handler2(int fd,
2863 goto found; 2855 goto found;
2864 } 2856 }
2865 ioh = qemu_mallocz(sizeof(IOHandlerRecord)); 2857 ioh = qemu_mallocz(sizeof(IOHandlerRecord));
2866 - if (!ioh)  
2867 - return -1;  
2868 ioh->next = first_io_handler; 2858 ioh->next = first_io_handler;
2869 first_io_handler = ioh; 2859 first_io_handler = ioh;
2870 found: 2860 found:
@@ -2902,8 +2892,6 @@ int qemu_add_polling_cb(PollingFunc *func, void *opaque) @@ -2902,8 +2892,6 @@ int qemu_add_polling_cb(PollingFunc *func, void *opaque)
2902 { 2892 {
2903 PollingEntry **ppe, *pe; 2893 PollingEntry **ppe, *pe;
2904 pe = qemu_mallocz(sizeof(PollingEntry)); 2894 pe = qemu_mallocz(sizeof(PollingEntry));
2905 - if (!pe)  
2906 - return -1;  
2907 pe->func = func; 2895 pe->func = func;
2908 pe->opaque = opaque; 2896 pe->opaque = opaque;
2909 for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next); 2897 for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
@@ -3273,8 +3261,6 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) @@ -3273,8 +3261,6 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque)
3273 { 3261 {
3274 QEMUBH *bh; 3262 QEMUBH *bh;
3275 bh = qemu_mallocz(sizeof(QEMUBH)); 3263 bh = qemu_mallocz(sizeof(QEMUBH));
3276 - if (!bh)  
3277 - return NULL;  
3278 bh->cb = cb; 3264 bh->cb = cb;
3279 bh->opaque = opaque; 3265 bh->opaque = opaque;
3280 bh->next = first_bh; 3266 bh->next = first_bh;
@@ -3432,8 +3418,6 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, @@ -3432,8 +3418,6 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
3432 VMChangeStateEntry *e; 3418 VMChangeStateEntry *e;
3433 3419
3434 e = qemu_mallocz(sizeof (*e)); 3420 e = qemu_mallocz(sizeof (*e));
3435 - if (!e)  
3436 - return NULL;  
3437 3421
3438 e->cb = cb; 3422 e->cb = cb;
3439 e->opaque = opaque; 3423 e->opaque = opaque;
@@ -471,8 +471,8 @@ static void send_framebuffer_update_hextile(VncState *vs, int x, int y, int w, i @@ -471,8 +471,8 @@ static void send_framebuffer_update_hextile(VncState *vs, int x, int y, int w, i
471 int has_fg, has_bg; 471 int has_fg, has_bg;
472 uint8_t *last_fg, *last_bg; 472 uint8_t *last_fg, *last_bg;
473 473
474 - last_fg = (uint8_t *) malloc(vs->serverds.pf.bytes_per_pixel);  
475 - last_bg = (uint8_t *) malloc(vs->serverds.pf.bytes_per_pixel); 474 + last_fg = (uint8_t *) qemu_malloc(vs->serverds.pf.bytes_per_pixel);
  475 + last_bg = (uint8_t *) qemu_malloc(vs->serverds.pf.bytes_per_pixel);
476 has_fg = has_bg = 0; 476 has_fg = has_bg = 0;
477 for (j = y; j < (y + h); j += 16) { 477 for (j = y; j < (y + h); j += 16) {
478 for (i = x; i < (x + w); i += 16) { 478 for (i = x; i < (x + w); i += 16) {
@@ -2237,8 +2237,6 @@ void vnc_display_init(DisplayState *ds) @@ -2237,8 +2237,6 @@ void vnc_display_init(DisplayState *ds)
2237 2237
2238 vs = qemu_mallocz(sizeof(VncState)); 2238 vs = qemu_mallocz(sizeof(VncState));
2239 dcl = qemu_mallocz(sizeof(DisplayChangeListener)); 2239 dcl = qemu_mallocz(sizeof(DisplayChangeListener));
2240 - if (!vs || !dcl)  
2241 - exit(1);  
2242 2240
2243 ds->opaque = vs; 2241 ds->opaque = vs;
2244 dcl->idle = 1; 2242 dcl->idle = 1;
@@ -2289,8 +2287,7 @@ static int vnc_set_x509_credential(VncState *vs, @@ -2289,8 +2287,7 @@ static int vnc_set_x509_credential(VncState *vs,
2289 *cred = NULL; 2287 *cred = NULL;
2290 } 2288 }
2291 2289
2292 - if (!(*cred = qemu_malloc(strlen(certdir) + strlen(filename) + 2)))  
2293 - return -1; 2290 + *cred = qemu_malloc(strlen(certdir) + strlen(filename) + 2);
2294 2291
2295 strcpy(*cred, certdir); 2292 strcpy(*cred, certdir);
2296 strcat(*cred, "/"); 2293 strcat(*cred, "/");