From c3033fd372fdaf5b89190136a74b3d78880b85d6 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 13 Jan 2021 16:10:12 -0600 Subject: 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 Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Markus Armbruster Message-Id: <20210113221013.390592-5-eblake@redhat.com> Signed-off-by: Markus Armbruster --- crypto/block-luks.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'crypto') diff --git a/crypto/block-luks.c b/crypto/block-luks.c index 564caa1094..fe8f04ffb2 100644 --- a/crypto/block-luks.c +++ b/crypto/block-luks.c @@ -1885,7 +1885,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block, { QCryptoBlockLUKS *luks = block->opaque; QCryptoBlockInfoLUKSSlot *slot; - QCryptoBlockInfoLUKSSlotList *slots = NULL, **prev = &info->u.luks.slots; + QCryptoBlockInfoLUKSSlotList **tail = &info->u.luks.slots; size_t i; info->u.luks.cipher_alg = luks->cipher_alg; @@ -1902,10 +1902,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block, sizeof(luks->header.uuid)); for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) { - slots = g_new0(QCryptoBlockInfoLUKSSlotList, 1); - *prev = slots; - - slots->value = slot = g_new0(QCryptoBlockInfoLUKSSlot, 1); + slot = g_new0(QCryptoBlockInfoLUKSSlot, 1); slot->active = luks->header.key_slots[i].active == QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED; slot->key_offset = luks->header.key_slots[i].key_offset_sector @@ -1917,7 +1914,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block, slot->stripes = luks->header.key_slots[i].stripes; } - prev = &slots->next; + QAPI_LIST_APPEND(tail, slot); } return 0; -- cgit 1.4.1