From nobody Fri May 17 20:27:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695995572; cv=none; d=zohomail.com; s=zohoarc; b=dAKjjOj4o3BmvVW71+JcRtefxNbUf4cudBsVjV4Jb1Bcsmfy99Yzp9tU0G57Ht6rdyQjZL7jMUb2jXz5QwCZKBiKGaTsZuXYZZVNcsy3CFInBSeErg4s8F1dy6pMMuh4G1EN/wyLMt/k7TYJ1yciJmvvN6PDtcuXi0PEw8gqVMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695995572; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dgajRz9XA+MYdI42+rcnk74FSLx1vj24DHfP+RfcSB4=; b=La1cuBOtB5xkLw8UU2iLFayeFLHZX4X1J4hg8dLKvduGHlkkLaUhbYO4sOtLz2FPWE8QJNzXIjR2cgbpXTGrD2Eu41T+Z11J9sqF0UnMcGMe/tqgVqrhpiaTTiSwOcVwd16waKHGe1D9PWSMjlEX8FUFE0WIZ9bc2TGBVuG8kfg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1695995572108266.76421567199577; Fri, 29 Sep 2023 06:52:52 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-448-hZ9JrOTyOFSx_tT1z1qegg-1; Fri, 29 Sep 2023 09:52:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F815802D35; Fri, 29 Sep 2023 13:52:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id A53FD40C6EBF; Fri, 29 Sep 2023 13:52:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 588291946587; Fri, 29 Sep 2023 13:52:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4CFF41946586 for ; Fri, 29 Sep 2023 13:48:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2BA6A2026D68; Fri, 29 Sep 2023 13:48:47 +0000 (UTC) Received: from fedora.. (unknown [10.45.225.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5D082026D4B for ; Fri, 29 Sep 2023 13:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695995571; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dgajRz9XA+MYdI42+rcnk74FSLx1vj24DHfP+RfcSB4=; b=UfwkDFN7UZSVkaPFQJeh5gxbd3NBH4k1pVdQLL8BSnz9fzpzAQy0qnc90V9rwj5bFxWla4 Yuo6pOQEjLyhoW19sFq8f5cI2PTavj+7HNOVSdV15SNFU1okw2xa17a0+6UMkmeKatQtMy xH+2UatLDf2Om1pJPWWZ6cVM2XaS1Oo= X-MC-Unique: hZ9JrOTyOFSx_tT1z1qegg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH] qemu: DomainGetGuestVcpusParams: reduce scope of tmp Date: Fri, 29 Sep 2023 15:48:40 +0200 Message-ID: <3ae7b5f7f5c692f32e1f5891e9abffe7cd582a69.1695995320.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695995574284100001 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=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- 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 =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); g_autoptr(virBitmap) online =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_ID); g_autoptr(virBitmap) offlinable =3D virBitmapNew(QEMU_GUEST_VCPU_MAX_I= D); - g_autofree char *tmp =3D NULL; size_t i; int ret =3D -1; =20 @@ -18416,11 +18415,13 @@ qemuDomainGetGuestVcpusParams(virTypedParameterPt= r *params, } =20 #define ADD_BITMAP(name) \ - if (!(tmp =3D virBitmapFormat(name))) \ - goto cleanup; \ - if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0) \ - goto cleanup; \ - VIR_FREE(tmp) + do { \ + g_autofree char *tmp =3D NULL; \ + if (!(tmp =3D virBitmapFormat(name))) \ + goto cleanup; \ + if (virTypedParamsAddString(&par, &npar, &maxpar, #name, tmp) < 0)= \ + goto cleanup; \ + } while (0) =20 ADD_BITMAP(vcpus); ADD_BITMAP(online); --=20 2.41.0