In both cases we need memory for a 'struct sanlk_resource' followed by
one 'struct sanlk_disk', thus there's no risk of overflow.
Use g_malloc0 and sizeof() to allocate the memory instead of
VIR_ALLOC_VAR.
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
g_autofree struct sanlk_resource *res = NULL;
size_t i;
- if (VIR_ALLOC_VAR(res, struct sanlk_disk, 1) < 0)
- return -1;
+ res = g_malloc0(sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk));
res->flags = shared ? SANLK_RES_SHARED : 0;
res->num_disks = 1;
return -1;
}
- if (VIR_ALLOC_VAR(res, struct sanlk_disk, 1) < 0)
- return -1;
+ res = g_malloc0(sizeof(struct sanlk_resource) + sizeof(struct sanlk_disk));
res->flags = shared ? SANLK_RES_SHARED : 0;
res->num_disks = 1;