From nobody Thu May 2 18:41:55 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=1641829579; cv=none; d=zohomail.com; s=zohoarc; b=PtS0G6fF0F1Gj9XFg1JlVCVukBmZH4VKS7z6iJl3KqD832AKrnklUW6450+JjmNpD9W9tQQx3IT4GDitSWVcNB7tuIenEMxOi9gex+oxYDAT86IAOL9i5Gq/6HgKEKYwX30VY8LcV1yqlk4ugmjhlswaZTNFFve33TrAy3IGTpc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641829579; 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=ptTnQhrJmc2yQp3vJxbmcFum8Qzlp6epe0HBHv6X00w=; b=QJbXVhCVLP8KpjtpYya8OM4cSZzVEJvf6jkbxju5BVaQS/YRN3LHHrjXvDNFRDOR4v3ko7JXm6mK9U+a+fawNVsMD56Bl+QOnZfpJ7zjXqL/5Xx9ovWiJyxHyMt5x9ZthnADsj+6uTtpBOuCrvBCV7+4k0BRYIVkD4rv1aOmPUM= 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 1641829579422713.4115856368778; Mon, 10 Jan 2022 07:46:19 -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-177-f98ptrH7PMSUUbzIO9E0QQ-1; Mon, 10 Jan 2022 10:46:14 -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 2E7A4343CD; Mon, 10 Jan 2022 15:46:09 +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 094842BE76; Mon, 10 Jan 2022 15:46: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 CD9BA4CA93; Mon, 10 Jan 2022 15:46:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20AFk7Jd019015 for ; Mon, 10 Jan 2022 10:46:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id EC3FC105C89B; Mon, 10 Jan 2022 15:46:07 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 725EC105C892 for ; Mon, 10 Jan 2022 15:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641829578; 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=ptTnQhrJmc2yQp3vJxbmcFum8Qzlp6epe0HBHv6X00w=; b=agzhbKBe853qMlUbWby10q6AwqOVd29kH4YrsDJBTz0AKV8I7jmLCXcfNJyecr5xLZpTDr rzZYPVeSDmousWkOabgvVxInZTxzxvFZbUCxA8HNXP2G7ilMR5T0TfvVFAXPKjBFoP0acT 6E/eG7kQWCU1tC0Uxbr315uUDZJJpcw= X-MC-Unique: f98ptrH7PMSUUbzIO9E0QQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] virdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty() Date: Mon, 10 Jan 2022 16:44:53 +0100 Message-Id: <62966f3d946806b66a31cb27d3fa7696f985817e.1641829321.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1641829581122100001 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 Thu May 2 18:41:55 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=1641829597; cv=none; d=zohomail.com; s=zohoarc; b=nZQHTTEssjbSvx0R7o8qV1uLQeMQwjdd2tgQuH/6ydoZiGtlJRkq8zPDGGTeVq9Ri/6K5Kmw37H2Ddy3Ximf8LDqS6TMTXUM/cmZUuUH0qfgqkeIQB3vymHddBSUpKPfpy+lixAos245BnnyhYy9UVUPU24vhiP+AcfcQwsh9vM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641829597; 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=gGze9ImmhLf+zKjnqn3DrivmK7cws3kbMwZRqjnMa1Q=; b=ev8cRz3YfknFleTUCr1skJsySV4o2mu4T8aY7KJor5AC9ypstA9RjFl3zCXy6iwA1vYUysvio60fmfVorXnG6jCAk6ZV+3G2slY4p/jRTuLagPpeXSqI9Atdrh/tYWsKaU59yWwnUYzEQcmioZzDn3L217SdLGu9L3tKmRaWU6E= 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 1641829597169275.5814312381424; Mon, 10 Jan 2022 07:46:37 -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-619-UMDZnFweNnuOBlzJ_LZViA-1; Mon, 10 Jan 2022 10:46:31 -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 CAD961023F6C; Mon, 10 Jan 2022 15:46:15 +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 8F44534949; Mon, 10 Jan 2022 15:46:15 +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 57CA71809CB9; Mon, 10 Jan 2022 15:46:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20AFkD8S019044 for ; Mon, 10 Jan 2022 10:46:13 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E1AF105C89B; Mon, 10 Jan 2022 15:46:13 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27F09105C892 for ; Mon, 10 Jan 2022 15:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641829596; 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=gGze9ImmhLf+zKjnqn3DrivmK7cws3kbMwZRqjnMa1Q=; b=AQ/IkNe1t3eix0bcPkRJtmL2xMRn5MDDRev42i1CvWfBt7qYZBbNCjkjrh90PVa+pfa6L4 2KK7dMz4kAAh86D9Z/rf/4JjoqR4LNLTIModvsud8IsQDho6Jyz+FlpKd+/N98HVnoQEfJ WHQrbUNIr7EesTAGETT2+fC7q6AvVMg= X-MC-Unique: UMDZnFweNnuOBlzJ_LZViA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] virdnsmasq: Lookup DNSMASQ in PATH Date: Mon, 10 Jan 2022 16:44:55 +0100 Message-Id: <978eb28c147e129633f76043de064852841e30a0.1641829321.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1641829599878100001 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. For instance, it does call stat() over the binary to learn its mtime (and thus decide whether capabilities need to be fetched again or not). Therefore, when constructing the capabilities structure look up the binary path. If DNSMASQ already contains an absolute path then it is returned (and virFindFileInPath() is a NOP). 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 d304929d51..b6ccb9d0a4 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -708,7 +708,7 @@ dnsmasqCapsNewEmpty(void) return NULL; if (!(caps =3D virObjectNew(dnsmasqCapsClass))) return NULL; - caps->binaryPath =3D g_strdup(DNSMASQ); + caps->binaryPath =3D virFindFileInPath(DNSMASQ); return caps; } =20 --=20 2.34.1 From nobody Thu May 2 18:41:55 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=1641890660; cv=none; d=zohomail.com; s=zohoarc; b=clsiQzleUfNZCJdP3/9nTKW6DTlvrz2Zj0LpuIfv2fl4zIV26LDJLWT/e//Tg00sFno8BUsvOt3BnOsBqZFnddmsF8Er1qni5VSaQcZCZoPMrPsFto6XvM+VV6wYRLj6Xsj6v6iCfL4mkCXt2zdZAbzFLkcqz7o+Y2RwJm1mAkc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641890660; 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=d2ZPtyZc3/m3aHsJ1lv6gjLYqkSRPyOUQQQMrq5G+lA=; b=HSHo7fCzNbMa2DxUphQ5E0KIMjr3s15+qK9HRoRsSSFhALMoMyXpcv6nWrKpDCJGn8Dwet/RwCLd1ODiQk7aVOxx9qJ6Li9zM9bb0qo8XYiz2OB4Bscd3MgK1LklMSmpDbmYxksOgsFw0ZnJL5NP90My9KgL+yKNlumPGvZWd0Y= 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 1641890660579475.9208538812519; Tue, 11 Jan 2022 00:44: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-640-OTYJPJToMlqS-45hraRZbg-1; Tue, 11 Jan 2022 03:44: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 9DCB4192AB98; Tue, 11 Jan 2022 08:44:11 +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 34F9E7CAF9; Tue, 11 Jan 2022 08:44:11 +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 164E91809CB8; Tue, 11 Jan 2022 08:44:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20B8i855026964 for ; Tue, 11 Jan 2022 03:44:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 712416E1EE; Tue, 11 Jan 2022 08:44:08 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id EEE8B6E1FA for ; Tue, 11 Jan 2022 08:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641890659; 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=d2ZPtyZc3/m3aHsJ1lv6gjLYqkSRPyOUQQQMrq5G+lA=; b=NMR319HLEM7n6poMpO3PuEQTOhSNscOeeGYVQPVxsWkwcMGfEExmCuQVUyQoqMQvYBVB16 uQ8UUUdows0PC4CKqjm6OKR0L3NKP7sDCuQTFKq/QUjHUaJEhwAuLW9hgqVTXtqnRZSPy0 e7fq27HSbkbsOLrfHulG6feeYPXnzbc= X-MC-Unique: OTYJPJToMlqS-45hraRZbg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/3] virdnsmasq: Lookup DNSMASQ in PATH Date: Tue, 11 Jan 2022 09:43:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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: 1641890663758100001 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. For instance, it does call stat() over the binary to learn its mtime (and thus decide whether capabilities need to be fetched again or not). 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. But, if we failed to find the binary in $PATH then do not report error. Either the dnsmasqCapsNewEmpty() function is called from dnsmasqCapsNewFromBinary() which will later validate the path and return appropriate error, or the function is called from a test suite (via dnsmasqCapsNewFromBuffer()) and the caps are parsed from a fixed string. Signed-off-by: Michal Privoznik --- Diff to v1: - Per my experiments we need a fallback case when DNSMASQ exists but is not executable. At any rate, this whole code could use cleanup, but let's save that for after the release. src/util/virdnsmasq.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index d304929d51..8ddc2d0b78 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -703,12 +703,21 @@ static dnsmasqCaps * dnsmasqCapsNewEmpty(void) { dnsmasqCaps *caps; + g_autofree char *binaryPath =3D NULL; =20 if (dnsmasqCapsInitialize() < 0) return NULL; if (!(caps =3D virObjectNew(dnsmasqCapsClass))) return NULL; - caps->binaryPath =3D g_strdup(DNSMASQ); + + if (!(binaryPath =3D virFindFileInPath(DNSMASQ))) { + /* Don't report error here because we might be running + * from a test suite an initializing capabilities from + * a buffer (dnsmasqCapsNewFromBuffer()). */ + binaryPath =3D g_strdup(DNSMASQ); + } + + caps->binaryPath =3D g_steal_pointer(&binaryPath); return caps; } =20 --=20 2.34.1 From nobody Thu May 2 18:41:55 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=1641829594; cv=none; d=zohomail.com; s=zohoarc; b=fWfd6rpZVXmqcds+r0QbqvOBnmYpdlOM54pgej1NyFphB8RG40Elh7h8ms6s0eXN4f/JlTY+cygWC32hLtI7h46wNXxu/io7KFwo9WpmfA8q0sTfDM4H4RbqoXBFhRg2r+hr+GHcEE9PaoH1lsWTHRMHwVJq9l+oOq+TN46srLY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641829594; 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=NY56+Ya+KHHDBe8Ko3K9d5XV4uqHA+/Br2Lqm20D+hw=; b=Dfd0K6B1hZ28f7OZ1YjA+XulWfXRn3I2wxlIENUgeH63b2YPMFXjrI4y99AxEJRlGTSy+/oge3EdwVYPyJc7YDsHy4i1OGI0U21ysgINpn3SACEqVOcV8tGd93o5eWG1uaotqgg7Gd0q9pdOBCoT+K0/Zt4z3ohSdkBqI4oAGqM= 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 1641829594783972.2312278126121; Mon, 10 Jan 2022 07:46:34 -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-249-bG8M3dQQOga_rqqOff4oHA-1; Mon, 10 Jan 2022 10:46:32 -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 B00ED192AB9D; Mon, 10 Jan 2022 15:46:17 +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 8C8C3105C892; Mon, 10 Jan 2022 15:46:17 +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 598844A7C8; Mon, 10 Jan 2022 15:46:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20AFkFdK019059 for ; Mon, 10 Jan 2022 10:46:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D643105C89B; Mon, 10 Jan 2022 15:46:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAC1E105C892 for ; Mon, 10 Jan 2022 15:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641829593; 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=NY56+Ya+KHHDBe8Ko3K9d5XV4uqHA+/Br2Lqm20D+hw=; b=Sa4FC9FKoy4CeMdIBbT4Ic29l9yq9xLIgZ19CC0MEfavhqou0XULkNWm9fVgH2vdSUal+O +55K47TcxBhk/SpWkvj40EiaBl0JgYb14ygy0pOAptQ7QxtK4yVKJaZSSFPaRaheoDLMAt XPrAKwryAMO9YA+4dFYiA3ESsAp5LdU= X-MC-Unique: bG8M3dQQOga_rqqOff4oHA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] virdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath() Date: Mon, 10 Jan 2022 16:44:57 +0100 Message-Id: <57d4efc76d82fd94e4f2dc0f3cc859364bbe7da9.1641829321.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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: 1641829597084100003 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 b6ccb9d0a4..a869b398c7 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -745,7 +745,7 @@ dnsmasqCapsNewFromBinary(void) const char * dnsmasqCapsGetBinaryPath(dnsmasqCaps *caps) { - return caps ? caps->binaryPath : DNSMASQ; + return caps->binaryPath; } =20 /** dnsmasqDhcpHostsToString: --=20 2.34.1