Wrap the macro body in a new block and move the declaration of 'tmp'
into it, to avoid the need to mix g_autofree with manual freeing.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_driver.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 056b5cec98..f3c9730cd8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -18396,7 +18396,6 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
g_autoptr(virBitmap) vcpus = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID);
g_autoptr(virBitmap) online = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID);
g_autoptr(virBitmap) offlinable = virBitmapNew(QEMU_GUEST_VCPU_MAX_ID);
- g_autofree char *tmp = NULL;
size_t i;
int ret = -1;
@@ -18416,11 +18415,13 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPtr *params,
}
#define ADD_BITMAP(name) \
- if (!(tmp = virBitmapFormat(name))) \
- goto cleanup; \
- if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0) \
- goto cleanup; \
- VIR_FREE(tmp)
+ do { \
+ g_autofree char *tmp = NULL; \
+ if (!(tmp = virBitmapFormat(name))) \
+ goto cleanup; \
+ if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0)
\
+ goto cleanup; \
+ } while (0)
ADD_BITMAP(vcpus);
ADD_BITMAP(online);
--
2.41.0