From nobody Sat Feb 7 08:54:58 2026 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=1639421979; cv=none; d=zohomail.com; s=zohoarc; b=ZBWW3KWGkAKKYDP/Z8Ogms8FWQLZEplk0BnavrHdznrZ7mG4ucPwIsItYxW7mCpdsWdd35490LB0GChGsQWfnz2Iid8fdcRC2I8NW3CoJzmnfx243aybz1SBjgtPAg1vqSuD5OXiVmynnpXRiOU/OO1gX9xk8+Lxz0nxoZlTYiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639421979; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gsKYWCL7xwqBL6GxmEVB/jIk1XnmLca6JOlFKlw3n64=; b=WVozqUUoOaMmNlgoIDyyH33ZXRrpNHE2sKqgnAHL3E632aupqglN8FDwj6TMnr6gzz5ax1pDr+0BfKxlBmh5J9PXyHAb8ViqgvizK1mxVnF0153Q/l3FYdplsiVo1GirQjGTBTu8vAAyNAuqohH3Grqh7mTMNoy+JfpUIm76ntI= 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 1639421979341751.9062435070203; Mon, 13 Dec 2021 10:59:39 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-uVDmve6COrO1_qHkzJVbEg-1; Mon, 13 Dec 2021 13:59:34 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47807102C87E; Mon, 13 Dec 2021 18:59:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D823C5F4EA; Mon, 13 Dec 2021 18:59:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A66C61809CB8; Mon, 13 Dec 2021 18:59:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1BDIxE4E006839 for ; Mon, 13 Dec 2021 13:59:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 87B4DADCB; Mon, 13 Dec 2021 18:59:14 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F5E65E272 for ; Mon, 13 Dec 2021 18:59:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639421978; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gsKYWCL7xwqBL6GxmEVB/jIk1XnmLca6JOlFKlw3n64=; b=GgwiAFTI2vZmZcJQlz6ykD2kAfS50HjlRhlekIU5Dibi1Jgx1AFhsuixb/tbURZzGo1h7v xKbcFJeA5mV+8d5rgsHa2j0xWbPJ9SrcDzTlO0T9o3rZi5UqYfMSQPqdF1ZP4EMxKZZRnT HELqMo+UK49WiPTErJdnc6VPc67jKeg= X-MC-Unique: uVDmve6COrO1_qHkzJVbEg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/5] util: dnsmasq: refactor CapsRefresh Date: Mon, 13 Dec 2021 19:58:47 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1639421980126100003 Use two variables with automatic cleanup instead of reusing one. Remove the pointless cleanup label. Signed-off-by: J=C3=A1n Tomko --- src/util/virdnsmasq.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 2dd9a20377..b62e353ceb 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -666,9 +666,9 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) static int dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool force) { - int ret =3D -1; struct stat sb; - virCommand *cmd =3D NULL; + g_autoptr(virCommand) vercmd =3D NULL; + g_autoptr(virCommand) helpcmd =3D NULL; g_autofree char *help =3D NULL; g_autofree char *version =3D NULL; g_autofree char *complete =3D NULL; @@ -692,31 +692,26 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool fo= rce) if (!virFileIsExecutable(caps->binaryPath)) { virReportSystemError(errno, _("dnsmasq binary %s is not executable= "), caps->binaryPath); - goto cleanup; + return -1; } =20 - cmd =3D virCommandNewArgList(caps->binaryPath, "--version", NULL); - virCommandSetOutputBuffer(cmd, &version); - virCommandAddEnvPassCommon(cmd); - virCommandClearCaps(cmd); - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; - virCommandFree(cmd); + vercmd =3D virCommandNewArgList(caps->binaryPath, "--version", NULL); + virCommandSetOutputBuffer(vercmd, &version); + virCommandAddEnvPassCommon(vercmd); + virCommandClearCaps(vercmd); + if (virCommandRun(vercmd, NULL) < 0) + return -1; =20 - cmd =3D virCommandNewArgList(caps->binaryPath, "--help", NULL); - virCommandSetOutputBuffer(cmd, &help); - virCommandAddEnvPassCommon(cmd); - virCommandClearCaps(cmd); - if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + helpcmd =3D virCommandNewArgList(caps->binaryPath, "--help", NULL); + virCommandSetOutputBuffer(helpcmd, &help); + virCommandAddEnvPassCommon(helpcmd); + virCommandClearCaps(helpcmd); + if (virCommandRun(helpcmd, NULL) < 0) + return -1; =20 complete =3D g_strdup_printf("%s\n%s", version, help); =20 - ret =3D dnsmasqCapsSetFromBuffer(caps, complete); - - cleanup: - virCommandFree(cmd); - return ret; + return dnsmasqCapsSetFromBuffer(caps, complete); } =20 static dnsmasqCaps * --=20 2.31.1