From nobody Sat Apr 20 05:11:28 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=1641977319; cv=none; d=zohomail.com; s=zohoarc; b=mYBmyNnxx3CdKdrWl3SOxSVIG3tU4uCNKxS4DPNaLKM5lCR0V318msoL+ZeKe4+AposmvjNA0tEALiODaId20G/bP4fY3/La/D1EWXYkIB9cvNoo5w7d2tLhZA93IaELXvFNX0DbSfJajSKahGWsanzvf95bZzgHzLe4PdHHTN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977319; 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=lEctAdyFQ5MwEBIjlHzqILlqqP2o1GvPeiFp40rM2wUU1lptT20rPuD5SmsEWEcEMOQVcq/9y9g5FVzZQxZWbXFkWLNFDmD90e858O4JA8kgr1Fdb6TE7wFJ/2JF3NBioCdRejqRlDXdwleh5loHEqgybQxrqOA8wR9pL3DE2NM= 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 1641977319694453.8933195368603; Wed, 12 Jan 2022 00:48: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-453-9mUu1eF1Nie21VAQj70cQg-1; Wed, 12 Jan 2022 03:48:35 -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 1231018397BE; Wed, 12 Jan 2022 08:48:30 +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 E013770D28; Wed, 12 Jan 2022 08:48: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 ACF9E18077BC; Wed, 12 Jan 2022 08:48:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8mLEZ017385 for ; Wed, 12 Jan 2022 03:48:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 30F6260C44; Wed, 12 Jan 2022 08:48:21 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF977752A4 for ; Wed, 12 Jan 2022 08:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977318; 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=VJT2aR06xeyjcuhmfUjXz9kBP/8aC2yWKRQ41BhrjBV/p9zJulNXc737VvVWT8TSATeZK1 Xx9Ao5i/fJ6/jJL1T/p0pwANBp5uTjMt4vvlK+dfd4BMwxUDycT3XPazP5luNzC2n+/LYp Ks79aAuKiXqRjoVqQ9ZBaVsOSTsT6Us= X-MC-Unique: 9mUu1eF1Nie21VAQj70cQg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 1/7] virdnsmasq: Drop @binaryPath argument from dnsmasqCapsNewEmpty() Date: Wed, 12 Jan 2022 09:47:52 +0100 Message-Id: <5ef354a2d93f38cb0d71298b75149affdaa3a728.1641976729.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.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: 1641977321569100001 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 Sat Apr 20 05:11:28 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=1641977320; cv=none; d=zohomail.com; s=zohoarc; b=KjgFzdwtnjUqR7vUDy3zk/NSSfYqiRh7LPWThV2zqXZ9xvJ25TeySrPCFYjfzax3G9ekUSBP7jHbD08XocI7AbhbbmiG2ZrRIO81yXvbt/SmA8Mcn+VEOKTvdq77nXcHi5lavR7U/xcP25/dtprOl5Sy0V8MQgTL0NailcIg9Io= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977320; 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=gvOt7v+A5SH7kQzAUl1CnjiHfkg8ATIWnXdUWWQGmDE=; b=LaYIrLXjTNkvkx5onMz5EG1i2XCmmaMau8PgQBFIZpotNMjqNKcYQjB/aYmfXCG5pq62x+iNPezavTV9JUvmRSVMsv/Bn/QWMnvfgTcYONQH31i6a+nkN6orxC1DDxUbexzRD1tvNQV71gpaONy5+GwReoZvt8g2bE+v5Zb3xX0= 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 1641977320123522.0911732794115; Wed, 12 Jan 2022 00:48:40 -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-393-Vj_xnMgIP6GA_gthugtOJQ-1; Wed, 12 Jan 2022 03:48:35 -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 979371006AA5; Wed, 12 Jan 2022 08:48: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 7204570D23; Wed, 12 Jan 2022 08:48: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 EB7054BB7C; Wed, 12 Jan 2022 08:48:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8mRI8017395 for ; Wed, 12 Jan 2022 03:48:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1008967C9D; Wed, 12 Jan 2022 08:48:27 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F0D4752A7 for ; Wed, 12 Jan 2022 08:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977319; 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=gvOt7v+A5SH7kQzAUl1CnjiHfkg8ATIWnXdUWWQGmDE=; b=egLhqA51mzPEigiqcA2teMIUF2coHq4It2EyiVFneomhXcePvzNZDkEhiLTgFFYqZfxnH3 DvN8NB3VcwKHpJbxo47mGUIdTqf8Mv5wUFsq/aM4L5AEdh7z79YiT2XkCfpf9Fd+ozHcIF FCDJe3/Dk68fRjQh6EjehH2p+uJczBs= X-MC-Unique: Vj_xnMgIP6GA_gthugtOJQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 2/7] lib: Prefer g_autoptr(dnsmasqCaps) instead of explicit unref Date: Wed, 12 Jan 2022 09:47:53 +0100 Message-Id: <029c2671f4ecd979d4eb1b04855c1d2152c41bac.1641976729.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.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: 1641977321601100002 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 | 18 ++++++++---------- tests/networkxml2conftest.c | 7 +++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index d304929d51..f4bdab116e 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -715,31 +715,29 @@ dnsmasqCapsNewEmpty(void) 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 Sat Apr 20 05:11:28 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=1641977318; cv=none; d=zohomail.com; s=zohoarc; b=CerowrLRonRQ5Ji+722bdgW30R8aVOEMMqH871DRZqzPBVIQRVn+7lJqIIjd2GnTprGsQ+4UY1lFy1nPtUuUKzVc49cOeBD3yuqzp5ArdwnWA9fML9uKL44EPw61BmOTexh0pJPXIlQrv1sOfyg6t1ttF88ygscSJ8nLfZTOWEc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977318; 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=J3oVLblUJHV1xlICwi7rvVIA6OS/dWDwBieqwpSZ/NE=; b=VKg4V4Kwfg3O8oWIgnRxNptJeHp/ADYHxRKKLVajVFOtGgXeFGkovGhnw7ZQxlGngJUr5acMV/qw7TPYvrFTHbjHcVgt6X2LLRe6x3FVNLJWKdac0/J5xge9i+G03A9wKVvPiDHtw4zxXH+WwTMkWKqXh5UymYnC9BbfHHGkQNI= 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 1641977318551914.6166144138509; Wed, 12 Jan 2022 00:48:38 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-36-9xDbZrk2OHaS8V4xt6pUhQ-1; Wed, 12 Jan 2022 03:48:34 -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 3B8F583DD23; Wed, 12 Jan 2022 08:48:29 +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 07FEE7CAD8; Wed, 12 Jan 2022 08:48: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 BF5C41809CBF; Wed, 12 Jan 2022 08:48:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8mRne017400 for ; Wed, 12 Jan 2022 03:48:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id D1BE767C9D; Wed, 12 Jan 2022 08:48:27 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C95B752A3 for ; Wed, 12 Jan 2022 08:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977317; 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=J3oVLblUJHV1xlICwi7rvVIA6OS/dWDwBieqwpSZ/NE=; b=TIZ1sbFsvhwTuhnO2s+HmVRZa8oiCS26AC42tEpvghA5P6RyMGkREHKInIuUr3UikC9+ww CpYBu4An/2G/lmcOZy3yjRXG71QVGxT2vkiuDZASCHnDmWCrRlspma81Me6zSJxNGscqqx PoGVT5sTUmpxZnujprPtHDqStMAZNFE= X-MC-Unique: 9xDbZrk2OHaS8V4xt6pUhQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 3/7] virdnsmasq: Lookup DNSMASQ in PATH Date: Wed, 12 Jan 2022 09:47:54 +0100 Message-Id: <2da99211b2743e3f6cf1112dc64bbb3a01b7dd25.1641976729.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.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: 1641977319316100001 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. With this code in place, the virFileIsExecutable() check can be removed from dnsmasqCapsRefreshInternal() because virFindFileInPath() already made sure the binary is executable. But introducing virFileIsExecutable() means we have to mock it in test suite because dnsmasqCaps are created in networkxml2conftest. Signed-off-by: Michal Privoznik --- src/util/virdnsmasq.c | 22 +++++++++------------- tests/meson.build | 1 + tests/networkmock.c | 30 ++++++++++++++++++++++++++++++ tests/networkxml2conftest.c | 3 ++- 4 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 tests/networkmock.c diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index f4bdab116e..79060e2021 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -670,16 +670,6 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool for= ce) return 0; caps->mtime =3D sb.st_mtime; =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); @@ -702,14 +692,20 @@ 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; + + if (!(caps->binaryPath =3D virFindFileInPath(DNSMASQ))) { + virReportSystemError(ENOENT, "%s", + _("Unable to find 'dnsmasq' binary in $PATH")= ); + return NULL; + } + + return g_steal_pointer(&caps); } =20 dnsmasqCaps * diff --git a/tests/meson.build b/tests/meson.build index 4792220b48..e8f5d4c1f7 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -57,6 +57,7 @@ endif =20 mock_libs =3D [ { 'name': 'domaincapsmock' }, + { 'name': 'networkmock' }, { 'name': 'shunload', 'sources': [ 'shunloadhelper.c' ] }, { 'name': 'vircgroupmock' }, { 'name': 'virfilecachemock' }, diff --git a/tests/networkmock.c b/tests/networkmock.c new file mode 100644 index 0000000000..a9c13311a6 --- /dev/null +++ b/tests/networkmock.c @@ -0,0 +1,30 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include + +#include "internal.h" +#include "virfile.h" + +char * +virFindFileInPath(const char *file) +{ + if (file && g_strrstr(file, "dnsmasq")) + return g_strdup(file); + + /* We should not need any other binaries so return NULL. */ + return NULL; +} diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index d79c2b4783..8a6657654a 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("network")) --=20 2.34.1 From nobody Sat Apr 20 05:11:28 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=1641977329; cv=none; d=zohomail.com; s=zohoarc; b=M0XOy7BhnL6kcmrkrxxFkhkuCngt9+1NKydbaETQ/GrgVBLQ47jRDZHyg8/s4SDQnJEzb5/jQhgFXE3kb91R6TAzobxa/sKqfY9Coe9BFGU2wFgsvWNKl4mArHSaIVE4q1/qKfIUptHlLgi0G6Zsv8l7BvVcwKf6MyZVVNU4EIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977329; 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=yUlPjhwJomxhpHaZqtB8Kl93wOqO0NEOgzE9OOIYRms=; b=nnZtOZj7XNkapXDBRK0U6T6as2lO4xwoW1PR5K4tB34Shdxv4oz6r1Xm3Fk3AVuS9z+7oJgg2SsFFLv28kJ7l59caXBSKsiw05XWhxYoM5dv/i/nephQzrHSIjW8n5w3Khj5RVCimmgofYDGI1LYD9sO7PuCON1O7sc9f8ihVfA= 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 1641977329876777.9924130804459; Wed, 12 Jan 2022 00:48:49 -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-380-mjjurHk7PFCoZYdkjU7kzQ-1; Wed, 12 Jan 2022 03:48:45 -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 AA47783DD24; Wed, 12 Jan 2022 08:48:40 +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 8883C1F303; Wed, 12 Jan 2022 08:48:40 +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 573A84A7C8; Wed, 12 Jan 2022 08:48:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8mcNc017420 for ; Wed, 12 Jan 2022 03:48:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id E88A767C9D; Wed, 12 Jan 2022 08:48:38 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 730C3752A7 for ; Wed, 12 Jan 2022 08:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977328; 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=yUlPjhwJomxhpHaZqtB8Kl93wOqO0NEOgzE9OOIYRms=; b=JAYzIaRva7FDRvAuFw81RqrL8hS7tVv7a9aA4ZExkL5lMW8atyzFMe3yZhFqWdgm2U/Ok7 0b8FOIAyfLA5LykVjixwk6R7RjIkjjeOzawJ349tvPIz6bUJfdw1u7XN2MJrCzEU/k9Oo9 0d38FVJoqaYeBkoIvJMA2sMGJ07j4yg= X-MC-Unique: mjjurHk7PFCoZYdkjU7kzQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 4/7] virdnsmasq: Require non NULL @caps in dnsmasqCapsGetBinaryPath() Date: Wed, 12 Jan 2022 09:47:55 +0100 Message-Id: <71af9d9de2e6f8bdebfc46bf5ead6002afbe01eb.1641976729.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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: 1641977331610100001 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 79060e2021..6d63e9e3c5 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -739,7 +739,7 @@ dnsmasqCapsNewFromBinary(void) const char * dnsmasqCapsGetBinaryPath(dnsmasqCaps *caps) { - return caps ? caps->binaryPath : DNSMASQ; + return caps->binaryPath; } =20 /** dnsmasqDhcpHostsToString: --=20 2.34.1 From nobody Sat Apr 20 05:11:28 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=1641977341; cv=none; d=zohomail.com; s=zohoarc; b=bbE/3fUG6vPERpcU9fDHnRnyN+MabNIaX1cRyDC+o5ozQ5nM3Z6juf4RLMjkxLOwG1tb3jzDlYTCQ+1EpD/dL1I2H5YKc6LPWa4KBqy9P9WSg3sjXLaaDzh6M/FOnho02+YSHD7+zvBwEYl6sRmhj20DQ4mCwlT0dwBr9JnrMvM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977341; 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=s8AUUpHEgrDvhdThlL2NpDw6i0ZnXjIpuVFubL3Ie5w=; b=ddmjp5f7F2qlv414eRyGNIV69taVnhlRnuh2gAAmkILifBGgxc4Se2SS7346WiqGj8NsrdP/2wyv3R2BbG7RnbFMhFih6/fdxqRgae2wK0fnp9LcpkFORT/KNbxRS+Uckf8D9RmfhgnKgl0KNKO48dWSnDo6rpJ7OdXcYpUwwQ0= 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 164197734104077.23301833650135; Wed, 12 Jan 2022 00:49:01 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-146-Vs2X8v3yOJicpYcxxh8iMg-1; Wed, 12 Jan 2022 03:48:58 -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 51B871006AA5; Wed, 12 Jan 2022 08:48: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 3399110589CF; Wed, 12 Jan 2022 08:48: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 031B41806D1C; Wed, 12 Jan 2022 08:48:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8mqmh017615 for ; Wed, 12 Jan 2022 03:48:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1BDFA60C44; Wed, 12 Jan 2022 08:48:52 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99C18752AA for ; Wed, 12 Jan 2022 08:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977340; 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=s8AUUpHEgrDvhdThlL2NpDw6i0ZnXjIpuVFubL3Ie5w=; b=XfCR4x1aqfJp+QHAgMJ66OttkdcS9K5MeiX3xzzEYeCzL20vqFFQFetEmW/0lej3/S1q8X XBjYxjbzAKMPoobE3TRXo4GS44zT81vBp421A+s4RxXx1i10+2u0ui1v5ipsjDvLvpF6xH nPuglz+4QKKyOXhfiy11+vvEbK57+20= X-MC-Unique: Vs2X8v3yOJicpYcxxh8iMg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 5/7] networkxml2conftest: Use dnsmasqCapsNewFromBinary() to construct caps Date: Wed, 12 Jan 2022 09:47:56 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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: 1641977342781100001 Content-Type: text/plain; charset="utf-8" DISCLAIMER: dnsmasq capabilities are empty as of v8.0.0-rc1~145. In a real environment the dnsmasq capabilities are constructed using dnsmasqCapsNewFromBinary(). We also have dnsmasqCapsNewFromBuffer() to bypass checks that real code is doing and just get capabilities object. The latter is used from test suite. However, with a little bit of mocking we can test the real life code. All that's needed is to simulate dnsmasq's output for --version and --help and mock a stat() that's done in dnsmasqCapsRefreshInternal(). Signed-off-by: Michal Privoznik --- tests/networkmock.c | 16 ++++++++++++++++ tests/networkxml2conftest.c | 38 ++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/tests/networkmock.c b/tests/networkmock.c index a9c13311a6..25014de8b8 100644 --- a/tests/networkmock.c +++ b/tests/networkmock.c @@ -28,3 +28,19 @@ virFindFileInPath(const char *file) /* We should not need any other binaries so return NULL. */ return NULL; } + +static int +virMockStatRedirect(const char *path G_GNUC_UNUSED, + char **newpath G_GNUC_UNUSED) +{ + /* We don't need to redirect stat. Do nothing. */ + return 0; +} + +#define VIR_MOCK_STAT_HOOK \ + if (strstr(path, "dnsmasq")) { \ + memset(sb, 0, sizeof(*sb)); \ + return 0; \ + } + +#include "virmockstathelpers.c" diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 8a6657654a..68dd3023e1 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -12,6 +12,8 @@ #include "viralloc.h" #include "network/bridge_driver.h" #include "virstring.h" +#define LIBVIRT_VIRCOMMANDPRIV_H_ALLOW +#include "vircommandpriv.h" =20 #define VIR_FROM_THIS VIR_FROM_NONE =20 @@ -108,13 +110,47 @@ testCompareXMLToConfHelper(const void *data) return result; } =20 +static void +buildCapsCallback(const char *const*args, + const char *const*env G_GNUC_UNUSED, + const char *input G_GNUC_UNUSED, + char **output, + char **error G_GNUC_UNUSED, + int *status, + void *opaque G_GNUC_UNUSED) +{ + if (STREQ(args[1], "--version")) { + *output =3D g_strdup("Dnsmasq version 2.67\n"); + *status =3D EXIT_SUCCESS; + } else if (STREQ(args[1], "--help")) { + *output =3D g_strdup("--bind-dynamic\n--ra-param"); + *status =3D EXIT_SUCCESS; + } else { + *status =3D EXIT_FAILURE; + } +} + +static dnsmasqCaps * +buildCaps(void) +{ + g_autoptr(dnsmasqCaps) caps =3D NULL; + g_autoptr(virCommandDryRunToken) dryRunToken =3D virCommandDryRunToken= New(); + + virCommandSetDryRun(dryRunToken, NULL, true, true, buildCapsCallback, = NULL); + + caps =3D dnsmasqCapsNewFromBinary(); + + return g_steal_pointer(&caps); +} + + static int mymain(void) { int ret =3D 0; g_autoptr(dnsmasqCaps) full =3D NULL; =20 - full =3D dnsmasqCapsNewFromBuffer("Dnsmasq version 2.67\n--bind-dynami= c\n--ra-param"); + full =3D buildCaps(); =20 #define DO_TEST(xname, xcaps) \ do { \ --=20 2.34.1 From nobody Sat Apr 20 05:11:28 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=1641977346; cv=none; d=zohomail.com; s=zohoarc; b=XCKiOeUPsyrhIbphgPpp4raqkqgUpMBCUvsO1BOAkKPEGUcavyMJqmhSlieSjGcLV9cbRBbHltD7N1Ti7dY6UJAtisTNHCHRtYkw9oMF6Ohha4rIMrsO9Z3SNcuTS9JVAyI6oaZEWHBA/gF5ieoMUzrhQF7EUSTpbN+cGzGbIfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977346; 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=nfC8ixmmYp3JpOTWReAWqsHMRKfFQ1q95DHtXFz5rnE=; b=GC7JDZ55sCWPKE4vyTsrb4BL/bct/mSQ8Bz/6a3a6vpd2ciOoMk1ORPm1dC0qhwm3LM1s1famhm5iHrXHZnazuDHCrJKOB3xGfEaHE3RKPIuzv+H1+Xqm6RVx57zalY8IBOVpWEM8scsoMOMYEE/i01JFF1kw3k4NYvsCos0B9E= 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 1641977346806375.77229908533536; Wed, 12 Jan 2022 00:49: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-586-yYzhBqY0NaGjySRawLyucQ-1; Wed, 12 Jan 2022 03:49:02 -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 C34A110151E4; Wed, 12 Jan 2022 08:48:57 +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 A2BD310589CF; Wed, 12 Jan 2022 08:48:57 +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 707984A7CD; Wed, 12 Jan 2022 08:48:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8mqYY017657 for ; Wed, 12 Jan 2022 03:48:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id DDE65752A4; Wed, 12 Jan 2022 08:48:52 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6806A60C44 for ; Wed, 12 Jan 2022 08:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977345; 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=nfC8ixmmYp3JpOTWReAWqsHMRKfFQ1q95DHtXFz5rnE=; b=jViVGlc26g7Lv1Ycm9DW7Pjzt7erICdofqsQuy/dxHLiCfPaOBeevgAcMtHkJPEfDj2KVo P35DfGKAgFhHyhwzQ5nNSLGRJeU6QygoVAG1ZDSMGGX+P9Xv6vgSXyjgn0at4HLvXxIZZW 3R8hpRULniJu87EQgdo5I12F3RBLo74= X-MC-Unique: yYzhBqY0NaGjySRawLyucQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 6/7] virdnsmasq: Drop dnsmasqCapsNewFromBuffer() Date: Wed, 12 Jan 2022 09:47:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.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: 1641977347551100001 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 ee14b99d88..aa23e8c0ec 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2114,7 +2114,6 @@ dnsmasqAddDhcpHost; dnsmasqAddHost; dnsmasqCapsGetBinaryPath; dnsmasqCapsNewFromBinary; -dnsmasqCapsNewFromBuffer; dnsmasqContextFree; dnsmasqContextNew; dnsmasqDelete; diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index 6d63e9e3c5..ca52bf7871 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -708,20 +708,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 Sat Apr 20 05:11:28 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=1641977376; cv=none; d=zohomail.com; s=zohoarc; b=HieA2lW8KNCRoBmJFtLRE1bzmRBZnkIBpllHR0JWUgV/zo4FSyIT6Uu4+j3erTCHF5Db6ATtyIOMgf6GKChJDoRNzQ+4wHbGty9rusndNPzX81KA/coSY/zq5xwxELqyvhSMw5RWWPjVAJWml1WPnlCQ337ImTr8idtCu/nqNRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641977376; 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=Un0EqxRR/LXwT4j0Tf+uoojghw+LpRgitYEOwlEY448=; b=TCvEmPC/2FIkRRlJTJsHFxWYrO/GROgy7tMCxygEeecxZTt+Nh5eL4URX+YT0hZot/lNmjow99ESIUsBAgIBqHLXemKyywNF9wTxGmtpmVTvMg3nTfGi43j/lCDpp1DYZUAMNHGbMxhM/ygF9/OnG7fzZ2eQWo2PXEpz/snSoLA= 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 1641977376451479.9692680407537; Wed, 12 Jan 2022 00:49:36 -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-112-k5xoVgCNPBWXHWBWekfEqw-1; Wed, 12 Jan 2022 03:49:34 -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 8AA7918397ED; Wed, 12 Jan 2022 08:49:29 +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 37EBE73160; Wed, 12 Jan 2022 08:49: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 084781806D1C; Wed, 12 Jan 2022 08:49:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20C8nR28018138 for ; Wed, 12 Jan 2022 03:49:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E64F749BD; Wed, 12 Jan 2022 08:49:27 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 088E2752A9 for ; Wed, 12 Jan 2022 08:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641977375; 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=Un0EqxRR/LXwT4j0Tf+uoojghw+LpRgitYEOwlEY448=; b=hKxbiqdTDsVGR8f2vg6wLG09uSKwssn8Oqj45IEdoXRPsRiAcVHSdaNRGT9xUBzmv3Ukdd 3a28z7zKYVWOgnP2M3hdGAUi4Zxa5qpb2lQooMuCrL9FaqiG1Xjy+83EadpYpcG9kVFf3h Fi517g2E8AyYgv03s8QKC06RUbmXN84= X-MC-Unique: k5xoVgCNPBWXHWBWekfEqw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v3 7/7] virdnsmasq: Join dnsmasqCapsNewEmpty() and dnsmasqCapsNewFromBinary() Date: Wed, 12 Jan 2022 09:47:58 +0100 Message-Id: <7c023a6d96f6db37160b6c90aa8ac32cfcc6a6a8.1641976729.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.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: 1641977377291100001 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 ca52bf7871..4108fc262b 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -689,13 +689,14 @@ dnsmasqCapsRefreshInternal(dnsmasqCaps *caps, bool fo= rce) return dnsmasqCapsSetFromBuffer(caps, complete); } =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 @@ -705,17 +706,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, true) < 0) return NULL; =20 --=20 2.34.1