From nobody Sun May 5 10:13:58 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=1642433092; cv=none; d=zohomail.com; s=zohoarc; b=IyFgtgaZIyfw6m0mTS9qNNvH698b40DLrdknGicQjAkrzAkFg/RmWj7pXgEXa9m7HCoH9o7fLaAjEnzFB3TuS18f6Z/o+Z6V3VffPLr5ZHWCZZePMMV8TsEQz1gF7bwJw1AK5DmqXGj9HBY1RoBJAXweCZkAFtXDAGNNCEaxYJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433092; 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=km/nf28vtScYi3Pv/3HxqQjhTCwhlJbyNwPV2448Q8aaSmvOzdwh99cgv8kdrHo3mHAm6v0xxMjCt0qQIM86OzsHo4Vk4r83d+ASfN9forT5Kz+kSRC6MZ48c4/Z6B0itEtjY1RGHhDkihSitifqjk5uKUu3wI3qfzoxMnZoQLM= 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 164243309259897.26650576526913; Mon, 17 Jan 2022 07:24:52 -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-284-XAmZbBwxMFCjecbehoK6Pg-1; Mon, 17 Jan 2022 10:24: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 83DCE1932486; Mon, 17 Jan 2022 15:24: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 3D0F777453; Mon, 17 Jan 2022 15:24: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 0896B4BB7C; Mon, 17 Jan 2022 15:24: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 20HFJU6j031487 for ; Mon, 17 Jan 2022 10:19:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 50B9F2B4C5; Mon, 17 Jan 2022 15:19:30 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA3EC26576 for ; Mon, 17 Jan 2022 15:19:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433091; 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=bEQ0VXrsQZlF45o51dfLNV3UM1sD3p0vNHiJcGcuS7mYj51qIMOjATA4k95ftRMOafHfhG +tRfzykyHQc2QvWTg7NNrYb0lZDIJOGLuLSlKCb5xgSJXGn1BvC7/wYpsH9d8XcOQ6UvQb nObc5NtXaZnmHx0Cw27nyM0Lh6vRbvA= X-MC-Unique: XAmZbBwxMFCjecbehoK6Pg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 01/13] virdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty() Date: Mon, 17 Jan 2022 16:19:15 +0100 Message-Id: <4237d847857e1f8c14416f3577d358232db46f3a.1642432611.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: 1642433093469100003 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 Sun May 5 10:13:58 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=1642432825; cv=none; d=zohomail.com; s=zohoarc; b=Okupo/y5ialxE0TD8DPg8NAOFISn/kTKvfmaUyd8CQy0gdMwMf+D9lPTccPNWsnhJLMl6ueRpJhfCrb1Gxn2KXRil4zY8Zna9r3MuV86LkjbJyBqXe8FTslyUZsZ7LBs609uRyyBUmff+Zw33vDAtTaJAXmJ2lbB7gxAVkDqXPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642432825; 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=Yst/tsgrP9yQtR0n83JlloOQMNONWuba/mpBeSE9YNtyqD3uI5NVhGfJ45Fsc0EbHN5j23o69R8mm5+1/FzUMKjXRiuwjQ5ThIN4SOdsvxAaQXHvuZ3BDk6w7IcyawsYeB0A5QWkZrHqSMBmVt18XFC1DIk3z4EFiGoOUdsJPD0= 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 1642432825900173.73693749400866; Mon, 17 Jan 2022 07:20:25 -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-290-rqpdbcPPNTObhjI9K1kMkg-1; Mon, 17 Jan 2022 10:19:57 -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 743CF192AB77; Mon, 17 Jan 2022 15:19:37 +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 A3018798CC; Mon, 17 Jan 2022 15:19:36 +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 6D6541809CB8; Mon, 17 Jan 2022 15:19: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 20HFJVhn031496 for ; Mon, 17 Jan 2022 10:19:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 21CB326576; Mon, 17 Jan 2022 15:19:31 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F3A72B5A5 for ; Mon, 17 Jan 2022 15:19:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642432824; 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=FtpeAAZvbqRWNXSl+0UNhHYBClFcQ12dHJ9ZpbJMpT3Z/l3rtuJQ1sK7vArmTxuNPKvKc8 DynJsYrUpGb1amPVydx3lTDQEXfzw6v3O0f75PZj5h5L5VxWJHm2aTpRu6OB4kw4R0XLmy dnCVdBHtOGw+SHCE3vYiC0thaWJauu4= X-MC-Unique: rqpdbcPPNTObhjI9K1kMkg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 02/13] lib: Prefer g_autoptr(dnsmasqCaps) instead of explicit unref Date: Mon, 17 Jan 2022 16:19:16 +0100 Message-Id: <735f0efb7135827b8cf7f3d62687375c24634326.1642432611.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: 1642432827772100001 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 Sun May 5 10:13:58 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=1642433232; cv=none; d=zohomail.com; s=zohoarc; b=EG3nc537qHbGXIa7dbaaV0Br+VtLs0kbJrUYYQfgJd8VwQ2Ueq1SlFWLpOiFZPU8/YUI9pF5GrEk2dlgTMAcDH7NXGd24Armt9CxndD9tS0pI1TMiSl4f/e6zsx7/GK00sfY+a2LQlIQRirSkPmzlW8Q47wvTuLBquQmJ6zNCIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433232; 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=TCK0ranXs9WFXigkGHMPeUX3hOYDjt0zdteI6yRXBPw=; b=h5gEPx2VKHmPuTeJ1ikN+Z0y6GdzBuOU474Dm0jvQhPC8H1cViDTdR6N8b9IcKxjG6r9LRIHxnyJnF+Kt2EWvBrF4uhXgsjvNatm6WBR9HN9Lvz0D9yQL1NniZ94irgdfALaIvXy9hqZLZEknjXsVZhtHIrD4YL2TuMJE+6LQzY= 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 164243323229879.24060685342079; Mon, 17 Jan 2022 07:27:12 -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-145-ERMwnMg5Ol63ApmGWpH24w-1; Mon, 17 Jan 2022 10:26:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53B1E1054F97; Mon, 17 Jan 2022 15:26:27 +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 3474810A403B; Mon, 17 Jan 2022 15:26:27 +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 6AF7A1806D1C; Mon, 17 Jan 2022 15:26:26 +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 20HFJVMK031501 for ; Mon, 17 Jan 2022 10:19:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id E7F1B2B4C5; Mon, 17 Jan 2022 15:19:31 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70F1326576 for ; Mon, 17 Jan 2022 15:19:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433231; 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=TCK0ranXs9WFXigkGHMPeUX3hOYDjt0zdteI6yRXBPw=; b=cy1ZU8V6Tehon5YOaJlSb1BW0z1jZC7G/pDEeqb9gBJcLRJTbzeUoc5nnrG3gxmJSstlm4 yw76rpI1h29nW3YWTexVfSpDhHFO+YWeTwdy9KIBq39qt78+eZcPNhkqjSvofjAV+NZjfj 5o65gzQvm3MchL102vIkTbVglN/dgTU= X-MC-Unique: ERMwnMg5Ol63ApmGWpH24w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 03/13] virdnsmasq: Drop @force argument of dnsmasqCapsRefreshInternal() Date: Mon, 17 Jan 2022 16:19:17 +0100 Message-Id: <73b5daa818351d3ce987f94748266e5df59bb4ce.1642432611.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.22 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: 1642433233177100001 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 Sun May 5 10:13:58 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=1642432899; cv=none; d=zohomail.com; s=zohoarc; b=G+v+5gCR7okuGMFwpkjJTkhLqzISwBqe3INmGPgNMxgG/qaoyTh1hXY1McY+pTy6N1LDerEXErvv5eSHSvcp9HemPYa25mhKRTxHzxtv/1p+lwRQ6k6IcjrTBmDIUHOl2dVgBq2dXjUy8C/1HsrC/LEPGO5AWYfKyb8VIatU8NA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642432899; 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=HxANYHt5RzGK3Q86svdVFLm6Uh4Najv5A4M6CUL2luU=; b=JR7mkxLoRptIC730orzmV7tpfYl8/6C0hRL5Au+g4uXqrnuVagDBJcBhtpAZsbMQrD8Dr4Tji8E7V7Tn1qjXtKnwJlFp7kHA+u9TPbqWqSOT4Dpalq4cXBGope+7XFWAkY6rnpX+Hf9BaqCVfsDXNs81Yk5P5V2rncmiWr5jYeU= 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 1642432899351398.61301504095616; Mon, 17 Jan 2022 07:21: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-648-NQaTVyn7P-iNHk_q64Ha2g-1; Mon, 17 Jan 2022 10:19:57 -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 7DFD285EE72; Mon, 17 Jan 2022 15:19: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 9BBC9798C9; Mon, 17 Jan 2022 15:19:37 +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 E53991809CB9; Mon, 17 Jan 2022 15:19: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 20HFJWuC031514 for ; Mon, 17 Jan 2022 10:19:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id B835C2B4C5; Mon, 17 Jan 2022 15:19:32 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 422B026576 for ; Mon, 17 Jan 2022 15:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642432898; 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=HxANYHt5RzGK3Q86svdVFLm6Uh4Najv5A4M6CUL2luU=; b=NbVlQEIAmjdUKVl/+WyoSAn39fryqjbSxDLbGp1RLvbVzzyJsHQ5YrkZ/+fvq/xki8ewb4 wV5/gnJHfa57JVBFKvUyxeGMmeJZTXOdqau5pDFnoy57HSn0x+M8AdftYCZ7gp7/VzRr+p p4OuoPDd9QIKAImxUBsBWcLh+UjFiXc= X-MC-Unique: NQaTVyn7P-iNHk_q64Ha2g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 04/13] virdnsmasq: Drop mtime member from struct _dnsmasqCaps Date: Mon, 17 Jan 2022 16:19:18 +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.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: 1642432900488100001 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 Sun May 5 10:13:58 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=1642432835; cv=none; d=zohomail.com; s=zohoarc; b=K3dMdqH6Sjsni33ro42OJaF8mBSvC/gc32GB23i/mQGVxRv8KPhPnbQ3pTKgHb8ebpH2GKxEpgzl8fuk30xJ9HAyALQRRPDK7KvQ3pqOQB5TriPsuUYivYLSI5X5cFcq0I8p20G/0qTZhkbfSlTb+VfO79U5OUs5OOZi7bAzmHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642432835; 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=CKC7Ibhm7CLsmsK5Et61eAYmWMlOsHFmExaQeHVwuI0=; b=oGwwa31rYitwtWu5GOoHeV1mIeO3DqC28XDTtrjVgqLsFjaKSwxpkV6Dk9x3UL5JOyRRiHQPgVEPmt3b/dPVKyjCnjLkO05UEc4zI71hQRTa1T2GhOnfEIupG1K/1MwETskbQy3oveQ6z3etdu6L81WaKZoRwD5S57xF1lLG9Dk= 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 1642432835835345.5303531617342; Mon, 17 Jan 2022 07:20: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-216-0FlxLxdxOKiVkIc7ItgiRw-1; Mon, 17 Jan 2022 10:20:31 -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 EE1FA85EE6C; Mon, 17 Jan 2022 15:20:01 +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 C867377467; Mon, 17 Jan 2022 15:20:01 +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 955134A7C8; Mon, 17 Jan 2022 15:20:01 +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 20HFJXds031521 for ; Mon, 17 Jan 2022 10:19:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 89D8D26576; Mon, 17 Jan 2022 15:19:33 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1368A2B5A5 for ; Mon, 17 Jan 2022 15:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642432834; 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=CKC7Ibhm7CLsmsK5Et61eAYmWMlOsHFmExaQeHVwuI0=; b=AqCZ/MQwMrkDeyjJFCXMp8NMbmAYzJpWE4Zo874m+ZwM7nLDG7+vUo2819j1FNcdA1UCEa 9x28b2HVkw3kVLGIysKerjxtOpEtfLulRlt6DYXZSgwGPAiH2sSoXS+ycg87VjKNJoDh8Z GZroN21dBfWAYJVkByRyqsIz4ceg3GE= X-MC-Unique: 0FlxLxdxOKiVkIc7ItgiRw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 05/13] virdnsmasq: Drop noRefresh member from from struct _dnsmasqCaps Date: Mon, 17 Jan 2022 16:19:19 +0100 Message-Id: <956a55c8a6b7ab0623361c80abe8495506b9c564.1642432611.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: 1642432838119100001 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 Sun May 5 10:13:58 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=1642433065; cv=none; d=zohomail.com; s=zohoarc; b=mMa2euOIECyqkv5hr5+XpaJEDZjGRdDIpy8BKyvGaeADC0gsBmj57Wa0h3EdXpHTaGmM5AfooYBgoWKL4r0rQCkpaX8/5Ac5CmQ8rkH8nPrIhCE+5QbEPhDB+XGWiuxP31X/b03zJxQ2wcJuwF7ywINnpjP2rkScmRewlnACURM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433065; 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=9V1IIR2jrcLL6gO2MIO7/lKCvzFIiYfCaDsjjju1oJw=; b=Srg2/ZSQUxIBTbhOtPz7D7ZYKdwwtHFW1t6W8m76dsP03HjpXXL3S874islv7eVTUFT589EJSuorNLq+XX2xVr23vPbvakJ1CSkzSiFCsRrsHrtjob32vxIhfylJH6DKnQ8FghtVir1nK7VSCPeERcfqaQPoaBtxu3AmyyJa7LA= 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 1642433065203839.2818137345366; Mon, 17 Jan 2022 07:24:25 -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-588-_eyAAN2yPtK7WCsfoaHixQ-1; Mon, 17 Jan 2022 10:24:07 -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 6A7B5192D787; Mon, 17 Jan 2022 15:23:54 +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 4AD6A77453; Mon, 17 Jan 2022 15:23:54 +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 1C20D180B654; Mon, 17 Jan 2022 15:23:54 +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 20HFJYNW031526 for ; Mon, 17 Jan 2022 10:19:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5A9A62B4C5; Mon, 17 Jan 2022 15:19:34 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id D88EE26576 for ; Mon, 17 Jan 2022 15:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433064; 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=9V1IIR2jrcLL6gO2MIO7/lKCvzFIiYfCaDsjjju1oJw=; b=HCKAoOfJymNpLqXTUnkI9nwtbEFl5efBu4uSWVjkCkwyCDJzz+zeP5ADIayVjKVx3iwljT Wczf5Wo7Wnj8+Gb/JPMT5V4zObjKzyDwWjZIBaFiqNFN29tt8pE2O5V4kxq6lhNN3QPkFm 5vp/L+sKpM/bYEt1ONainfIudN3kNuA= X-MC-Unique: _eyAAN2yPtK7WCsfoaHixQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 06/13] virdnsmasq: Drop !caps check from dnsmasqCapsRefreshInternal() Date: Mon, 17 Jan 2022 16:19:20 +0100 Message-Id: <68643caa17e1297d539910c8cba6d71df2c2b858.1642432611.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: 1642433065727100001 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 Sun May 5 10:13:58 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=1642433081; cv=none; d=zohomail.com; s=zohoarc; b=Ajo7F/xSWXxdyieZ1qzZOLM9Bq7qUGLFc4Ik//8HrjWjQFucgolVRS9YqB0oDIskJ+SUl19Q4f9GmFI2foti4DKEbH4wgOnjKBd0eaoyKpBCP9QpwfDoq5TnIgflXof3GvoruFQDOBZxkuFieDEneJHr8ZBOci6jlYZRmh45vhY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433081; 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=la9A23M/vy5zDfY2Wqe3A1xzZ14A17Q/D2DUtV5xKLM=; b=Y1ItVM3zCT+0z1XTyYbkIV/M9nzNaM1nPHxG6p1irBTxgXxo2wkt5RKSBPBR4Yu+QIGuo6m/wbzJjzZ+3Adp3zO2Dxld4297+XbHx/hcYzZEvevTI8l0SBLbBjnaePxhMxlLXghzDoykBi7/JND9jFlGNYMAgMKAA0THiRdedCc= 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 1642433081018265.533850025441; Mon, 17 Jan 2022 07:24:41 -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-422-aoGmABwBMVukujzTtdGpYw-1; Mon, 17 Jan 2022 10:24:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 20857102CB35; Mon, 17 Jan 2022 15:23:59 +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 ED27B71DE0; Mon, 17 Jan 2022 15:23:58 +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 B63E64BB7C; Mon, 17 Jan 2022 15:23:58 +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 20HFJZr4031531 for ; Mon, 17 Jan 2022 10:19:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2B73126576; Mon, 17 Jan 2022 15:19:35 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id A96152B5A5 for ; Mon, 17 Jan 2022 15:19:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433080; 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=la9A23M/vy5zDfY2Wqe3A1xzZ14A17Q/D2DUtV5xKLM=; b=Vzt/fwUZ+UUFoU8YUEdGQUU4Nie/JOCaEV8F1GUYuhp3Fe4y6P+HjRVQrl+5jhc2XGv5BM ctrNyBy0HnGFLPUVnwWO6al2TFD9PNP1zt/ir/uAj8pbHww1sd+aVgKVxH9HJjhUlk987T xz+zOphkoM/fK8f5f5BnnP96LmAeUvo= X-MC-Unique: aoGmABwBMVukujzTtdGpYw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 07/13] virdnsmasq: Don't run 'dnsmasq --help' Date: Mon, 17 Jan 2022 16:19:21 +0100 Message-Id: <243857a3bd69cf3b9903c05cafdd6ab9bbe58b76.1642432611.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.13 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: 1642433083283100001 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 Sun May 5 10:13:58 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=1642433070; cv=none; d=zohomail.com; s=zohoarc; b=HKypBjE+PhkgpRIhX9mlhuTEXErnxz8Zg2jJz7aZlpaiquxWkptW/0gjzmK8QdBX1wDg8RABrtqrKmc5oqub5cDn37IWdyniLqsjk9N3HA17GTirChQDLQofoHqDasQW9hptQuEFlhLT68mkJsB0VQZYszjopkMe3BvLPLW1Rso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433070; 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=MTbNPIvzrAC1wmzxyqxoyEkLzWMYdITcCXIjAU07CXU=; b=DAr0rizCb/rP8cZMfJxPW9Spj9QyH81Ksmyau7qlfPKhct/wK60NzG2GcuiclEw9+7xjETPAVrT0g0n0JJQft34XejqWnUpw408jAHSrMGPoQCvdSOyde0PChk8x3wrPJ//9t2xMEnnVr5/ShS4MlWw9Zha3HMvnwdhhXFRCdAk= 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 1642433070866933.893334409071; Mon, 17 Jan 2022 07:24: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-227-d9QYYCXDOAiJ_O0dkuFAKQ-1; Mon, 17 Jan 2022 10:24:14 -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 5A7D993930; Mon, 17 Jan 2022 15:24:03 +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 3652C7E645; Mon, 17 Jan 2022 15:24:03 +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 F14144A7CA; Mon, 17 Jan 2022 15:24:02 +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 20HFJZ5X031539 for ; Mon, 17 Jan 2022 10:19:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id F083226576; Mon, 17 Jan 2022 15:19:35 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79DC62B4C5 for ; Mon, 17 Jan 2022 15:19:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433069; 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=MTbNPIvzrAC1wmzxyqxoyEkLzWMYdITcCXIjAU07CXU=; b=SPvaP/uPQwXLI7gD4iZr7ialKLjYM9uupeThF1Q8uC7SRhLhdPH5BV5Lmt7LVChGrktWML Luift8WXSLHPg03WR/BW6WqGXUiZhY3AqflqROqdakCPqZvc/LiG2ZDNwRU2w3M4IfikqI RAYT5uF73MfT6w7yyNoIMtOVwu+6TjQ= X-MC-Unique: d9QYYCXDOAiJ_O0dkuFAKQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 08/13] virdnsmasq: Lookup DNSMASQ in PATH Date: Mon, 17 Jan 2022 16:19:22 +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: 1642433071558100001 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 Sun May 5 10:13:58 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=1642433103; cv=none; d=zohomail.com; s=zohoarc; b=S6ZPYDka1jSndBX09v70Eo7bgpErUuiAZbS7Xn20KElJj0sv3qoqGt93tK43qfpVSu98VV3DyZAhlKcEcOzTqHL9eM1hOYmGDAcpLIegeAAYIK2WJuatvpF7/XOTpzIk+n+iGcG2vI5faVW0Yho21JL6mSDGpzEnZozpJ2A7stE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433103; 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=VZAsU9TUZtMb0n7fXJi4yCQjnzHBQvZKBJNUsnMI+aoBGsiOlnHzphqDG/G4YpfTi98pk0lNn0nCF6YOpT0I5vK2vLU0RVrVJVfbS6DAPluANwF5CztiRf5jdE6wU2cUN5k2ewX19tkQGwfL3XAz60mLjRMxOQCXBjd1ZLhd+qw= 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 1642433103293547.6947144579633; Mon, 17 Jan 2022 07:25:03 -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-610-L-Xo0kVlOFydt7t1pqPk7A-1; Mon, 17 Jan 2022 10:24:48 -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 E538D84DA40; Mon, 17 Jan 2022 15:24:34 +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 8EA017BB57; Mon, 17 Jan 2022 15:24:34 +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 540E91806D2B; Mon, 17 Jan 2022 15:24: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 20HFJa2B031549 for ; Mon, 17 Jan 2022 10:19:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id C184F2B6CA; Mon, 17 Jan 2022 15:19:36 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B18026576 for ; Mon, 17 Jan 2022 15:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433102; 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=ajwHyiwyjXWYGKfaQBC2K5Tb5V+xUox3wW1nSIhyt5cNaXzVssrvsbSHxZ6m5OOfGIMHGp jWwMbHjf131vd0ZpmEMY2ij8mXrMnYMw6rrGb2PLh+KCL2oXh0w341J/ddlqW/X0souYzo 4Hbjwrn8T1byqZ5/gm/jvS5x3WUFW8c= X-MC-Unique: L-Xo0kVlOFydt7t1pqPk7A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 09/13] virdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath() Date: Mon, 17 Jan 2022 16:19:23 +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.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: 1642433104398100001 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 Sun May 5 10:13:58 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=1642433066; cv=none; d=zohomail.com; s=zohoarc; b=kTGUtKU5GgCJIgo41aWrhqluKzsRE91y7ALbk55R4Q3Xg3LSE7CmKhz7POklqA0SrNm7nnmWgbbqdAuiJcoRD7Cj4LX3qkqG3fYnU34YUDF0eO3jFu0TIN6fNIAEI0oiIKyubF1DEiVEzbaDgdDQd4ezKydVb0SGJ2hEWAIdwxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433066; 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=F1+CTCCXnFUHCt+zc6gdPnISVNvcgyzsn7MWP/k1zvE=; b=CWNwbgcdkoxvvcqmL1QYxsZO7DxNkBQmJinT7WoOBVKiAE6aQ0cI+eZnIIG3sNr5C0P6sAYhP0NoPaT/4G8vMYWjL86Nhjqqf1Drd6rGHCZ0o3KxCYRXE2yxSMDIUMsPcFdKoRuIN+CcoYKRkbbndcBeeS6TGquOli/He2ykt3o= 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 1642433066595651.4438523097045; Mon, 17 Jan 2022 07:24:26 -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-296-D3R-FvGDPQ6NOON0UxFiLg-1; Mon, 17 Jan 2022 10:24:16 -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 58DF01023F5F; Mon, 17 Jan 2022 15:24:06 +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 2C351798AB; Mon, 17 Jan 2022 15:24:06 +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 D9AD51806D1D; Mon, 17 Jan 2022 15:24:05 +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 20HFJbmZ031564 for ; Mon, 17 Jan 2022 10:19:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9211526576; Mon, 17 Jan 2022 15:19:37 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AB132B6CA for ; Mon, 17 Jan 2022 15:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433065; 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=F1+CTCCXnFUHCt+zc6gdPnISVNvcgyzsn7MWP/k1zvE=; b=P6EvnakeoafLdIqhHAEG5yImnnfpdxvBa5UludM0wLtfInYIT81hWI8w+D6bQp9BBekeBz vSQaC6DzcM/X/0y9jY/fOVxUD8IDyhK3fETRtq5PjixTKGjgisZZMTNRtVdrzfQOcQjYrH Q9gzaCaTS8v1gmM2/RzetDqbMds+pdA= X-MC-Unique: D3R-FvGDPQ6NOON0UxFiLg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 10/13] networkxml2conftest: Use dnsmasqCapsNewFromBinary() to construct caps Date: Mon, 17 Jan 2022 16:19:24 +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.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: 1642433068026100001 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. Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- tests/dnsmasqmock.py | 13 +++++++++++++ tests/networkxml2conftest.c | 2 +- tests/virdnsmasqmock.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 tests/dnsmasqmock.py diff --git a/tests/dnsmasqmock.py b/tests/dnsmasqmock.py new file mode 100755 index 0000000000..0cfc65a854 --- /dev/null +++ b/tests/dnsmasqmock.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +import sys + +output =3D { + "--version": "Dnsmasq version 2.67", +} + +if len(sys.argv) !=3D 2 or sys.argv[1] not in output: + print("invalid usage") + sys.exit(1) + +print(output[sys.argv[1]]) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 13257c749b..f96a92b9f0 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"); + full =3D dnsmasqCapsNewFromBinary(); =20 #define DO_TEST(xname, xcaps) \ do { \ diff --git a/tests/virdnsmasqmock.c b/tests/virdnsmasqmock.c index 448332ec40..b043c5ceca 100644 --- a/tests/virdnsmasqmock.c +++ b/tests/virdnsmasqmock.c @@ -12,7 +12,7 @@ char * virFindFileInPath(const char *file) { if (STREQ_NULLABLE(file, "dnsmasq")) - return g_strdup("/usr/sbin/dnsmasq"); + return g_strdup(abs_srcdir "/dnsmasqmock.py"); =20 /* We should not need any other binaries so return NULL. */ return NULL; --=20 2.34.1 From nobody Sun May 5 10:13:58 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=1642433243; cv=none; d=zohomail.com; s=zohoarc; b=ckut63STwNB4CPzxaD+Lh+oLhktVD5gR3iqkmuGQwdR3SPP2uxWLKcY3r1lwGOUi/avnK+yneE9D2lvoxUK96deWtrRVgqxyT6XC0l1i/pH22lhCRMObS4C6NiqUMJMo+OnzmCAB/4e2byznB5gpgI2Fs0u8PUTddtVg3m7Icoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433243; 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=iBAnYk4j4WpsVRqLPDH39Sv2Lp62d9SN54Q4l5N2LKE=; b=efgOe+VZxyRrifR8mSaQA7vKHhqcIL6DfdSkIwvGkXjfvbEIwkVjKjPT4feTrMNmDKbAtuDh0ztc9g4gkhHmT61nMrAuHIqXk/dvDPHAcBfLx4peiINhcraxnNkf8DKz7N/PkgruEzF9Fn5hFhRCgOI5zqgtHBvLsRqVgR3UMmQ= 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 1642433243516815.3125927034237; Mon, 17 Jan 2022 07:27:23 -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-224-Qlem1YNZOly7mxduJeOTLA-1; Mon, 17 Jan 2022 10:27:10 -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 B2D6683DD39; Mon, 17 Jan 2022 15:26:33 +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 8ED6C7E412; Mon, 17 Jan 2022 15:26:33 +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 5CCFD1806D2B; Mon, 17 Jan 2022 15:26:33 +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 20HFJcOF031571 for ; Mon, 17 Jan 2022 10:19:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 635522B5A0; Mon, 17 Jan 2022 15:19:38 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E0E972B6CA for ; Mon, 17 Jan 2022 15:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433242; 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=iBAnYk4j4WpsVRqLPDH39Sv2Lp62d9SN54Q4l5N2LKE=; b=G7UHu7/c5zjdICfUoYpRj7cF3CEDfbTF3s2XBTMwpYhHdwFdFBBTA14wzW1Guyvmowm1S/ m4guwAyfu1QtcwnBIhaKKne3t/S8FMm01yu7ZVd0mFzVjgkTenVQKVJZ7rWJTatzYSrmgT xX19ZW4tIwg36jyJSnsM7RfDaN8nnO8= X-MC-Unique: Qlem1YNZOly7mxduJeOTLA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 11/13] networkxml2conftest: Check if capabilities were created successfully Date: Mon, 17 Jan 2022 16:19:25 +0100 Message-Id: <1680c5475e15291a94ea82e681f66d7395858c3b.1642432611.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: 1642433244996100001 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index f96a92b9f0..6bc0c1465e 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -114,7 +114,10 @@ mymain(void) int ret =3D 0; g_autoptr(dnsmasqCaps) full =3D NULL; =20 - full =3D dnsmasqCapsNewFromBinary(); + if (!(full =3D dnsmasqCapsNewFromBinary())) { + fprintf(stderr, "failed to create the fake capabilities"); + return EXIT_FAILURE; + } =20 #define DO_TEST(xname, xcaps) \ do { \ --=20 2.34.1 From nobody Sun May 5 10:13:58 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=1642433106; cv=none; d=zohomail.com; s=zohoarc; b=R4HYqkRANGtYTj461G87sQdC6qOVJx9IvaW3Ni3N+b5xWPM3mfgLECudbgxzbPuK5FIdEUxqNXZAuAw4WOlmOeIYSDcjc5yrcZ1vIE4ZBbBVNXs7+qvv0q7o3AKv6okdRpLir5+nwKCfd+qXYiC2erArCTTCsEitelhypZiYg8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433106; 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=kC5oPnh75Ck03l/m7qURTV48nWuvds7+fLw1qoY8j5V/A+s9GRStrb0MpiFEBp16JdZmQoCnbo1wQqhFK8rexducVejyHP6cL9YrIz0uarWFwio98+PfnPmrLyk9h67ixDDIAzQIlgbaWbHXa1Jw7u7XzEqm4fgtBk9hcvPJgaA= 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 1642433106953600.6567756150716; Mon, 17 Jan 2022 07:25:06 -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-182-DIsauLY9OVW75O3Sp5uh3g-1; Mon, 17 Jan 2022 10:24:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC89B94DD6; Mon, 17 Jan 2022 15:24:09 +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 84A165B922; Mon, 17 Jan 2022 15:24: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 281BB1806D2C; Mon, 17 Jan 2022 15:24: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 20HFJdgj031579 for ; Mon, 17 Jan 2022 10:19:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 364F92B4C5; Mon, 17 Jan 2022 15:19:39 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id B416226576 for ; Mon, 17 Jan 2022 15:19:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433106; 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=L9uAm37otp7n5VwUhYnl+biVQ4iHjW6vIkyYkKzd3YCnZ458rCPPKEvxH1YbIVpCVWUq21 o/5S4Fs70JbUl2ArbodSmEvuGj9nOYubNho7fIpxwxyFQ8Hw4uNcAuyLlccmDSA+z8THz2 JMuHFZJUQ1dc8sou07VuHaahsIVW2zg= X-MC-Unique: DIsauLY9OVW75O3Sp5uh3g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 12/13] virdnsmasq: Drop dnsmasqCapsNewFromBuffer() Date: Mon, 17 Jan 2022 16:19:26 +0100 Message-Id: <1285f8e217ed26693829a7e63bca0bea0a5477e9.1642432611.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.13 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: 1642433109160100003 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 Sun May 5 10:13:58 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=1642433390; cv=none; d=zohomail.com; s=zohoarc; b=gt3Io4XxAS64jq5YkCTqLC9FA8FiMGoRrE2RpHUJJ5eFHRf0bYfNpPXEtktGVuivIcEvFIqW4nchjDWxVistoe+i+NyV2u6TV5uX914yOdsmD/vTnddQSxAueOi30CqkK1BzwgyxeuyqHJXAWQzFnjUYs2Ao/o/Eqhg0/KYI6FA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642433390; 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=Z8NZkCcLFOMXonzuit7JaROLi7/XYTqtTiGXD88eqT21jvhA764Dox3CdvE6VJ6JZf6+hdq+qAW7e+xn8Z3RNzt/NHYsex5zqAL7PBdPedQX0Q1p60XpZQFdewz5fjDvPnNU02S5HqkPP78TBkMpzZ/9S1e/oOZ5rVXQVDlz/Tg= 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 16424333906299.13003983151691; Mon, 17 Jan 2022 07:29:50 -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-447-e3LxfstkPWKN9dv-iVKMNw-1; Mon, 17 Jan 2022 10:24:55 -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 7DE8019324A5; Mon, 17 Jan 2022 15:24:39 +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 324E87D5B4; Mon, 17 Jan 2022 15:24:39 +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 C44AF1806D1C; Mon, 17 Jan 2022 15:24:38 +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 20HFJeam031589 for ; Mon, 17 Jan 2022 10:19:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 094CC26576; Mon, 17 Jan 2022 15:19:40 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 848DE2B5A5 for ; Mon, 17 Jan 2022 15:19:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642433389; 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=BIj21w2vj0H6Ms3yog9J/xGzJdNxPKDy2EnIErGXbF6DUECi2weAnEPWw9gNbPk4yrh6tT Z06ng7bBeEZ6vuA6/oqBg/fjUEwbaOofwVbsfXLXBs/2UoRnJrV2lXNZ7aDOkZmj1OIBg9 FEsCpmSTz7WklH41zzavEApGH37AQ8c= X-MC-Unique: e3LxfstkPWKN9dv-iVKMNw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v4 13/13] virdnsmasq: Join dnsmasqCapsNewEmpty() and dnsmasqCapsNewFromBinary() Date: Mon, 17 Jan 2022 16:19:27 +0100 Message-Id: <83dd7a90b5daa42b28fabf50fd516eaa0d33eba1.1642432611.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.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: 1642433392455100001 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