qemu-patch-raspberry4/block
Markus Armbruster 5839e53bbc block: Use g_new() & friends where that makes obvious sense
g_new(T, n) is neater than g_malloc(sizeof(T) * n).  It's also safer,
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.

Patch created with Coccinelle, with two manual changes on top:

* Add const to bdrv_iterate_format() to keep the types straight

* Convert the allocation in bdrv_drop_intermediate(), which Coccinelle
  inexplicably misses

Coccinelle semantic patch:

    @@
    type T;
    @@
    -g_malloc(sizeof(T))
    +g_new(T, 1)
    @@
    type T;
    @@
    -g_try_malloc(sizeof(T))
    +g_try_new(T, 1)
    @@
    type T;
    @@
    -g_malloc0(sizeof(T))
    +g_new0(T, 1)
    @@
    type T;
    @@
    -g_try_malloc0(sizeof(T))
    +g_try_new0(T, 1)
    @@
    type T;
    expression n;
    @@
    -g_malloc(sizeof(T) * (n))
    +g_new(T, n)
    @@
    type T;
    expression n;
    @@
    -g_try_malloc(sizeof(T) * (n))
    +g_try_new(T, n)
    @@
    type T;
    expression n;
    @@
    -g_malloc0(sizeof(T) * (n))
    +g_new0(T, n)
    @@
    type T;
    expression n;
    @@
    -g_try_malloc0(sizeof(T) * (n))
    +g_try_new0(T, n)
    @@
    type T;
    expression p, n;
    @@
    -g_realloc(p, sizeof(T) * (n))
    +g_renew(T, p, n)
    @@
    type T;
    expression p, n;
    @@
    -g_try_realloc(p, sizeof(T) * (n))
    +g_try_renew(T, p, n)

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
..
archipelago.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
backup.c block/backup: Fix hang for unaligned image size 2014-07-09 15:50:11 +02:00
blkdebug.c blkdebug: report errors on flush too 2014-08-15 18:03:11 +01:00
blkverify.c blkverify: implement .bdrv_detach/attach_aio_context() 2014-06-04 09:56:11 +02:00
bochs.c bochs: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
cloop.c cloop: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
commit.c block: extend block-commit to accept a string for the backing file 2014-07-01 10:47:01 +02:00
cow.c block/cow: Avoid use of uninitialized cow_bs in error path 2014-07-01 10:15:34 +02:00
curl.c curl: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
dmg.c dmg: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
gluster.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
iscsi.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
linux-aio.c linux-aio: Fix laio resource leak 2014-07-15 15:34:13 +02:00
Makefile.objs block: Support Archipelago as a QEMU block backend 2014-08-15 15:07:14 +02:00
mirror.c mirror: Handle failure for potentially large allocations 2014-08-15 15:07:16 +02:00
nbd-client.c nbd: implement .bdrv_detach/attach_aio_context() 2014-06-04 09:56:11 +02:00
nbd-client.h nbd: implement .bdrv_detach/attach_aio_context() 2014-06-04 09:56:11 +02:00
nbd.c nbd: implement .bdrv_detach/attach_aio_context() 2014-06-04 09:56:11 +02:00
nfs.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
parallels.c parallels: 2TB+ parallels images support 2014-08-15 18:03:13 +01:00
qapi.c qemu-img info: show nocow info 2014-08-15 15:07:14 +02:00
qcow.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
qcow2-cache.c qcow2: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
qcow2-cluster.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
qcow2-refcount.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
qcow2-snapshot.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
qcow2.c qcow2: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
qcow2.h qcow2: Limit snapshot table size 2014-04-01 15:22:35 +02:00
qed-check.c qed: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
qed-cluster.c Use glib memory allocation and free functions 2011-08-20 23:01:08 -05:00
qed-gencb.c Use glib memory allocation and free functions 2011-08-20 23:01:08 -05:00
qed-l2-cache.c qed: do not evict in-use L2 table cache entries 2012-03-12 15:14:06 +01:00
qed-table.c qed: use BlockDriverState's AioContext 2014-06-04 09:56:11 +02:00
qed.c qed: Handle failure for potentially large allocations 2014-08-15 15:07:15 +02:00
qed.h qed: Make qiov match request size until backing file EOF 2014-07-14 12:03:20 +02:00
quorum.c quorum: Add the rewrite-corrupted parameter to quorum 2014-06-27 14:18:17 +02:00
raw-aio.h linux-aio: implement io plug, unplug and flush io queue 2014-07-07 11:05:17 +02:00
raw-posix.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
raw-win32.c cleanup QEMUOptionParameter 2014-06-16 17:23:21 +08:00
raw_bsd.c block: Add Error argument to bdrv_refresh_limits() 2014-07-18 13:18:43 +01:00
rbd.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
sheepdog.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
snapshot.c Use error_is_set() only when necessary 2014-02-17 11:57:23 -05:00
ssh.c cleanup QEMUOptionParameter 2014-06-16 17:23:21 +08:00
stream.c block: Add Error argument to bdrv_refresh_limits() 2014-07-18 13:18:43 +01:00
vdi.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
vhdx-endian.c block: VHDX endian fixes 2014-08-15 15:07:14 +02:00
vhdx-log.c vhdx: Handle failure for potentially large allocations 2014-08-15 15:07:16 +02:00
vhdx.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
vhdx.h block: VHDX endian fixes 2014-08-15 15:07:14 +02:00
vmdk.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
vpc.c vpc: Handle failure for potentially large allocations 2014-08-15 15:07:16 +02:00
vvfat.c block: Use g_new() & friends where that makes obvious sense 2014-08-20 11:51:28 +02:00
win32-aio.c raw-win32: Handle failure for potentially large allocations 2014-08-15 15:07:16 +02:00