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,
especially where we do "v = g_malloc(sizeof(*v) * n)", but it's merely
four years old, and we can't use such newfangled stuff.
This commit does not touch allocations with size arguments that don't
use sizeof. We can make them safe by converting to g_malloc_n() when
the newfangled stuff becomes available to us in a couple of years.
Signed-off-by: Markus Armbruster <address@hidden>
---
block/bochs.c | 2 +-
block/parallels.c | 2 +-
block/qcow2-cache.c | 2 +-
block/qed-check.c | 3 +--
block/rbd.c | 2 +-
block/sheepdog.c | 2 +-
hw/block/dataplane/ioq.c | 4 ++--
hw/block/nvme.c | 8 ++++----
8 files changed, 12 insertions(+), 13 deletions(-)