g_malloc(0) and g_malloc0(0) return NULL; simplify
Once upon a time, it was decided that qemu_malloc(0) should abort. Switching to glib retired that bright idea. Some code that was added to cope with it (e.g. in commits702ef63
,b76b6e9
) is still around. Bury it. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
74cef80c47
commit
6528499fa4
@ -737,11 +737,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
|
|||||||
* l1_table_offset when it is the current s->l1_table_offset! Be careful
|
* l1_table_offset when it is the current s->l1_table_offset! Be careful
|
||||||
* when changing this! */
|
* when changing this! */
|
||||||
if (l1_table_offset != s->l1_table_offset) {
|
if (l1_table_offset != s->l1_table_offset) {
|
||||||
if (l1_size2 != 0) {
|
l1_table = g_malloc0(align_offset(l1_size2, 512));
|
||||||
l1_table = g_malloc0(align_offset(l1_size2, 512));
|
|
||||||
} else {
|
|
||||||
l1_table = NULL;
|
|
||||||
}
|
|
||||||
l1_allocated = 1;
|
l1_allocated = 1;
|
||||||
if (bdrv_pread(bs->file, l1_table_offset,
|
if (bdrv_pread(bs->file, l1_table_offset,
|
||||||
l1_table, l1_size2) != l1_size2)
|
l1_table, l1_size2) != l1_size2)
|
||||||
|
@ -443,9 +443,7 @@ static int vdi_open(BlockDriverState *bs, int flags)
|
|||||||
|
|
||||||
bmap_size = header.blocks_in_image * sizeof(uint32_t);
|
bmap_size = header.blocks_in_image * sizeof(uint32_t);
|
||||||
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
|
bmap_size = (bmap_size + SECTOR_SIZE - 1) / SECTOR_SIZE;
|
||||||
if (bmap_size > 0) {
|
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
|
||||||
s->bmap = g_malloc(bmap_size * SECTOR_SIZE);
|
|
||||||
}
|
|
||||||
ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
|
ret = bdrv_read(bs->file, s->bmap_sector, (uint8_t *)s->bmap, bmap_size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto fail_free_bmap;
|
goto fail_free_bmap;
|
||||||
|
@ -3101,11 +3101,7 @@ static void v9fs_xattrcreate(void *opaque)
|
|||||||
xattr_fidp->fs.xattr.flags = flags;
|
xattr_fidp->fs.xattr.flags = flags;
|
||||||
v9fs_string_init(&xattr_fidp->fs.xattr.name);
|
v9fs_string_init(&xattr_fidp->fs.xattr.name);
|
||||||
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
|
v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name);
|
||||||
if (size) {
|
xattr_fidp->fs.xattr.value = g_malloc(size);
|
||||||
xattr_fidp->fs.xattr.value = g_malloc(size);
|
|
||||||
} else {
|
|
||||||
xattr_fidp->fs.xattr.value = NULL;
|
|
||||||
}
|
|
||||||
err = offset;
|
err = offset;
|
||||||
put_fid(pdu, file_fidp);
|
put_fid(pdu, file_fidp);
|
||||||
out_nofid:
|
out_nofid:
|
||||||
|
@ -269,11 +269,8 @@ static inline void vhost_dev_log_resize(struct vhost_dev* dev, uint64_t size)
|
|||||||
vhost_log_chunk_t *log;
|
vhost_log_chunk_t *log;
|
||||||
uint64_t log_base;
|
uint64_t log_base;
|
||||||
int r, i;
|
int r, i;
|
||||||
if (size) {
|
|
||||||
log = g_malloc0(size * sizeof *log);
|
log = g_malloc0(size * sizeof *log);
|
||||||
} else {
|
|
||||||
log = NULL;
|
|
||||||
}
|
|
||||||
log_base = (uint64_t)(unsigned long)log;
|
log_base = (uint64_t)(unsigned long)log;
|
||||||
r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);
|
r = ioctl(dev->control, VHOST_SET_LOG_BASE, &log_base);
|
||||||
assert(r >= 0);
|
assert(r >= 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user