xemu/hw/block
Markus Armbruster 02c4f26b15 block: Use g_new() & friends to avoid multiplying sizes
g_new(T, n) is safer than g_malloc(sizeof(*v) * n) for two reasons.
One, it catches multiplication overflowing size_t.  Two, it returns
T * rather than void *, which lets the compiler catch more type
errors.

Perhaps a conversion to g_malloc_n() would be neater in places, but
that's merely four years old, and we can't use such newfangled stuff.

This commit only touches allocations with size arguments of the form
sizeof(T), plus two that use 4 instead of sizeof(uint32_t).  We can
make the others safe by converting to g_malloc_n() when it becomes
available to us in a couple of years.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2014-08-20 11:51:28 +02:00
..
dataplane dataplane: stop trying on notifier error 2014-08-15 18:03:13 +01:00
block.c hw: move target-independent files to subdirectories 2013-04-08 18:13:12 +02:00
cdrom.c bswap.h: Remove cpu_to_be32wu() 2013-11-05 19:57:47 -08:00
ecc.c savevm: Remove all the unneeded version_minimum_id_old (arm) 2014-05-13 16:09:35 +01:00
fdc.c savevm: Remove all the unneeded version_minimum_id_old (x86) 2014-06-16 04:55:26 +02:00
hd-geometry.c hw: move target-independent files to subdirectories 2013-04-08 18:13:12 +02:00
m25p80.c block: m25p80: Support read only bdrvs. 2014-06-21 16:40:14 +08:00
Makefile.objs pc_sysfw: do not make it a device anymore 2013-08-12 09:31:14 -05:00
nand.c savevm: Remove all the unneeded version_minimum_id_old (arm) 2014-05-13 16:09:35 +01:00
nvme.c block: Use g_new() & friends to avoid multiplying sizes 2014-08-20 11:51:28 +02:00
nvme.h NVMe: Initial commit for new storage interface 2013-06-17 17:47:59 +02:00
onenand.c block: Drop superfluous conditionals around g_free() 2014-06-16 17:23:19 +08:00
pflash_cfi01.c memory: remove memory_region_destroy 2014-08-18 12:06:21 +02:00
pflash_cfi02.c memory: remove memory_region_destroy 2014-08-18 12:06:21 +02:00
tc58128.c shix: Don't require firmware presence for qtest 2013-11-05 17:47:29 +01:00
virtio-blk.c virtio-blk: Correct bug in support for flexible descriptor layout 2014-08-15 18:03:14 +01:00
xen_blkif.h xen_disk: add discard support 2014-05-07 16:18:04 +00:00
xen_disk.c xen_disk: fix possible null-ptr dereference 2014-08-15 15:07:13 +02:00