From nobody Tue Apr 30 13:36:39 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=1642516696; cv=none; d=zohomail.com; s=zohoarc; b=muljw81RjM/hKF0R63Ape8u5p/yg1N+w0uBfiPyP3MkevzuNIivFGS3ZYaAsFkbZxX+uqzWJchriVEXiRS0yE5tMLNm3e+dHRK6fcdVTiMZO/xDYQECoqecvRCtolDyK6A+/t2jLSoHaeAHFlGvoqTsrg5jnjKc8OF6qv8ezrq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516696; 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=HOI5MO/DnZeIVglUEGzJi9Fae+jqF5Hn5EAjFmVBxv4=; b=BCX9/utauzh2Fk62oilp4Mun2IY3mrpcXeUsMPBwSnkVpZVfrCbEt8XsTB9BfmA2HROK+3WX1zJYYthLeymOMOTJKYDqujqIhu65ePT1h9k8o/WcZZYaUZh87YgYBo+qrls400X4613YniX4GvXZDTejgvDvm+vWEiD/dwSdKr8= 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 1642516696709666.430649212989; Tue, 18 Jan 2022 06:38:16 -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-146-y1CafkNRPe-NlckLCXSKbA-1; Tue, 18 Jan 2022 09:38:13 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72D6E36393; Tue, 18 Jan 2022 14:38:08 +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 DD819753D1; Tue, 18 Jan 2022 14:38:07 +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 F09191809CB8; Tue, 18 Jan 2022 14:38:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbe5k016620 for ; Tue, 18 Jan 2022 09:37:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5BE652C1AE; Tue, 18 Jan 2022 14:37:40 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9FFF2BE7F for ; Tue, 18 Jan 2022 14:37:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516695; 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=HOI5MO/DnZeIVglUEGzJi9Fae+jqF5Hn5EAjFmVBxv4=; b=HA69u6MxP1+kPta4afYaSPz8JOUyqE23GrVt4PqgFjb2s7eGESqerGG43OkWgKeQrr0TNq RujINoHJePKN0t0SOIzmZtRLpHul5dDsCIvigl8pkvROjPNid32dXDArVGoMR2/BoBIDTr zi/hrPNdoTclXAo5lNz6AR9bMkbfyxI= X-MC-Unique: y1CafkNRPe-NlckLCXSKbA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 01/13] virdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty() Date: Tue, 18 Jan 2022 15:37:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516698758100001 Content-Type: text/plain; charset="utf-8" Both callers of dnsmasqCapsNewEmpty() pass DNSMASQ as an argument which is then fed to a ternary operator which looks like this (after substitution). DNSMASQ ? DNSMASQ : DNSMASQ While I like tautologies, the code can be simplified by dropping the argument. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index e5edec2b64..d304929d51 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -700,7 +700,7 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool forc= e) } =20 static dnsmasqCaps * -dnsmasqCapsNewEmpty(const char *binaryPath) +dnsmasqCapsNewEmpty(void) { dnsmasqCaps *caps; =20 @@ -708,14 +708,14 @@ dnsmasqCapsNewEmpty(const char *binaryPath) return NULL; if (!(caps =3D virObjectNew(dnsmasqCapsClass))) return NULL; - caps->binaryPath =3D g_strdup(binaryPath ? binaryPath : DNSMASQ); + caps->binaryPath =3D g_strdup(DNSMASQ); return caps; } =20 dnsmasqCaps * dnsmasqCapsNewFromBuffer(const char *buf) { - dnsmasqCaps *caps =3D dnsmasqCapsNewEmpty(DNSMASQ); + dnsmasqCaps *caps =3D dnsmasqCapsNewEmpty(); =20 if (!caps) return NULL; @@ -730,7 +730,7 @@ dnsmasqCapsNewFromBuffer(const char *buf) dnsmasqCaps * dnsmasqCapsNewFromBinary(void) { - dnsmasqCaps *caps =3D dnsmasqCapsNewEmpty(DNSMASQ); + dnsmasqCaps *caps =3D dnsmasqCapsNewEmpty(); =20 if (!caps) return NULL; --=20 2.34.1 From nobody Tue Apr 30 13:36:39 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=1642516710; cv=none; d=zohomail.com; s=zohoarc; b=TlFs7VsuAefW7k83YIjulLAlgSp2K3hcmv8e3VJW8ZEfp84DtDCL0rR/3/H3wbEf+DvPou3tvfwJwwiqhD2xVyhFjbrdvqk4qVqt7TbfR+7xq6kBdVnaw9eO0AY9mBA5syt94rE73XyaVpgE/iYoUd6F02cHiTlvDUa6lZxb2j4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516710; 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=b3e0gRN6udBkXMGafKzRDLMBMV1kkYef/j97eJKy7y4=; b=CfrhlNIwC9Ku0om/CBqSrN6PbzIH3f7h3G8RC/um9Ac/JNlfQibAWAzgge7j/5TpLBux7iwr/MflCtuvvfCql1N3YkMABrBN33Yctq/fxytRW8vAUXtw4rsKJEnVzaBPg0MVMcaKWmH5VEKx4hWA5QdrcSmGTRy8EahXmi3jy/Q= 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 1642516710894414.10612688317246; Tue, 18 Jan 2022 06:38:30 -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-480-Q50uBWDKOImcwb6zNP8J0w-1; Tue, 18 Jan 2022 09:38:27 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D16ED3E75E; Tue, 18 Jan 2022 14:38:21 +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 A654D753CF; Tue, 18 Jan 2022 14:38:21 +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 6C43F1809CB9; Tue, 18 Jan 2022 14:38:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbf8D016629 for ; Tue, 18 Jan 2022 09:37:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2C0652C1AE; Tue, 18 Jan 2022 14:37:41 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA4B32BE7F for ; Tue, 18 Jan 2022 14:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516709; 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=b3e0gRN6udBkXMGafKzRDLMBMV1kkYef/j97eJKy7y4=; b=By05OMKTa1trPHcmzsYgx9m8fg792D1acYnR/df24wgVmmNV9Y39oUXJQL5tpTcHx4qkMr 35o2ZkKuMng3VCdavpvPjjtNPAAWWADnQFuWyHM8TbCvq5MLH8YDxs7J3MwuahOY2Vcm1d 1/EmD95PfQeCRAyF84gNrwJKhJu0TUQ= X-MC-Unique: Q50uBWDKOImcwb6zNP8J0w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 02/13] lib: Prefer g_autoptr(dnsmasqCaps) instead of explicit unref Date: Tue, 18 Jan 2022 15:37:09 +0100 Message-Id: <6944c78d38d8e2f1531ca713cd0c51746765909a.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516713057100001 Content-Type: text/plain; charset="utf-8" The dnsmasqCaps type has its own cleanup function defined and ready to use via g_autoptr(). Use automatic cleanup instead of an explicit one. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 22 ++++++++++------------ tests/networkxml2conftest.c | 7 +++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index d304929d51..9f3da1d5e6 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -702,44 +702,42 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool fo= rce) static dnsmasqCaps * dnsmasqCapsNewEmpty(void) { - dnsmasqCaps *caps; + g_autoptr(dnsmasqCaps) caps =3D NULL; =20 if (dnsmasqCapsInitialize() < 0) return NULL; if (!(caps =3D virObjectNew(dnsmasqCapsClass))) return NULL; caps->binaryPath =3D g_strdup(DNSMASQ); - return caps; + return g_steal_pointer(&caps); } =20 dnsmasqCaps * dnsmasqCapsNewFromBuffer(const char *buf) { - dnsmasqCaps *caps =3D dnsmasqCapsNewEmpty(); + g_autoptr(dnsmasqCaps) caps =3D dnsmasqCapsNewEmpty(); =20 if (!caps) return NULL; =20 - if (dnsmasqCapsSetFromBuffer(caps, buf) < 0) { - virObjectUnref(caps); + if (dnsmasqCapsSetFromBuffer(caps, buf) < 0) return NULL; - } - return caps; + + return g_steal_pointer(&caps); } =20 dnsmasqCaps * dnsmasqCapsNewFromBinary(void) { - dnsmasqCaps *caps =3D dnsmasqCapsNewEmpty(); + g_autoptr(dnsmasqCaps) caps =3D dnsmasqCapsNewEmpty(); =20 if (!caps) return NULL; =20 - if (dnsmasqCapsRefreshInternal(caps, true) < 0) { - virObjectUnref(caps); + if (dnsmasqCapsRefreshInternal(caps, true) < 0) return NULL; - } - return caps; + + return g_steal_pointer(&caps); } =20 const char * diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 178c74d9af..d79c2b4783 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -112,8 +112,9 @@ static int mymain(void) { int ret =3D 0; - dnsmasqCaps *full - =3D dnsmasqCapsNewFromBuffer("Dnsmasq version 2.67\n--bind-dynamic= \n--ra-param"); + g_autoptr(dnsmasqCaps) full =3D NULL; + + full =3D dnsmasqCapsNewFromBuffer("Dnsmasq version 2.67\n--bind-dynami= c\n--ra-param"); =20 #define DO_TEST(xname, xcaps) \ do { \ @@ -154,8 +155,6 @@ mymain(void) DO_TEST("leasetime-hours", full); DO_TEST("leasetime-infinite", full); =20 - virObjectUnref(full); - return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 --=20 2.34.1 From nobody Tue Apr 30 13:36:39 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=1642516715; cv=none; d=zohomail.com; s=zohoarc; b=QvBY/JgbIKUNp2oYgAzTgwdSK/Rsrln3X7BQh7cpt7xwqIJUUp2XO2rX1/3RVyHV8+f++m/K/V5k3Pk2GWiO3M/P191sHFWqJWUuN+5f4IbnT8JyukZrXhKeGYgzSJpZoe5zwfGH/BwJodJuZz6ah2Z9d3QSSskI8uANuXMbm2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516715; 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=UPC+7fuFSJv4tIKCapoFLX2lh+S5a6RvFIrfIMb8gMI=; b=eM+stcKIvQ0AGTx2XFGvp+/xA4vUqFQzQiDDNZ14LWhAMjvYyAx0L89yIzoqgWNjV39JaIWcU3nNy5HhgivR4psYwO8gusGWbl+6OUL1yFGhFdL+LcGcl5ZSIAbtRmy9P/YonwNMTTFXGgcScIEOg2Bpz9yOGIFa9Z2/3VS8isM= 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 1642516715226172.1279492778391; Tue, 18 Jan 2022 06:38:35 -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-308-uCQKAEm8ORm72wpZ60CULA-1; Tue, 18 Jan 2022 09:38:30 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F37683DD2C; Tue, 18 Jan 2022 14:38:25 +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 5B8027E12C; Tue, 18 Jan 2022 14:38: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 F184B1809CBF; Tue, 18 Jan 2022 14:38:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbfRN016636 for ; Tue, 18 Jan 2022 09:37:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id EFBC82BE7F; Tue, 18 Jan 2022 14:37:41 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 798392C1B4 for ; Tue, 18 Jan 2022 14:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516714; 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=UPC+7fuFSJv4tIKCapoFLX2lh+S5a6RvFIrfIMb8gMI=; b=G10NiWwJt35kpLzaT1/CwD0scoratrGKFTaA0FWNw0XP2ckyOBFKUnbeGL0Y+NwQw3NwcJ MwILZhqXRHP9vY0k6AqVFO7z9IRTaTf5emOGdj8Th6hk2PFj5I79BZ11nGbIv5VUujuMcb CuBiOwNk0VKYHtXSNxoYqg835vGwIfQ= X-MC-Unique: uCQKAEm8ORm72wpZ60CULA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 03/13] virdnsmasq: Drop @force argument of dnsmasqCapsRefreshInternal() Date: Tue, 18 Jan 2022 15:37:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516716341100001 Content-Type: text/plain; charset="utf-8" This argument is not used really as the only caller passes true and dnsmasqCapsRefreshInternal() only checks for false value. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 9f3da1d5e6..7fcaadda3f 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -649,7 +649,7 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) } =20 static int -dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool force) +dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) { struct stat sb; g_autoptr(virCommand) vercmd =3D NULL; @@ -666,7 +666,7 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool forc= e) caps->binaryPath); return -1; } - if (!force && caps->mtime =3D=3D sb.st_mtime) + if (caps->mtime =3D=3D sb.st_mtime) return 0; caps->mtime =3D sb.st_mtime; =20 @@ -734,7 +734,7 @@ dnsmasqCapsNewFromBinary(void) if (!caps) return NULL; =20 - if (dnsmasqCapsRefreshInternal(caps, true) < 0) + if (dnsmasqCapsRefreshInternal(caps) < 0) return NULL; =20 return g_steal_pointer(&caps); --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516791; cv=none; d=zohomail.com; s=zohoarc; b=GO3sOcNRrVVOl5/BJ6qA03sr5W0GRX0WQDiq5ppjkmLTLAHi5m4NnQE7AEo2xvQN+Zo2pj8gsZlZ84xTN0Rx783sh34pPBFWanWyQhejwMBthSIOS2Zar0aNzL0jLR07vJHUYBfwDgEu6J4LH/bFahvGdAYoo5n9nQFxgMthaFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516791; 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=dQbLwTVQv161uSsoOt8JMJjGu/0CuMKWn7/cu0vkN+M=; b=IHTTWu3x0TzbzaiSW8wMEegpzfJyejl8V98jSFiN0LuUC4SiIdXid5kYe2lc6K3pllEveWr3/lIiQKooLC337Q1M0k4J6s4ar4MWgxBgHk56unFCr0S6+aW9xjzWuVeeoECbuN8hCl966il88BR7K3vZ1d5kDhwzp1l0/1B+rh8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642516791081648.7913253416822; Tue, 18 Jan 2022 06:39:51 -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-465-61lDXJe7Nki2Fu71V6IQ-A-1; Tue, 18 Jan 2022 09:39:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 31F4E6D24F; Tue, 18 Jan 2022 14:39:43 +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 13F0C798C4; Tue, 18 Jan 2022 14:39:43 +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 AEA541806D2D; Tue, 18 Jan 2022 14:39:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbgx4016645 for ; Tue, 18 Jan 2022 09:37:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id C3A952BE7F; Tue, 18 Jan 2022 14:37:42 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AA852C1AE for ; Tue, 18 Jan 2022 14:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516790; 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=dQbLwTVQv161uSsoOt8JMJjGu/0CuMKWn7/cu0vkN+M=; b=H/b4WLwsh0nhxn0zLO4msjuT/KAFfn9urJzN4+dEjxOg+hPDhGQDxsPL5lDHH1+idzAjiV a+suLRcQVaBh5RsUIqLujjCKYa51Qftn/gq9H+FtJc4VKGGK9X2qADYKGn7B8mCAKe2LRU +VbN5KOTJNHsXArU8WjKGFgVOaf+IS8= X-MC-Unique: 61lDXJe7Nki2Fu71V6IQ-A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 04/13] virdnsmasq: Drop mtime member from struct _dnsmasqCaps Date: Tue, 18 Jan 2022 15:37:11 +0100 Message-Id: <0a7224a1471e294175a9e1295ba846580f6c54e7.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516792762100001 Content-Type: text/plain; charset="utf-8" The _dnsmasqCaps struct has @mtime member which holds the mtime of the dnsmasq binary. The idea was that capabilities don't need to be queried if mtime hasn't changed since the last time. However, the code that would try to query capabilities again was removed and now we are left with code that stores mtime but has no use for it. Remove the member and code that uses it. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 7fcaadda3f..c3801d622f 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -577,7 +577,6 @@ struct _dnsmasqCaps { virObject parent; char *binaryPath; bool noRefresh; - time_t mtime; unsigned long version; }; =20 @@ -651,7 +650,6 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) static int dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) { - struct stat sb; g_autoptr(virCommand) vercmd =3D NULL; g_autoptr(virCommand) helpcmd =3D NULL; g_autofree char *help =3D NULL; @@ -661,15 +659,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) if (!caps || caps->noRefresh) return 0; =20 - if (stat(caps->binaryPath, &sb) < 0) { - virReportSystemError(errno, _("Cannot check dnsmasq binary %s"), - caps->binaryPath); - return -1; - } - if (caps->mtime =3D=3D sb.st_mtime) - return 0; - caps->mtime =3D sb.st_mtime; - /* Make sure the binary we are about to try exec'ing exists. * Technically we could catch the exec() failure, but that's * in a sub-process so it's hard to feed back a useful error. --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516718; cv=none; d=zohomail.com; s=zohoarc; b=VFEkjO8XXZw0XeYIOtZf4UN8Dt3RN3Vx5N6TLulxci49m4uGR9xsp020LpWZaCuPK15jHp6TX0+oNpIrn3YVd7GqzhEuvjE/4wRIFRGNgK1SgxGYIl2MTmGWwnpxQd8RFsV8kntMss7RW1t27qQrJX6Mr+qpa/uOkk5L9nEpubQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516718; 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=PJ0Jxetlj436P6+afd2+rFKuabpoPRUpnCMrH1WbgQk=; b=OGNjid0vYXuh6d3Vwu70gWn2gCgn+AiZk5DeFxZheszxLnQ0n1AyEw5+54LVeenHsqtkfvpC9BI56PUsCz9rwpefZbzQvlpeyxTOx7PPB6hbotB209DIJMoHHxol802yRsq0tjj7P0Pcv/g7NVGipLMV8Kn8RIJ2WYdSTP71f5g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 16425167186111022.870128032396; Tue, 18 Jan 2022 06:38:38 -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-331-xvC_Sn-zPg2rjPY47KIYMw-1; Tue, 18 Jan 2022 09:38:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B609383DD35; Tue, 18 Jan 2022 14:38:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 939757E2F6; Tue, 18 Jan 2022 14:38:29 +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 37CEF4BB7C; Tue, 18 Jan 2022 14:38:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbhQP016655 for ; Tue, 18 Jan 2022 09:37:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 943182BE7F; Tue, 18 Jan 2022 14:37:43 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D9F22C1B4 for ; Tue, 18 Jan 2022 14:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516717; 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=PJ0Jxetlj436P6+afd2+rFKuabpoPRUpnCMrH1WbgQk=; b=INJ9+tmeiV0W8DAOIiiiJhPoF0qUimeWwdQzvuFdNoYM8BA/f2pt9nvUXQClGgsAmS4o58 4udOataNxTzNZzR8GIXSlYdigpS3L1t3KHwRNaRy5/sX28u7c2jGnBjN3fsMKNSHm7CL9p C8pV8/EzTxymrJrybWzPIi954tj1xvM= X-MC-Unique: xvC_Sn-zPg2rjPY47KIYMw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 05/13] virdnsmasq: Drop noRefresh member from from struct _dnsmasqCaps Date: Tue, 18 Jan 2022 15:37:12 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516719168100001 Content-Type: text/plain; charset="utf-8" The noRefresh member of _dnsmasqCaps struct is set only after it was checked for and is never checked again. This is needless and the member can be removed. There is no way that dnsmasqCapsRefreshInternal() can be called after dnsmasqCapsSetFromBuffer(). Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index c3801d622f..a8fb91ed2b 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -576,7 +576,6 @@ dnsmasqReload(pid_t pid G_GNUC_UNUSED) struct _dnsmasqCaps { virObject parent; char *binaryPath; - bool noRefresh; unsigned long version; }; =20 @@ -609,8 +608,6 @@ dnsmasqCapsSetFromBuffer(dnsmasqCaps *caps, const char = *buf) int len; const char *p; =20 - caps->noRefresh =3D true; - p =3D STRSKIP(buf, DNSMASQ_VERSION_STR); if (!p) goto error; @@ -656,7 +653,7 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) g_autofree char *version =3D NULL; g_autofree char *complete =3D NULL; =20 - if (!caps || caps->noRefresh) + if (!caps) return 0; =20 /* Make sure the binary we are about to try exec'ing exists. --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516748; cv=none; d=zohomail.com; s=zohoarc; b=QTlW2Gksr3+NN6GPd4Hhcdo+YjwOO/TBtqPTF9uRk6hmGh9udB3HnLIp7/co6o0ubyKADC329KLiIIOoPEwQzxPzHT24nctCEPgy57RBxEMz1UQmZTO5VZOdyWdt5bL6N4fnq5NsF8pBnRvCfe6GLj8ABFiCOIHaNFDo2SWXHds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516748; 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=u/JuRpqZKrBaVZ73cLsTXPCLalhdh2Vmhe4dpNUqDIc=; b=lPiKIduCod9QklWPqdoPo4Gt+82Cv9LOWypoPasyA9nLiLn7bOJMcas7zvrbIj0+0iayzkPaarLcSx2DegW+7Kr+oaUSJeXDikuQZkjjDefGkvuaicigFEYgQwmuFuWL+3VCKp8KHuWfeFEksjUtlZPhKY/+8jqTyVPaBEhx6lw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642516748345902.402023862585; Tue, 18 Jan 2022 06:39:08 -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-593-R7kAUEBDNOCtMAgUdwREVw-1; Tue, 18 Jan 2022 09:39:06 -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 BF0508144E0; Tue, 18 Jan 2022 14:39:00 +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 9F0325AB4B; Tue, 18 Jan 2022 14:39:00 +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 67F221806D2B; Tue, 18 Jan 2022 14:39:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbiEm016668 for ; Tue, 18 Jan 2022 09:37:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 632AD2C1AE; Tue, 18 Jan 2022 14:37:44 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E14182BE7F for ; Tue, 18 Jan 2022 14:37:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516747; 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=u/JuRpqZKrBaVZ73cLsTXPCLalhdh2Vmhe4dpNUqDIc=; b=EWpvD2nwGcr8kArCxvW0DU9y5Jp8Xpyqt1J2LtYlo0CAfNomWvXxDpr+Y9/9SWViq6WlJB L2i9TMJmCY+e9nnEeFNpZDqYjds5USeasTYbfAMNxJjMEfpDeQPneScIS/jdAxCRn7ieJL 5j5cfRoT+1MYK3kh56cosK+p1Hzv5b0= X-MC-Unique: R7kAUEBDNOCtMAgUdwREVw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 06/13] virdnsmasq: Drop !caps check from dnsmasqCapsRefreshInternal() Date: Tue, 18 Jan 2022 15:37:13 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516750518100001 Content-Type: text/plain; charset="utf-8" There is no way that the dnsmasqCapsRefreshInternal() function can be called with @caps =3D=3D NULL. Therefore, drop the if() that checks for that. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index a8fb91ed2b..9f50ce7755 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -653,9 +653,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) g_autofree char *version =3D NULL; g_autofree char *complete =3D NULL; =20 - if (!caps) - return 0; - /* Make sure the binary we are about to try exec'ing exists. * Technically we could catch the exec() failure, but that's * in a sub-process so it's hard to feed back a useful error. --=20 2.34.1 From nobody Tue Apr 30 13:36:39 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=1642516797; cv=none; d=zohomail.com; s=zohoarc; b=ba518KH/3zepGAa8uHzvrJEvOprNiAHhiIjY5wJi36JizCs8WEl2IlBLMzeiWsiSq25JOIsCtU6Us2P7nz/YUXJcq59cnvxSm8WX2TWN5fECClb3cLy/wKHa1WyjRfEEO+zZIb1v0cG7QVZ/m3lG7kT+s5cvXqOjgxnOFdaDPUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516797; 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=kL4lVCTk+IupbX73bWU4Z3QnFTclQxQXU/PWd8e6i6M=; b=ctosAcyb2RZeOsUszfcrKzKAf+3mJAztTxevuWLIYjhM6A9L3JUTRPmSYgL7KQfiYuBckFv0UoiJbJbNoxQVdV69ZUKjhK/7ueFAGQG7ilrP9fmEYLnclgj+n0CIhkTS3QlMuL9ZDZWgmdIzEc0BIO4xhwmV9jcbQY+g0uIf1qk= 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 1642516797417978.9201980873725; Tue, 18 Jan 2022 06:39:57 -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-402-wUFPuBEzNHGb_nAx5lr4zA-1; Tue, 18 Jan 2022 09:39:52 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90BBB100E328; Tue, 18 Jan 2022 14:39:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 417E22C1AE; Tue, 18 Jan 2022 14:39:47 +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 0DF104A700; Tue, 18 Jan 2022 14:39:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbjGk016673 for ; Tue, 18 Jan 2022 09:37:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 341E82C1AE; Tue, 18 Jan 2022 14:37:45 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id B2ADD2BE7F for ; Tue, 18 Jan 2022 14:37:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516796; 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=kL4lVCTk+IupbX73bWU4Z3QnFTclQxQXU/PWd8e6i6M=; b=XLoVpR9YJ3sYGBo5Xpe36V8QO6l96CbZxYmTltPlTHqlMEsxHgRCJMX4M7/du032cPZ7l8 UZG5/2jazFGzhsvNcIhAo3y0W9DFS8OjmeOPWolOqXP6pe9vbhv3q+Tz1Qa6NXace912Vq FqHsdw/iwPKCKQGNCImGnuOQeXJXWqc= X-MC-Unique: wUFPuBEzNHGb_nAx5lr4zA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 07/13] virdnsmasq: Don't run 'dnsmasq --help' Date: Tue, 18 Jan 2022 15:37:14 +0100 Message-Id: <96308ebae9b2f4dae4051764944acbb05aae89c9.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516798229100001 Content-Type: text/plain; charset="utf-8" We don't query any capabilities of dnsmasq. We are only interested in dnsmasq's version (obtained via 'dnsmasq --version'). Therefore, there's no point in running 'dnsmasq --help'. Its output is not processed even. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 14 +------------- tests/networkxml2conftest.c | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 9f50ce7755..5bed8817e5 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -648,10 +648,7 @@ static int dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) { 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; =20 /* Make sure the binary we are about to try exec'ing exists. * Technically we could catch the exec() failure, but that's @@ -670,16 +667,7 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) if (virCommandRun(vercmd, NULL) < 0) return -1; =20 - helpcmd =3D virCommandNewArgList(caps->binaryPath, "--help", NULL); - virCommandSetOutputBuffer(helpcmd, &help); - virCommandAddEnvPassCommon(helpcmd); - virCommandClearCaps(helpcmd); - if (virCommandRun(helpcmd, NULL) < 0) - return -1; - - complete =3D g_strdup_printf("%s\n%s", version, help); - - return dnsmasqCapsSetFromBuffer(caps, complete); + return dnsmasqCapsSetFromBuffer(caps, version); } =20 static dnsmasqCaps * diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index d79c2b4783..6a2c70ead1 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -114,7 +114,7 @@ mymain(void) int ret =3D 0; g_autoptr(dnsmasqCaps) full =3D NULL; =20 - full =3D dnsmasqCapsNewFromBuffer("Dnsmasq version 2.67\n--bind-dynami= c\n--ra-param"); + full =3D dnsmasqCapsNewFromBuffer("Dnsmasq version 2.67"); =20 #define DO_TEST(xname, xcaps) \ do { \ --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516722; cv=none; d=zohomail.com; s=zohoarc; b=HkXxATyN4tK6d7/YUBiQPcn47oNUeZdFjIQ+7XzGwi7MhD3myA/LiaKLW/aXbRNlDkHTa3JjMVJFGhzZAWF70I4fwj/8ILmZ/xYzMnhIPdSS4sTlEnVtiDuTw5vHJ0sp5wAx/t+NykgvEDhQ+tof7qMNlh15b+s/vA9pDAhmvkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516722; 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=+4Q3Jr7qZS44GOOadXUVvR5FVWWdW511mA07HPWAuK0=; b=caqfc57WEYcHV2PrNLmNxJgF2lrl+C2SoMi9T3hZCcPTJ9+tkneK5efWxO4NOxBrPzXi5PpqX4I+bQtcPUIJMRBdnnBWF3b0R+4SNBSwIxKvCH3+ljoN0VHluw3vtonr8b0iQKgjpsNmcslE6ZCjCOS7Mj3jysDUbZ0fcACN0p4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 164251672297887.46051371704664; Tue, 18 Jan 2022 06:38:42 -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-319-MnVODOC8NMGND9ykKK0WrQ-1; Tue, 18 Jan 2022 09:38:38 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6ADF2814517; Tue, 18 Jan 2022 14:38:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45799753DB; Tue, 18 Jan 2022 14:38:32 +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 0FA0D4CA9B; Tue, 18 Jan 2022 14:38:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbkFm016684 for ; Tue, 18 Jan 2022 09:37:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 06BC82C1AE; Tue, 18 Jan 2022 14:37:46 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8245D2BE7F for ; Tue, 18 Jan 2022 14:37:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516722; 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=+4Q3Jr7qZS44GOOadXUVvR5FVWWdW511mA07HPWAuK0=; b=R0TlsovKYJZyhEQ/BYsSB0mqFMO+x3eeZ43fpAUD5XMrK9N1jucl/d/ekz27+HdXnbcViE C7Mm9LRSXdhHzfyKlpOehM09DLxB05B2Bxi1BClU71kFp/naRZ+5zV1GgJzGopbXUn7bxy vQrzKO7wD9fqpzE/ibZqphAOD3hDSIk= X-MC-Unique: MnVODOC8NMGND9ykKK0WrQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 08/13] virdnsmasq: Lookup DNSMASQ in PATH Date: Tue, 18 Jan 2022 15:37:15 +0100 Message-Id: <5c98d1cee0be741a3205bb08be8bca4165259154.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.11 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516724770100001 Content-Type: text/plain; charset="utf-8" While it's true that our virCommand subsystem is happy with non-absolute paths, the dnsmasq capability code is not. It stores the path to dnsmasq within and makes it accessible via dnsmasqCapsGetBinaryPath(). While strictly speaking no caller necessarily needs canonicalized path, let's find dnsmasq once and cache the result. Therefore, when constructing the capabilities structure look up the binary path. If DNSMASQ already contains an absolute path then virFindFileInPath() will simply return a copy. With this code in place, the virFileIsExecutable() check can be removed from dnsmasqCapsRefreshInternal() because virFindFileInPath() already made sure the binary is executable. But introducing virFindFileInPath() means we have to mock it in test suite because dnsmasqCaps are created in networkxml2conftest. Moreover, we don't need to check for dnsmasq in configure. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- meson.build | 1 - src/util/virdnsmasq.c | 19 ++++++++----------- tests/meson.build | 1 + tests/networkxml2conftest.c | 3 ++- tests/virdnsmasqmock.c | 19 +++++++++++++++++++ 5 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 tests/virdnsmasqmock.c diff --git a/meson.build b/meson.build index c2e9619f1f..70843afcd5 100644 --- a/meson.build +++ b/meson.build @@ -813,7 +813,6 @@ endforeach optional_programs =3D [ 'augparse', 'dmidecode', - 'dnsmasq', 'ebtables', 'flake8', 'ip', diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 5bed8817e5..579c67d86a 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -46,6 +46,7 @@ =20 VIR_LOG_INIT("util.dnsmasq"); =20 +#define DNSMASQ "dnsmasq" #define DNSMASQ_HOSTSFILE_SUFFIX "hostsfile" #define DNSMASQ_ADDNHOSTSFILE_SUFFIX "addnhosts" =20 @@ -650,16 +651,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) g_autoptr(virCommand) vercmd =3D NULL; g_autofree char *version =3D NULL; =20 - /* Make sure the binary we are about to try exec'ing exists. - * Technically we could catch the exec() failure, but that's - * in a sub-process so it's hard to feed back a useful error. - */ - if (!virFileIsExecutable(caps->binaryPath)) { - virReportSystemError(errno, _("dnsmasq binary %s is not executable= "), - caps->binaryPath); - return -1; - } - vercmd =3D virCommandNewArgList(caps->binaryPath, "--version", NULL); virCommandSetOutputBuffer(vercmd, &version); virCommandAddEnvPassCommon(vercmd); @@ -679,7 +670,13 @@ dnsmasqCapsNewEmpty(void) return NULL; if (!(caps =3D virObjectNew(dnsmasqCapsClass))) return NULL; - caps->binaryPath =3D g_strdup(DNSMASQ); + + if (!(caps->binaryPath =3D virFindFileInPath(DNSMASQ))) { + virReportSystemError(ENOENT, "%s", + _("Unable to find 'dnsmasq' binary in $PATH")= ); + return NULL; + } + return g_steal_pointer(&caps); } =20 diff --git a/tests/meson.build b/tests/meson.build index 4792220b48..8f92f2033f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -59,6 +59,7 @@ mock_libs =3D [ { 'name': 'domaincapsmock' }, { 'name': 'shunload', 'sources': [ 'shunloadhelper.c' ] }, { 'name': 'vircgroupmock' }, + { 'name': 'virdnsmasqmock' }, { 'name': 'virfilecachemock' }, { 'name': 'virfirewallmock' }, { 'name': 'virgdbusmock' }, diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 6a2c70ead1..13257c749b 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -158,4 +158,5 @@ mymain(void) return ret =3D=3D 0 ? EXIT_SUCCESS : EXIT_FAILURE; } =20 -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, + VIR_TEST_MOCK("virdnsmasq")) diff --git a/tests/virdnsmasqmock.c b/tests/virdnsmasqmock.c new file mode 100644 index 0000000000..448332ec40 --- /dev/null +++ b/tests/virdnsmasqmock.c @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2022 Red Hat, Inc. + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include + +#include "internal.h" +#include "virfile.h" + +char * +virFindFileInPath(const char *file) +{ + if (STREQ_NULLABLE(file, "dnsmasq")) + return g_strdup("/usr/sbin/dnsmasq"); + + /* We should not need any other binaries so return NULL. */ + return NULL; +} --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516760; cv=none; d=zohomail.com; s=zohoarc; b=WBmSp1Lq3VrGxTzbT0qhP6t+Dx09YyHMjm53LlpOvDsUvnCFDjtPbGr3HqsE0Kp3FUHKiqrIjRktppKihgOUFLEzaFmM9B+7EcDYbfzHMhEQfpF6+D/GfeGf2OXBw58xZL6pefxRK0DKVCoof//ZUk1MzrbN23BjQPuRzicdg4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516760; 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=rRUw1l7fnjmlnM9PNfggg1c2AdOFR/rOvIkOES39xoE=; b=MRjsbkPXp+kaMZCe1tZiBlz1JAs0oin/A1/pwlnhz1l/ufqZQ5vjt0pPUgXcNxDjpCAeyH0wQfL9T/h+xJagkSg82qFjOGh2qXgNflxw3loIHD9vcFoI61JXDsz5x/OJfn29+2dwRTfoA75F601smUfjr7/VmWLrPpxcB5O/TvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642516760297821.4398055787518; Tue, 18 Jan 2022 06:39:20 -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-373-YnKFPTTSOe-X-hnZHLfEDg-1; Tue, 18 Jan 2022 09:39:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2ABFE10247AC; Tue, 18 Jan 2022 14:39:07 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04BED7A2E2; Tue, 18 Jan 2022 14:39:07 +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 6CD454CA9B; Tue, 18 Jan 2022 14:39:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbkhh016696 for ; Tue, 18 Jan 2022 09:37:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id C93FA2BE7F; Tue, 18 Jan 2022 14:37:46 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5253C2C1B4 for ; Tue, 18 Jan 2022 14:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516759; 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=rRUw1l7fnjmlnM9PNfggg1c2AdOFR/rOvIkOES39xoE=; b=T2rp9mQUor5KJ/Y587T438v7PbUCuiM+lUMtErrF6LCHvk1r6VD/dPrGF8KfLPcHyZGBE6 Uc/L02cCWMgf2YCtQLJ2RkC7aehGAcYcrEMajvXF+sPZjCvUJPgIA0Nz26jEXIzWDBe4u1 T8wFTQ2dm35MhYWEtSLQgwv5i+qKpqc= X-MC-Unique: YnKFPTTSOe-X-hnZHLfEDg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 09/13] virdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath() Date: Tue, 18 Jan 2022 15:37:16 +0100 Message-Id: <4b68c982e283471575bacbf87302495864da46fe.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516762100100003 Content-Type: text/plain; charset="utf-8" First observation: There is no way that caps->binaryPath can be NULL. Second observation: There is no caller that passes NULL. Let's drop the ternary operator and access @caps directly. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 579c67d86a..841689b782 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -711,7 +711,7 @@ dnsmasqCapsNewFromBinary(void) const char * dnsmasqCapsGetBinaryPath(dnsmasqCaps *caps) { - return caps ? caps->binaryPath : DNSMASQ; + return caps->binaryPath; } =20 /** dnsmasqDhcpHostsToString: --=20 2.34.1 From nobody Tue Apr 30 13:36:39 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=1642516758; cv=none; d=zohomail.com; s=zohoarc; b=LReiphotwq1DHbfd+wTyaJ3w+IJoN5BKaKAuul3I7wxUA8BAqwfg9UtINe3VvKC5iy+T3An1fdkCFm+FwBbeeUSabE75Cn18HTIzrUx09wZMKuO3c2IO1bnxSAycoKF95BQKhTYc1ZC75/VyC9d0hY4FVOnXUexygqasngoA9bM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516758; 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=esDObrOZUFV4nIPVxFaV6B2cDEelwr2QOyRwnjqDthg=; b=C13P+ivcZ0Jy5Y5BbkGp5H2dKh2/JosfVaT7QEzcGVhmGMmLBEY7cHwmc4+pPOXWsa0Fp7seSfCutaR5xylbyZV8XcnbO5Km81LZQXgJ4uhesWtPx//J5qDVzQAuhW5EmdaZR671zUoV3IoN4YTb9PH8Q1TAErYPOrAaEQ3AsY0= 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 1642516758988979.9536104322874; Tue, 18 Jan 2022 06:39:18 -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-190-1xkUMhGMNXK3Ve8s239fRw-1; Tue, 18 Jan 2022 09:39:16 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09BB310144EC; Tue, 18 Jan 2022 14:39:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC9017E5A8; Tue, 18 Jan 2022 14:39:09 +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 ABB284A7CA; Tue, 18 Jan 2022 14:39:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbl5o016704 for ; Tue, 18 Jan 2022 09:37:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 98D4B2C1AE; Tue, 18 Jan 2022 14:37:47 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 229D72BE7F for ; Tue, 18 Jan 2022 14:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516758; 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=esDObrOZUFV4nIPVxFaV6B2cDEelwr2QOyRwnjqDthg=; b=WLxPaFqH//ygSSQK4DtBBUFqK2Q97xN+0oarzX/WaklZ/8f5fG8hI2JOtnaK5NsRU6U+cI OF4eDnKZZhnc5Yqs6ZZX0A2tqYwyaodhuBAynpbuxRKr20YoNZ62m8fv3mpat3jupe9uYo 8QFp4L4tKDxXNFhogFQK79gb+JMmsQ8= X-MC-Unique: 1xkUMhGMNXK3Ve8s239fRw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 10/13] networkxml2conftest: Use dnsmasqCapsNewFromBinary() to construct caps Date: Tue, 18 Jan 2022 15:37:17 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516759690100001 Content-Type: text/plain; charset="utf-8" DISCLAIMER: dnsmasq capabilities are empty as of v8.0.0-rc1~145. In a real environment the dnsmasq capabilities are constructed using dnsmasqCapsNewFromBinary(). We also have dnsmasqCapsNewFromBuffer() to bypass checks that real code is doing and just get capabilities object. The latter is used from test suite. However, with a little bit of mocking we can test the real life code. All that's needed is to simulate dnsmasq's output for --version and --help and mock a stat() that's done in dnsmasqCapsRefreshInternal(). Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- tests/networkxml2conftest.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 13257c749b..718a031879 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -12,6 +12,8 @@ #include "viralloc.h" #include "network/bridge_driver.h" #include "virstring.h" +#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW +#include "vircommandpriv.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -108,13 +110,44 @@ testCompareXMLToConfHelper(const void *data) return result; } =20 +static void +buildCapsCallback(const char *const*args, + const char *const*env G_GNUC_UNUSED, + const char *input G_GNUC_UNUSED, + char **output, + char **error G_GNUC_UNUSED, + int *status, + void *opaque G_GNUC_UNUSED) +{ + if (STREQ(args[0], "/usr/sbin/dnsmasq") && STREQ(args[1], "--version")= ) { + *output =3D g_strdup("Dnsmasq version 2.67\n"); + *status =3D EXIT_SUCCESS; + } else { + *status =3D EXIT_FAILURE; + } +} + +static dnsmasqCaps * +buildCaps(void) +{ + g_autoptr(dnsmasqCaps) caps =3D NULL; + g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + + virCommandSetDryRun(dryRunToken, NULL, true, true, buildCapsCallback, = NULL); + + caps =3D dnsmasqCapsNewFromBinary(); + + return g_steal_pointer(&caps); +} + + static int mymain(void) { int ret =3D 0; g_autoptr(dnsmasqCaps) full =3D NULL; =20 - full =3D dnsmasqCapsNewFromBuffer("Dnsmasq version 2.67"); + full =3D buildCaps(); =20 #define DO_TEST(xname, xcaps) \ do { \ --=20 2.34.1 From nobody Tue Apr 30 13:36:39 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=1642516724; cv=none; d=zohomail.com; s=zohoarc; b=S32x2A8V+aN4tzCUzWEiH4CgaQ1hRxCrVKE/ls2tfrPAPJDZ73xRotkhRd6ESx4B0eHkVK9dVLdc6cdu+e4EpLRm4YjMUTqYJsxhDv7/QaYFoZBrihbtlqeQ1LvNKs3hwB/0iAjKZV5XnA/g6K2kcaRm6aIGWSmDul2VrUQL4n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516724; 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=9skTzoYruyGbHT618mjkjDujIVupLREK+9oy0EmJqC4=; b=IT5Gj5BAGHy7YFNfxJLR8sBr2J3s7yZqsB//q/VnmlUmWeoC14t8XRRgFqa3zR50pCxnDy0KzbSKf0muc0vMXGURntGc/lfNY/Dpq3G6wmPzrl+oahw+40VKpj7CRdIhXgviMpEWx7onIOJlfl6nQrez00oLQ0F1x4oT4sHKyrI= 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 1642516724629877.9560419410615; Tue, 18 Jan 2022 06:38:44 -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-472-qXMA6ckHMUSEtA9Nai6Jaw-1; Tue, 18 Jan 2022 09:38:40 -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 4F5D7593C5; Tue, 18 Jan 2022 14:38:35 +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 099755AB42; Tue, 18 Jan 2022 14:38:35 +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 C76851809CBA; Tue, 18 Jan 2022 14:38:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbmA2016726 for ; Tue, 18 Jan 2022 09:37:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 823A734D3D; Tue, 18 Jan 2022 14:37:48 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7FA22BE75 for ; Tue, 18 Jan 2022 14:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516723; 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=9skTzoYruyGbHT618mjkjDujIVupLREK+9oy0EmJqC4=; b=Ywr9xHPirHW8ekIdxJdx52pTMB6VTY6kBZHlP2bhSHyGLQA3Yxna8kIbkxZaQXo4/LPfGX dl4bZmqowrdoLo7IBnIgJLe49g5Xcqo+u8MHNkuuYIMbMfCiEDCgim+B5180BQBqaf2bub D3t553D2tRyVmyvKQ8lEbwZ4o7g3r0I= X-MC-Unique: qXMA6ckHMUSEtA9Nai6Jaw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 11/13] networkxml2conftest: Check if capabilities were created successfully Date: Tue, 18 Jan 2022 15:37:18 +0100 Message-Id: <174fad189f2e042e7238f49e80d1a3fb117a954c.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516725340100003 Content-Type: text/plain; charset="utf-8" Now that looking up dnsmasq is handled/mocked we can start checking whether dnsmasq capabilities were built successfully and error out if that wasn't the case. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- tests/networkxml2conftest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 718a031879..0bc9e128e3 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -147,7 +147,11 @@ mymain(void) int ret =3D 0; g_autoptr(dnsmasqCaps) full =3D NULL; =20 - full =3D buildCaps(); + if (!(full =3D buildCaps())) { + fprintf(stderr, "failed to create the fake capabilities: %s", + virGetLastErrorMessage()); + return EXIT_FAILURE; + } =20 #define DO_TEST(xname, xcaps) \ do { \ --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516749; cv=none; d=zohomail.com; s=zohoarc; b=Bf78zVITgg+yEZt4BH7DcPqcEgUWlUDmdLHtEIhd+YX51g3pnBZJV5FXWdRU3+xvvVFH6ca7q7KcHjWTrzjfPpfLeT2Yt1cJDpXUB5wNTx34EfdwpDhY9Zygn6la/gH5B1c+RX4w5Ol5Vaeb4xu1XxX1GqGJ4JsU2jQEOPaIirU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516749; 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=UYo3R9tEnPaBlZZDcFYqAe7g5Qt6+ijLF2xRSCBwc1A=; b=Wq5JIX9RIo+viXquZvlioR8B+5Qd7CQeO6Ueigrs9of156CXBaTgLDuSIFbTyeHLlB7m9bTzXLaLx6SEsIYh7G0z0A8IgLjMFAMQ9i6DkQ3gFt3QVSiRJCv23tAvHkq5+DW299oyKGzjCUaT8TKtVv30hdl7879VrnyNJZrMrP4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642516749479134.43384599803187; Tue, 18 Jan 2022 06:39:09 -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-132-hjiZlVEgNf6FfASzipmB0Q-1; Tue, 18 Jan 2022 09:38:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5452610144F2; Tue, 18 Jan 2022 14:38:38 +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 3232A798C6; Tue, 18 Jan 2022 14:38:38 +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 F183E1802E2B; Tue, 18 Jan 2022 14:38:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbnVX016736 for ; Tue, 18 Jan 2022 09:37:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 400152BE75; Tue, 18 Jan 2022 14:37:49 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC6C634D37 for ; Tue, 18 Jan 2022 14:37:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516748; 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=UYo3R9tEnPaBlZZDcFYqAe7g5Qt6+ijLF2xRSCBwc1A=; b=VuFsis+g0cvgry6Qe3b3wKUXGmxUT4QbWlSKpBfDMOukL1GjQmW1GPsoQV5Rpv8MCl00KT 0tfnqY0ikAdNzQRgQp1Zx0de30ICY8J66cnViOu3FhNrnNuV4eU4RbtlTkhUU7t4UcseKG 83Sc4cNcH2x6SjOlpW+a3Z3ggB05dKI= X-MC-Unique: hjiZlVEgNf6FfASzipmB0Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 12/13] virdnsmasq: Drop dnsmasqCapsNewFromBuffer() Date: Tue, 18 Jan 2022 15:37:19 +0100 Message-Id: <9bc9cf33ad723280122dd97151c50ba7e11c4940.1642516422.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.14 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516751049100005 Content-Type: text/plain; charset="utf-8" The function is no longer used. Remove it. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/libvirt_private.syms | 1 - src/util/virdnsmasq.c | 14 -------------- src/util/virdnsmasq.h | 1 - 3 files changed, 16 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index f75dea36c4..2b4a44d696 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2117,7 +2117,6 @@ dnsmasqAddDhcpHost; dnsmasqAddHost; dnsmasqCapsGetBinaryPath; dnsmasqCapsNewFromBinary; -dnsmasqCapsNewFromBuffer; dnsmasqContextFree; dnsmasqContextNew; dnsmasqDelete; diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 841689b782..f5029d2fdc 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -680,20 +680,6 @@ dnsmasqCapsNewEmpty(void) return g_steal_pointer(&caps); } =20 -dnsmasqCaps * -dnsmasqCapsNewFromBuffer(const char *buf) -{ - g_autoptr(dnsmasqCaps) caps =3D dnsmasqCapsNewEmpty(); - - if (!caps) - return NULL; - - if (dnsmasqCapsSetFromBuffer(caps, buf) < 0) - return NULL; - - return g_steal_pointer(&caps); -} - dnsmasqCaps * dnsmasqCapsNewFromBinary(void) { diff --git a/src/util/virdnsmasq.h b/src/util/virdnsmasq.h index c74cc887f8..cc1c337d41 100644 --- a/src/util/virdnsmasq.h +++ b/src/util/virdnsmasq.h @@ -91,7 +91,6 @@ int dnsmasqSave(const dnsmasqContext *ctx); int dnsmasqDelete(const dnsmasqContext *ctx); int dnsmasqReload(pid_t pid); =20 -dnsmasqCaps *dnsmasqCapsNewFromBuffer(const char *buf); dnsmasqCaps *dnsmasqCapsNewFromBinary(void); const char *dnsmasqCapsGetBinaryPath(dnsmasqCaps *caps); char *dnsmasqDhcpHostsToString(dnsmasqDhcpHost *hosts, --=20 2.34.1 From nobody Tue Apr 30 13:36:39 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1642516801; cv=none; d=zohomail.com; s=zohoarc; b=iNTX7CCm88utcXwswtSS1hNn9eFQ+cB0Nc/hDsTYnhEVFoY+NAU+rh9fXGf5jP9VJO8hiFs7ZCCD8c2fmIAe9b0XbPWcyw/wVyVVrQwr9nfFeYVIOuN2Khlyi20lVOw5amUkbBAlL/+VGCLO5bnXVtbkxbHZHwsv1aY4xtWa+4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642516801; 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=9F1Jp8sJDVHx1WRg+qj/oZoRwHVHFX+cDlKZcSF4upo=; b=I7/BIPnmT2K391OexDlfBa7t6n/3Cc8+DpXbCAJQfTbVGnt/fx1Du3oR0dNT82BL9Du0oTp8FdkNbwIKWineOj29lvm9qH9/n/s5mxRZI8svhYdfLTiu67bgCJg1vaNPJU5KLZjwITlzEqzcCrcFI2XJQzX7iDksXyd87AjIHNw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1642516801616798.0843089006659; Tue, 18 Jan 2022 06:40:01 -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-531-CGVb_nPyPnSU8f3DnhcyWQ-1; Tue, 18 Jan 2022 09:39:56 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48D3B760CD; Tue, 18 Jan 2022 14:39:50 +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 295F17E90C; Tue, 18 Jan 2022 14:39:50 +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 E4D681806D2F; Tue, 18 Jan 2022 14:39:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20IEbo6A016748 for ; Tue, 18 Jan 2022 09:37:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id 10F422BE77; Tue, 18 Jan 2022 14:37:50 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F13C2BE75 for ; Tue, 18 Jan 2022 14:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642516800; 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=9F1Jp8sJDVHx1WRg+qj/oZoRwHVHFX+cDlKZcSF4upo=; b=cLsdyLjisCKpKgyRKjZlhgQxMhI/iKnnivVRESkJiJkXttMhgdbC712NxFVwHOdWg4kDMI 28EfkeRA1i5GC2tMAWm7PBUcBPqci1ikGUCsXCrJCyKhEcAVxqYcqYHGtDXDQuxBHoA4u4 S+fAkOb8RWpR5ovQM1bzLdWeOl/pJwQ= X-MC-Unique: CGVb_nPyPnSU8f3DnhcyWQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v5 13/13] virdnsmasq: Join dnsmasqCapsNewEmpty() and dnsmasqCapsNewFromBinary() Date: Tue, 18 Jan 2022 15:37:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.12 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642516803459100001 Content-Type: text/plain; charset="utf-8" After previous cleanups, there's just one caller of dnsmasqCapsNewEmpty() and it is dnsmasqCapsNewFromBinary(). And the former is pretty short. Therefore, it is not necessary for the code to live in two separate functions. Dissolve the former in the latter. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/util/virdnsmasq.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index f5029d2fdc..57b24c9f6a 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -661,13 +661,14 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps) return dnsmasqCapsSetFromBuffer(caps, version); } =20 -static dnsmasqCaps * -dnsmasqCapsNewEmpty(void) +dnsmasqCaps * +dnsmasqCapsNewFromBinary(void) { g_autoptr(dnsmasqCaps) caps =3D NULL; =20 if (dnsmasqCapsInitialize() < 0) return NULL; + if (!(caps =3D virObjectNew(dnsmasqCapsClass))) return NULL; =20 @@ -677,17 +678,6 @@ dnsmasqCapsNewEmpty(void) return NULL; } =20 - return g_steal_pointer(&caps); -} - -dnsmasqCaps * -dnsmasqCapsNewFromBinary(void) -{ - g_autoptr(dnsmasqCaps) caps =3D dnsmasqCapsNewEmpty(); - - if (!caps) - return NULL; - if (dnsmasqCapsRefreshInternal(caps) < 0) return NULL; =20 --=20 2.34.1