aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2-bitmap.c
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2021-01-13 16:10:12 -0600
committerMarkus Armbruster <armbru@redhat.com>2021-01-28 08:08:45 +0100
commitc3033fd372fdaf5b89190136a74b3d78880b85d6 (patch)
tree6c2464ae3f51b43702c448606acb3a6c21b6b634 /block/qcow2-bitmap.c
parentdc13f40c6ba291e31d09053815c230ed88c8921f (diff)
downloadqemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.zip
qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.gz
qemu-c3033fd372fdaf5b89190136a74b3d78880b85d6.tar.bz2
qapi: Use QAPI_LIST_APPEND in trivial cases
The easiest spots to use QAPI_LIST_APPEND are where we already have an obvious pointer to the tail of a list. While at it, consistently use the variable name 'tail' for that purpose. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210113221013.390592-5-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'block/qcow2-bitmap.c')
-rw-r--r--block/qcow2-bitmap.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index d7a31a8..5eef82f 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1061,7 +1061,7 @@ fail:
static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
{
Qcow2BitmapInfoFlagsList *list = NULL;
- Qcow2BitmapInfoFlagsList **plist = &list;
+ Qcow2BitmapInfoFlagsList **tail = &list;
int i;
static const struct {
@@ -1076,11 +1076,7 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
for (i = 0; i < map_size; ++i) {
if (flags & map[i].bme) {
- Qcow2BitmapInfoFlagsList *entry =
- g_new0(Qcow2BitmapInfoFlagsList, 1);
- entry->value = map[i].info;
- *plist = entry;
- plist = &entry->next;
+ QAPI_LIST_APPEND(tail, map[i].info);
flags &= ~map[i].bme;
}
}
@@ -1105,7 +1101,7 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
Qcow2BitmapList *bm_list;
Qcow2Bitmap *bm;
Qcow2BitmapInfoList *list = NULL;
- Qcow2BitmapInfoList **plist = &list;
+ Qcow2BitmapInfoList **tail = &list;
if (s->nb_bitmaps == 0) {
return NULL;
@@ -1119,13 +1115,10 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1);
- Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1);
info->granularity = 1U << bm->granularity_bits;
info->name = g_strdup(bm->name);
info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS);
- obj->value = info;
- *plist = obj;
- plist = &obj->next;
+ QAPI_LIST_APPEND(tail, info);
}
bitmap_list_free(bm_list);