From nobody Thu Apr 25 01:13:43 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=1641993074; cv=none; d=zohomail.com; s=zohoarc; b=ZQJABvWzIdYfJwGsI2If5An29vlp/wAcKOzMGdRU61KHV6iiLtKzP5prBqu1SxD4UAFCTl/snaPubbwRxB4pbDjeEhWshS/8FxYEvXHWwRbxBmGvRhx7WkEYZR7SbhJMxjuswugQLmSH4EDvzQUiNM1dCtauxsAXb8r3x8+Vqyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993074; h=Content-Type:Content-Transfer-Encoding:Cc: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=+MMP5LKJkB7LXzcQCWOAmNjOzwWI9AXUsEtwDe0PzF8=; b=LWTjv+6lXY6yEEbhwMb/tMMblbnaiCrVW5D0n/Aeo0sNn+U8KINLu3reRS2w8gJIDygkOi9RgzXPQAZ20KytuH2ovmSkwPB5IUWiGK3F0K6Dj15RtRSOEpqiH7EMHNSE0CCLb/7/K9A+tA0qi542h2yRpPPreEfuzaJpNDgF28c= 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 1641993074004567.8255088750474; Wed, 12 Jan 2022 05:11:14 -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-605-V0JcL2UaMpqa_soLHpRm6g-1; Wed, 12 Jan 2022 08:11:09 -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 EE14881EE63; Wed, 12 Jan 2022 13:11:03 +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 CDAFC7D475; Wed, 12 Jan 2022 13:11: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 8ECDB1809CB9; Wed, 12 Jan 2022 13:11:03 +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 20CDB22G004262 for ; Wed, 12 Jan 2022 08:11:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id C4F042634C; Wed, 12 Jan 2022 13:11:02 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07AF92634A; Wed, 12 Jan 2022 13:10:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993073; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=+MMP5LKJkB7LXzcQCWOAmNjOzwWI9AXUsEtwDe0PzF8=; b=fRAiyViUYL6mHYXbWVif3YPY0G/SPi3zM3G6w/kDF3axC0CLy18enYXr5RwsifumHZJbaL Lw2+46LwvsbJVx0CSmgKazK1eMFjN6302Hb9BWFyKdkbppDcWlq7h91lkTPEYwuaM88wUk F0sLKMldajOyQv4xfKq3UESxvF6Ou+4= X-MC-Unique: V0JcL2UaMpqa_soLHpRm6g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 01/14] docs: coding-style: Clarify on virXXXPtr types Date: Wed, 12 Jan 2022 14:10:02 +0100 Message-Id: <20220112131015.100288-2-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993074582100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- docs/coding-style.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/coding-style.rst b/docs/coding-style.rst index 470c61860f..ab7634dc14 100644 --- a/docs/coding-style.rst +++ b/docs/coding-style.rst @@ -54,6 +54,7 @@ Struct type names and each following word should have its first letter in uppercase. The struct name should be the same as the typedef name with a leading underscore. + :: =20 typedef struct _virHashTable virHashTable; @@ -61,6 +62,10 @@ Struct type names ... }; =20 + Historically, libvirt also declared pointer types 'virXXXPtr', + which have been dropped where possible. Do not introduce new + such types. + Function names All functions should have a 'vir' prefix in their name, followed by one or more words with first letter of each word --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993084; cv=none; d=zohomail.com; s=zohoarc; b=h7ByGV2STbnDy6VkC6APp34kbutZ5+jCQE9yVUuUyGpgdJ+gJBzCl+0pxSO9xlOSUZT/ZxLUluL+JJ8dQRUfcUfzu3FKmd+Qxait7JdcNlEogj43FsuIOWCRNP5+oh+DABLNFkpDJWDocTTLincVcIinV4y1SNSueWrPmYmCtek= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993084; h=Content-Type:Content-Transfer-Encoding:Cc: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=rSUuupmC2GRPA4awnNOdU2jWVHDcKPcC9aeMabI0LTg=; b=l4TMdoOdJT9q0rTx5+ctoz8SVtKDJd3A3g24uZpLaLP/0nMhhtS9JZSudQwpK5qA0PIOLhXuYWXtd0hunosdu8fDwTfbgS94pMzS52FqoV5DeUmii5qpKGOT/860DAFDetBhXvsVya/zksM2834w4yLYVzQ07r8tGkPwgSmXn7A= 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 1641993084515474.8915013359109; Wed, 12 Jan 2022 05:11:24 -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-63-gO0QXRrNN_Gm-E-VMxNOCQ-1; Wed, 12 Jan 2022 08:11:19 -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 F0B7281EE62; Wed, 12 Jan 2022 13:11:13 +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 CD2EF84D05; Wed, 12 Jan 2022 13:11:13 +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 99A571809CB9; Wed, 12 Jan 2022 13:11:13 +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 20CDB4vf004272 for ; Wed, 12 Jan 2022 08:11:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id F39732634C; Wed, 12 Jan 2022 13:11:03 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 357AA2634A; Wed, 12 Jan 2022 13:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993083; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=rSUuupmC2GRPA4awnNOdU2jWVHDcKPcC9aeMabI0LTg=; b=LprHIlk8cV3mYSqySDWsgmLaLwp8FyRLzWdth2fmi0X/dCj44StuCc/cONmrohmx1KutPr WcSmjz2GSQ98ho44h1xpzGQhYPVFKeglPTwyEJZkij+LdR6oBpx/kOU8eASpBCpfLPTJ7F CNx5v045F3rVWJ0uII02CRYyMwMRAdw= X-MC-Unique: gO0QXRrNN_Gm-E-VMxNOCQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 02/14] virQEMUCapsSEVInfoCopy: Remove superfluous g_auto usage Date: Wed, 12 Jan 2022 14:10:03 +0100 Message-Id: <20220112131015.100288-3-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993085020100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/qemu/qemu_capabilities.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5f1eb5014c..f8db6fd370 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1891,7 +1891,7 @@ static int virQEMUCapsSEVInfoCopy(virSEVCapability **dst, virSEVCapability *src) { - g_autoptr(virSEVCapability) tmp =3D NULL; + virSEVCapability *tmp; =20 if (!src) { *dst =3D NULL; @@ -1908,7 +1908,7 @@ virQEMUCapsSEVInfoCopy(virSEVCapability **dst, tmp->max_guests =3D src->max_guests; tmp->max_es_guests =3D src->max_es_guests; =20 - *dst =3D g_steal_pointer(&tmp); + *dst =3D tmp; return 0; } =20 --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993087; cv=none; d=zohomail.com; s=zohoarc; b=Ezpdn3mgLm6iNohsHeqS0tZ9p8NyhASPIcsj+QmUU+sfwmU2M4WVs5Qi9N9R8eIm/Uazt1k/8ryXETFne0TK3QOV+PQLjmwD0T6PyvG9FEymhX4UwseqBLy/isENY96jAtHV6Q7yaH0NZiSSwqfY2ZnFLw459NjF8nhqg0PmjmM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993087; h=Content-Type:Content-Transfer-Encoding:Cc: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=0kB5xOKG5bLw/tpU0UZ9FtpbP+bgymWn6tcjEH7io4E=; b=Nq29dnms+YK/uEAK01b+ysmS88Ghukzgmksx9UlQqzvtj2TEEN0NNqtlQ30OCreHQNwjEiILWW2tUPY5DkwfNzYbtJ3karNJIAx2f/V3TsS3MufAaZvRSGournDjcXsdbwpvv1O7smuIJ7b3UXSkcixrtvABfxWFZvH2S94pL4w= 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 1641993087472302.3889845782909; Wed, 12 Jan 2022 05:11:27 -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-441-7Jw-w0lBNiG7HJkARnDgvQ-1; Wed, 12 Jan 2022 08:11:22 -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 42A64100C661; Wed, 12 Jan 2022 13:11: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 211887E913; Wed, 12 Jan 2022 13:11: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 B2E944A7C8; Wed, 12 Jan 2022 13:11:16 +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 20CDB5a2004277 for ; Wed, 12 Jan 2022 08:11:05 -0500 Received: by smtp.corp.redhat.com (Postfix) id 435532634A; Wed, 12 Jan 2022 13:11:05 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5962526364; Wed, 12 Jan 2022 13:11:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993086; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=0kB5xOKG5bLw/tpU0UZ9FtpbP+bgymWn6tcjEH7io4E=; b=NAJ8614mp04HCMDl2ulyZ0rtvZBmEtaQhhrnFtFQNoeSgUTCWGDdRnOo4L05NHPH4Gwd2W Ji9+9GqhRR1R12iCo0hWN9LtU3fsysIFFvSorYQeVo0Nn0WXxKI+I9+V3H+0tkttdXUxA5 TkW6U45c0xPg1WLj+ipZXRKn1BcbEvg= X-MC-Unique: 7Jw-w0lBNiG7HJkARnDgvQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 03/14] virInterfaceDefDevFormat: Add missing error handling Date: Wed, 12 Jan 2022 14:10:04 +0100 Message-Id: <20220112131015.100288-4-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993087867100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index f2b3804bec..150616bda9 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -1089,13 +1089,16 @@ virInterfaceDefDevFormat(virBuffer *buf, virBufferAsprintf(buf, "\n", def->mac= ); break; case VIR_INTERFACE_TYPE_BRIDGE: - virInterfaceBridgeDefFormat(buf, def); + if (virInterfaceBridgeDefFormat(buf, def) < 0) + return -1; break; case VIR_INTERFACE_TYPE_BOND: - virInterfaceBondDefFormat(buf, def); + if (virInterfaceBondDefFormat(buf, def) < 0) + return -1; break; case VIR_INTERFACE_TYPE_VLAN: - virInterfaceVlanDefFormat(buf, def); + if (virInterfaceVlanDefFormat(buf, def) < 0) + return -1; break; } =20 --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993104; cv=none; d=zohomail.com; s=zohoarc; b=fGOD63R8htakhW2epxta2fmHMx8U05ivO5Xr3rdfg7mnPDYnJ16zxiNOpdsgam4qQmGlB/FylQSKUg5LhqHL55zNEq3zAou1RKL1VoYZsMHZC1TTDb0FRDo2fvzkaYcmA+ZOYzRwTO9rfhejwc5xzN2jAFWjH6TmyQHmmXFCUN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993104; h=Content-Type:Content-Transfer-Encoding:Cc: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=44Q9jWDVYuuJIFOCgrt5BE2QrRvZRtC1X1Xe/vwOabI=; b=IBqi5yljoS2p4QQip/jPb2wwI3Rqi/FCeP4M2kbeupr6eylc8fpmw5tH0DOwsqSQ7JojvOjqmHTDEdQbEtZ0xww248FZysUG98xRr6wwPvqup+iGREHXGOG/Nqfno+OVn7gydaHC1ZBTAXO077luX0iEm3Ifg47CMDRpYAgt1R8= 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 1641993104796859.6095271398732; Wed, 12 Jan 2022 05:11:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-DkZYUXxiMlqzOhX3WygF5Q-1; Wed, 12 Jan 2022 08:11:40 -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 BBE81192FDA7; Wed, 12 Jan 2022 13:11:35 +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 97DFC56F90; Wed, 12 Jan 2022 13:11:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6711A4A7CA; Wed, 12 Jan 2022 13:11:35 +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 20CDB6r3004282 for ; Wed, 12 Jan 2022 08:11:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 61CAF26358; Wed, 12 Jan 2022 13:11:06 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FAA82634A; Wed, 12 Jan 2022 13:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993103; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=44Q9jWDVYuuJIFOCgrt5BE2QrRvZRtC1X1Xe/vwOabI=; b=Ezqtqdcrix9NJH3asryDa2961YPnsurqcK8ziDXrVAgMLYlMaZl8i0cWKpah2+5KiKn/DJ AvNFiDpnhEvqkK598hP9Bme7TMUlivJpCC+YQgaDlBoVLQMO7Ma/qhMHtJL7Sg7/IQx4yL nKFMYqKKLG7ET/N9QcXBG0k52hMqFQk= X-MC-Unique: DkZYUXxiMlqzOhX3WygF5Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 04/14] conf: interface: Preparation for g_auto Date: Wed, 12 Jan 2022 14:10:05 +0100 Message-Id: <20220112131015.100288-5-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993105570100001 Content-Type: text/plain; charset="utf-8" These changes make the g_auto-ification in the next commit clearer. Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 150616bda9..cbe6aad957 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -453,14 +453,12 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, } proto->family =3D tmp; if (STREQ(tmp, "ipv4")) { - ret =3D virInterfaceDefParseProtoIPv4(proto, ctxt); - if (ret !=3D 0) { + if (virInterfaceDefParseProtoIPv4(proto, ctxt) !=3D 0) { virInterfaceProtocolDefFree(proto); goto error; } } else if (STREQ(tmp, "ipv6")) { - ret =3D virInterfaceDefParseProtoIPv6(proto, ctxt); - if (ret !=3D 0) { + if (virInterfaceDefParseProtoIPv6(proto, ctxt) !=3D 0) { virInterfaceProtocolDefFree(proto); goto error; } @@ -741,10 +739,12 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, } =20 switch (type) { - case VIR_INTERFACE_TYPE_ETHERNET: - if ((tmp =3D virXPathString("string(./mac/@address)", ctxt))) - def->mac =3D tmp; + case VIR_INTERFACE_TYPE_ETHERNET: { + char *mac =3D virXPathString("string(./mac/@address)", ctxt); + if (mac !=3D NULL) + def->mac =3D mac; break; + } case VIR_INTERFACE_TYPE_BRIDGE: { xmlNodePtr bridge; =20 --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993123; cv=none; d=zohomail.com; s=zohoarc; b=TGUeQE6/FNOf5QzPKRHyfHRnpgOFJUMgpPrku4MTEJBkIymx3utUNxCT5yrgA/YP6C/yARed5DKyUncNdgQcpX14i9TOMXCgl5UJy4fR8ZvvbV5ZyTPm4kDpX64auNToFGAhEadj55faK31LK24kpf4ct5I4VQGogr2P2NlYEMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993123; h=Content-Type:Content-Transfer-Encoding:Cc: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=ODkNhxk3ZuagfxwmiIkYDFffwrZo2cB6h0UbcJQRWAQ=; b=XPqL1HSHdpiB+DBQxpcRGMPCFA1Jk4fg0wNPOEEFz419HWJ9JjdYKFjnsIXjZXf6IOPVuAv0sMvpx6x2OCVfyofrBuZzdP2rAa+EBGIFGG1FtnQgqq0/xHa+a+xaE92MhMPFEt9QWcyFECZUzhchCFzHTwsYBRwEC4vwHHmvqeY= 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 1641993123294783.3301278600501; Wed, 12 Jan 2022 05:12: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-636-J_T0YTwTP7-f3fKZ9MmQBg-1; Wed, 12 Jan 2022 08:11:26 -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 7327F427CA; Wed, 12 Jan 2022 13:11:20 +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 1B42A84FF6; Wed, 12 Jan 2022 13:11:20 +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 D1E271809CBF; Wed, 12 Jan 2022 13:11:19 +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 20CDB7J8004298 for ; Wed, 12 Jan 2022 08:11:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 84F7B2634C; Wed, 12 Jan 2022 13:11:07 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id C77412634A; Wed, 12 Jan 2022 13:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993122; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=ODkNhxk3ZuagfxwmiIkYDFffwrZo2cB6h0UbcJQRWAQ=; b=Vr9R0KCAMpI1foVLF4vboTPrj0WAHsd0Cg56h4hoT7KRf7r+hC3mAK/SgtbJgQF99uMNfw jw6Bci0tKDCzCMqOviTLlQtHdOkBkEk5s/Tt/cC8tTTs3iN4caPe0MzOE5oEjORlAuUsGu +BA6emY/P/EPiJhngiKrFJuZeH4lkmQ= X-MC-Unique: J_T0YTwTP7-f3fKZ9MmQBg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 05/14] conf: interface: Use g_auto Date: Wed, 12 Jan 2022 14:10:06 +0100 Message-Id: <20220112131015.100288-6-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993124660100006 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 67 ++++++++++++--------------------------- 1 file changed, 20 insertions(+), 47 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index cbe6aad957..4b464bdf4f 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -68,6 +68,7 @@ virInterfaceProtocolDefFree(virInterfaceProtocolDef *def) g_free(def->gateway); g_free(def); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virInterfaceProtocolDef, virInterfaceProtoco= lDefFree); =20 =20 void @@ -155,9 +156,8 @@ static int virInterfaceDefParseStartMode(virInterfaceDef *def, xmlXPathContextPtr ctxt) { - char *tmp; + g_autofree char *tmp =3D virXPathString("string(./start/@mode)", ctxt); =20 - tmp =3D virXPathString("string(./start/@mode)", ctxt); if (tmp =3D=3D NULL) { def->startmode =3D VIR_INTERFACE_START_UNSPECIFIED; } else if (STREQ(tmp, "onboot")) { @@ -169,10 +169,8 @@ virInterfaceDefParseStartMode(virInterfaceDef *def, } else { virReportError(VIR_ERR_XML_ERROR, _("unknown interface startmode %s"), tmp); - VIR_FREE(tmp); return -1; } - VIR_FREE(tmp); return 0; } =20 @@ -180,10 +178,9 @@ virInterfaceDefParseStartMode(virInterfaceDef *def, static int virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) { - char *tmp; + g_autofree char *tmp =3D virXPathString("string(./@mode)", ctxt); int ret =3D 0; =20 - tmp =3D virXPathString("string(./@mode)", ctxt); if (tmp =3D=3D NULL) return VIR_INTERFACE_BOND_NONE; if (STREQ(tmp, "balance-rr")) { @@ -205,7 +202,6 @@ virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) _("unknown bonding mode %s"), tmp); ret =3D -1; } - VIR_FREE(tmp); return ret; } =20 @@ -213,10 +209,9 @@ virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) static int virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) { - char *tmp; + g_autofree char *tmp =3D virXPathString("string(./miimon/@carrier)", c= txt); int ret =3D 0; =20 - tmp =3D virXPathString("string(./miimon/@carrier)", ctxt); if (tmp =3D=3D NULL) return VIR_INTERFACE_BOND_MII_NONE; if (STREQ(tmp, "ioctl")) { @@ -228,7 +223,6 @@ virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr c= txt) _("unknown mii bonding carrier %s"), tmp); ret =3D -1; } - VIR_FREE(tmp); return ret; } =20 @@ -236,10 +230,9 @@ virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr = ctxt) static int virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) { - char *tmp; + g_autofree char *tmp =3D virXPathString("string(./arpmon/@validate)", = ctxt); int ret =3D 0; =20 - tmp =3D virXPathString("string(./arpmon/@validate)", ctxt); if (tmp =3D=3D NULL) return VIR_INTERFACE_BOND_ARP_NONE; if (STREQ(tmp, "active")) { @@ -253,7 +246,6 @@ virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctx= t) _("unknown arp bonding validate %s"), tmp); ret =3D -1; } - VIR_FREE(tmp); return ret; } =20 @@ -263,7 +255,7 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDef *def, xmlNodePtr dhcp, xmlXPathContextPtr ctxt) { VIR_XPATH_NODE_AUTORESTORE(ctxt) - char *tmp; + g_autofree char *tmp =3D NULL; int ret =3D 0; =20 def->dhcp =3D 1; @@ -280,7 +272,6 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDef *def, } else { def->peerdns =3D state ? 1 : 0; } - VIR_FREE(tmp); } =20 return ret; @@ -317,7 +308,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef *= def, xmlXPathContextPtr ctxt) { xmlNodePtr dhcp; - xmlNodePtr *ipNodes =3D NULL; + g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes, ret =3D -1; size_t i; char *tmp; @@ -357,7 +348,6 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef *= def, ret =3D 0; =20 error: - VIR_FREE(ipNodes); return ret; } =20 @@ -367,7 +357,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *= def, xmlXPathContextPtr ctxt) { xmlNodePtr dhcp, autoconf; - xmlNodePtr *ipNodes =3D NULL; + g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes, ret =3D -1; size_t i; char *tmp; @@ -411,7 +401,6 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *= def, ret =3D 0; =20 error: - VIR_FREE(ipNodes); return ret; } =20 @@ -421,7 +410,7 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, xmlXPathContextPtr ctxt) { VIR_XPATH_NODE_AUTORESTORE(ctxt) - xmlNodePtr *protoNodes =3D NULL; + g_autofree xmlNodePtr *protoNodes =3D NULL; int nProtoNodes, pp, ret =3D -1; char *tmp; =20 @@ -439,42 +428,33 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, def->nprotos =3D 0; for (pp =3D 0; pp < nProtoNodes; pp++) { =20 - virInterfaceProtocolDef *proto; - - proto =3D g_new0(virInterfaceProtocolDef, 1); + g_autoptr(virInterfaceProtocolDef) proto =3D g_new0(virInterfacePr= otocolDef, 1); =20 ctxt->node =3D protoNodes[pp]; tmp =3D virXPathString("string(./@family)", ctxt); if (tmp =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("protocol misses the family attribute")= ); - virInterfaceProtocolDefFree(proto); goto error; } proto->family =3D tmp; if (STREQ(tmp, "ipv4")) { - if (virInterfaceDefParseProtoIPv4(proto, ctxt) !=3D 0) { - virInterfaceProtocolDefFree(proto); + if (virInterfaceDefParseProtoIPv4(proto, ctxt) !=3D 0) goto error; - } } else if (STREQ(tmp, "ipv6")) { - if (virInterfaceDefParseProtoIPv6(proto, ctxt) !=3D 0) { - virInterfaceProtocolDefFree(proto); + if (virInterfaceDefParseProtoIPv6(proto, ctxt) !=3D 0) goto error; - } } else { virReportError(VIR_ERR_XML_ERROR, _("unsupported protocol family '%s'"), tmp); - virInterfaceProtocolDefFree(proto); goto error; } - def->protos[def->nprotos++] =3D proto; + def->protos[def->nprotos++] =3D g_steal_pointer(&proto); } =20 ret =3D 0; =20 error: - VIR_FREE(protoNodes); return ret; =20 } @@ -484,17 +464,16 @@ static int virInterfaceDefParseBridge(virInterfaceDef *def, xmlXPathContextPtr ctxt) { - xmlNodePtr *interfaces =3D NULL; - xmlNodePtr bridge; + VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree xmlNodePtr *interfaces =3D NULL; virInterfaceDef *itf; - char *tmp =3D NULL; + g_autofree char *tmp =3D NULL; int nbItf; size_t i; int ret =3D 0; =20 - bridge =3D ctxt->node; def->data.bridge.stp =3D -1; - if ((tmp =3D virXMLPropString(bridge, "stp"))) { + if ((tmp =3D virXMLPropString(ctxt->node, "stp"))) { if (STREQ(tmp, "on")) { def->data.bridge.stp =3D 1; } else if (STREQ(tmp, "off")) { @@ -506,7 +485,7 @@ virInterfaceDefParseBridge(virInterfaceDef *def, goto error; } } - def->data.bridge.delay =3D virXMLPropString(bridge, "delay"); + def->data.bridge.delay =3D virXMLPropString(ctxt->node, "delay"); =20 nbItf =3D virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf < 0) { @@ -530,9 +509,6 @@ virInterfaceDefParseBridge(virInterfaceDef *def, } =20 error: - VIR_FREE(tmp); - VIR_FREE(interfaces); - ctxt->node =3D bridge; return ret; } =20 @@ -541,8 +517,8 @@ static int virInterfaceDefParseBondItfs(virInterfaceDef *def, xmlXPathContextPtr ctxt) { - xmlNodePtr *interfaces =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autofree xmlNodePtr *interfaces =3D NULL; virInterfaceDef *itf; int nbItf; size_t i; @@ -573,7 +549,6 @@ virInterfaceDefParseBondItfs(virInterfaceDef *def, =20 ret =3D 0; cleanup: - VIR_FREE(interfaces); return ret; } =20 @@ -679,7 +654,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, { g_autoptr(virInterfaceDef) def =3D NULL; int type; - char *tmp; + g_autofree char *tmp =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr lnk; =20 @@ -695,10 +670,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, if (type =3D=3D -1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown interface type %s"), tmp); - VIR_FREE(tmp); return NULL; } - VIR_FREE(tmp); =20 def =3D g_new0(virInterfaceDef, 1); =20 --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993125; cv=none; d=zohomail.com; s=zohoarc; b=WeQGMo0IjfJF5xvQ8qOeKyGhfxuXOyvzWOHrj1D0GLAi4FNYxNFlDLmIEQP4sCFGDwqZE7E9xJd32+SnY/qFnEn06IH4IH/FdkgyZPX2VT2T3gEKAq+JCbEzvc1waaanS8sZOFiH3ptZf1GCKCEM/nAxusm54SUbWscGSRcRLA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993125; h=Content-Type:Content-Transfer-Encoding:Cc: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=kVsQaYuFrrT843ILLNWRycUeZ/gX0no8PpbVuBrGjqI=; b=OUYvVMzjwsCvlkrJ8jG3jnVJo/TTxzdU4Dbgj9AbQUuu3p4nl9wsX/ShOACScQHBxDXmzVq6VacTDCuaVxReOETOtONzNgp1GMIAzGo1ULK0qLevp2p9MMzmqe3TeQ35SkLUaXWT2fElhT+Lj9reXBeqMin+cBiusO8UFBHlTuI= 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 1641993125564979.5675809540938; Wed, 12 Jan 2022 05:12:05 -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-441-2lt0ACatOg-0baWf7voTDQ-1; Wed, 12 Jan 2022 08:11:23 -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 9196E81EE63; Wed, 12 Jan 2022 13:11:17 +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 6B80E84D05; Wed, 12 Jan 2022 13:11: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 3BDF41809CB9; Wed, 12 Jan 2022 13:11:17 +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 20CDBEnN004317 for ; Wed, 12 Jan 2022 08:11:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8C0FC2634C; Wed, 12 Jan 2022 13:11:14 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFBE326DC6; Wed, 12 Jan 2022 13:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993124; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=kVsQaYuFrrT843ILLNWRycUeZ/gX0no8PpbVuBrGjqI=; b=U0TlNFzY2AjgnADxZiyGaO0cMc11CUfHEXc7vpFQ+1QEJl2C8Qqcvcw0v9SafrIB0xvJjt T2659hYxv+JSvXfCZ9JRNFtJ54Oi8PLFp+xeBzkP3AYgPjyYyBWG+uhGByqpBnHHhmAfx8 eczs9zohzaSGj9jeDMwn2jARw6kld5Y= X-MC-Unique: 2lt0ACatOg-0baWf7voTDQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 06/14] conf: interface: Remove ret and goto Date: Wed, 12 Jan 2022 14:10:07 +0100 Message-Id: <20220112131015.100288-7-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993127112100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 129 +++++++++++++++----------------------- 1 file changed, 49 insertions(+), 80 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 4b464bdf4f..47f9da797d 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -179,30 +179,27 @@ static int virInterfaceDefParseBondMode(xmlXPathContextPtr ctxt) { g_autofree char *tmp =3D virXPathString("string(./@mode)", ctxt); - int ret =3D 0; =20 if (tmp =3D=3D NULL) return VIR_INTERFACE_BOND_NONE; if (STREQ(tmp, "balance-rr")) { - ret =3D VIR_INTERFACE_BOND_BALRR; + return VIR_INTERFACE_BOND_BALRR; } else if (STREQ(tmp, "active-backup")) { - ret =3D VIR_INTERFACE_BOND_ABACKUP; + return VIR_INTERFACE_BOND_ABACKUP; } else if (STREQ(tmp, "balance-xor")) { - ret =3D VIR_INTERFACE_BOND_BALXOR; + return VIR_INTERFACE_BOND_BALXOR; } else if (STREQ(tmp, "broadcast")) { - ret =3D VIR_INTERFACE_BOND_BCAST; + return VIR_INTERFACE_BOND_BCAST; } else if (STREQ(tmp, "802.3ad")) { - ret =3D VIR_INTERFACE_BOND_8023AD; + return VIR_INTERFACE_BOND_8023AD; } else if (STREQ(tmp, "balance-tlb")) { - ret =3D VIR_INTERFACE_BOND_BALTLB; + return VIR_INTERFACE_BOND_BALTLB; } else if (STREQ(tmp, "balance-alb")) { - ret =3D VIR_INTERFACE_BOND_BALALB; - } else { - virReportError(VIR_ERR_XML_ERROR, - _("unknown bonding mode %s"), tmp); - ret =3D -1; + return VIR_INTERFACE_BOND_BALALB; } - return ret; + + virReportError(VIR_ERR_XML_ERROR, _("unknown bonding mode %s"), tmp); + return -1; } =20 =20 @@ -210,20 +207,17 @@ static int virInterfaceDefParseBondMiiCarrier(xmlXPathContextPtr ctxt) { g_autofree char *tmp =3D virXPathString("string(./miimon/@carrier)", c= txt); - int ret =3D 0; =20 if (tmp =3D=3D NULL) return VIR_INTERFACE_BOND_MII_NONE; if (STREQ(tmp, "ioctl")) { - ret =3D VIR_INTERFACE_BOND_MII_IOCTL; + return VIR_INTERFACE_BOND_MII_IOCTL; } else if (STREQ(tmp, "netif")) { - ret =3D VIR_INTERFACE_BOND_MII_NETIF; - } else { - virReportError(VIR_ERR_XML_ERROR, - _("unknown mii bonding carrier %s"), tmp); - ret =3D -1; + return VIR_INTERFACE_BOND_MII_NETIF; } - return ret; + + virReportError(VIR_ERR_XML_ERROR, _("unknown mii bonding carrier %s"),= tmp); + return -1; } =20 =20 @@ -231,22 +225,19 @@ static int virInterfaceDefParseBondArpValid(xmlXPathContextPtr ctxt) { g_autofree char *tmp =3D virXPathString("string(./arpmon/@validate)", = ctxt); - int ret =3D 0; =20 if (tmp =3D=3D NULL) return VIR_INTERFACE_BOND_ARP_NONE; if (STREQ(tmp, "active")) { - ret =3D VIR_INTERFACE_BOND_ARP_ACTIVE; + return VIR_INTERFACE_BOND_ARP_ACTIVE; } else if (STREQ(tmp, "backup")) { - ret =3D VIR_INTERFACE_BOND_ARP_BACKUP; + return VIR_INTERFACE_BOND_ARP_BACKUP; } else if (STREQ(tmp, "all")) { - ret =3D VIR_INTERFACE_BOND_ARP_ALL; - } else { - virReportError(VIR_ERR_XML_ERROR, - _("unknown arp bonding validate %s"), tmp); - ret =3D -1; + return VIR_INTERFACE_BOND_ARP_ALL; } - return ret; + + virReportError(VIR_ERR_XML_ERROR, _("unknown arp bonding validate %s")= , tmp); + return -1; } =20 =20 @@ -256,7 +247,6 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDef *def, { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *tmp =3D NULL; - int ret =3D 0; =20 def->dhcp =3D 1; ctxt->node =3D dhcp; @@ -268,13 +258,12 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDef *def, if (virStringParseYesNo(tmp, &state) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown dhcp peerdns value %s"), tmp); - ret =3D -1; - } else { - def->peerdns =3D state ? 1 : 0; + return -1; } + def->peerdns =3D state ? 1 : 0; } =20 - return ret; + return 0; } =20 =20 @@ -309,7 +298,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef *= def, { xmlNodePtr dhcp; g_autofree xmlNodePtr *ipNodes =3D NULL; - int nipNodes, ret =3D -1; + int nipNodes; size_t i; char *tmp; =20 @@ -340,15 +329,12 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef= *def, ctxt->node =3D ipNodes[i]; if (virInterfaceDefParseIP(ip, ctxt) < 0) { virInterfaceIPDefFree(ip); - goto error; + return -1; } def->ips[def->nips++] =3D ip; } =20 - ret =3D 0; - - error: - return ret; + return 0; } =20 =20 @@ -358,7 +344,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *= def, { xmlNodePtr dhcp, autoconf; g_autofree xmlNodePtr *ipNodes =3D NULL; - int nipNodes, ret =3D -1; + int nipNodes; size_t i; char *tmp; =20 @@ -393,15 +379,12 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef= *def, ctxt->node =3D ipNodes[i]; if (virInterfaceDefParseIP(ip, ctxt) < 0) { virInterfaceIPDefFree(ip); - goto error; + return -1; } def->ips[def->nips++] =3D ip; } =20 - ret =3D 0; - - error: - return ret; + return 0; } =20 =20 @@ -411,12 +394,12 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, { VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree xmlNodePtr *protoNodes =3D NULL; - int nProtoNodes, pp, ret =3D -1; + int nProtoNodes, pp; char *tmp; =20 nProtoNodes =3D virXPathNodeSet("./protocol", ctxt, &protoNodes); if (nProtoNodes < 0) - goto error; + return -1; =20 if (nProtoNodes =3D=3D 0) { /* no protocols is an acceptable outcome */ @@ -435,28 +418,24 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, if (tmp =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("protocol misses the family attribute")= ); - goto error; + return -1; } proto->family =3D tmp; if (STREQ(tmp, "ipv4")) { if (virInterfaceDefParseProtoIPv4(proto, ctxt) !=3D 0) - goto error; + return -1; } else if (STREQ(tmp, "ipv6")) { if (virInterfaceDefParseProtoIPv6(proto, ctxt) !=3D 0) - goto error; + return -1; } else { virReportError(VIR_ERR_XML_ERROR, _("unsupported protocol family '%s'"), tmp); - goto error; + return -1; } def->protos[def->nprotos++] =3D g_steal_pointer(&proto); } =20 - ret =3D 0; - - error: - return ret; - + return 0; } =20 =20 @@ -470,7 +449,6 @@ virInterfaceDefParseBridge(virInterfaceDef *def, g_autofree char *tmp =3D NULL; int nbItf; size_t i; - int ret =3D 0; =20 def->data.bridge.stp =3D -1; if ((tmp =3D virXMLPropString(ctxt->node, "stp"))) { @@ -482,15 +460,14 @@ virInterfaceDefParseBridge(virInterfaceDef *def, virReportError(VIR_ERR_XML_ERROR, _("bridge interface stp should be on or off got= %s"), tmp); - goto error; + return 0; } } def->data.bridge.delay =3D virXMLPropString(ctxt->node, "delay"); =20 nbItf =3D virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf < 0) { - ret =3D -1; - goto error; + return -1; } if (nbItf > 0) { def->data.bridge.itf =3D g_new0(struct _virInterfaceDef *, nbItf); @@ -500,16 +477,14 @@ virInterfaceDefParseBridge(virInterfaceDef *def, ctxt->node =3D interfaces[i]; itf =3D virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BRIDG= E); if (itf =3D=3D NULL) { - ret =3D -1; def->data.bridge.nbItf =3D i; - goto error; + return -1; } def->data.bridge.itf[i] =3D itf; } } =20 - error: - return ret; + return 0; } =20 =20 @@ -522,15 +497,13 @@ virInterfaceDefParseBondItfs(virInterfaceDef *def, virInterfaceDef *itf; int nbItf; size_t i; - int ret =3D -1; =20 nbItf =3D virXPathNodeSet("./interface", ctxt, &interfaces); if (nbItf < 0) - goto cleanup; + return -1; =20 if (nbItf =3D=3D 0) { - ret =3D 0; - goto cleanup; + return 0; } =20 def->data.bond.itf =3D g_new0(struct _virInterfaceDef *, nbItf); @@ -542,14 +515,12 @@ virInterfaceDefParseBondItfs(virInterfaceDef *def, itf =3D virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_BOND); if (itf =3D=3D NULL) { def->data.bond.nbItf =3D i; - goto cleanup; + return -1; } def->data.bond.itf[i] =3D itf; } =20 - ret =3D 0; - cleanup: - return ret; + return 0; } =20 =20 @@ -823,7 +794,6 @@ virInterfaceBridgeDefFormat(virBuffer *buf, const virInterfaceDef *def) { size_t i; - int ret =3D 0; =20 virBufferAddLit(buf, "data.bridge.stp =3D=3D 1) @@ -838,12 +808,12 @@ virInterfaceBridgeDefFormat(virBuffer *buf, for (i =3D 0; i < def->data.bridge.nbItf; i++) { if (virInterfaceDefDevFormat(buf, def->data.bridge.itf[i], VIR_INTERFACE_TYPE_BRIDGE) < 0) - ret =3D -1; + return -1; } =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); - return ret; + return 0; } =20 =20 @@ -852,7 +822,6 @@ virInterfaceBondDefFormat(virBuffer *buf, const virInterfaceDef *def) { size_t i; - int ret =3D 0; =20 virBufferAddLit(buf, "data.bond.mode =3D=3D VIR_INTERFACE_BOND_BALRR) @@ -903,12 +872,12 @@ virInterfaceBondDefFormat(virBuffer *buf, for (i =3D 0; i < def->data.bond.nbItf; i++) { if (virInterfaceDefDevFormat(buf, def->data.bond.itf[i], VIR_INTERFACE_TYPE_BOND) < 0) - ret =3D -1; + return -1; } =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); - return ret; + return 0; } =20 =20 --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993123; cv=none; d=zohomail.com; s=zohoarc; b=eRzhZyKdMT8SGGTm7ZkpquodqpEk43rZ6GnmUkwVbU0Tc3Ouv2MLadzSrE0DKx+DjIPP4IhOXtgzeSCVzTaoJcDzl7LxWZmc1eSTwfhvIEkiSZc85pnVcqJ/T2VFV7ZQgROEqf7/gBy/PLUEcZ997UAC215DWr5SiqdwMLWc6U8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993123; h=Content-Type:Content-Transfer-Encoding:Cc: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=jD5vmJUiz1PvGl5aX/0U/4LvdeRTzLHx0EvQAnSQ54A=; b=dqjLeLZOWzd0tA6OPV6dlNiDucNA0T1+WKoKfukCUGXWU1O3F/N7m/Q+E1hvMllbEIkRTx/zabI3asoHHGszDKOc3nqPLYlGgWWVakjtfMRE6JucuxwZOOvO06ONahirI+E0+27MC8vVD3bL8W1pCW+C5Rn4hA/LreyyNx1V7/A= 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 1641993123062247.9547935413351; Wed, 12 Jan 2022 05:12: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-636-X68tWZhyPKadvX4wAwH2dA-1; Wed, 12 Jan 2022 08:11:26 -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 92BA6100D847; Wed, 12 Jan 2022 13:11:20 +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 4EEF1753C3; Wed, 12 Jan 2022 13:11:20 +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 0F1B918077BC; Wed, 12 Jan 2022 13:11:20 +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 20CDBFGd004329 for ; Wed, 12 Jan 2022 08:11:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id A596E26358; Wed, 12 Jan 2022 13:11:15 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6B4A2634A; Wed, 12 Jan 2022 13:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993122; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=jD5vmJUiz1PvGl5aX/0U/4LvdeRTzLHx0EvQAnSQ54A=; b=ANzS9lgek/DSxI3IkmLDpfYFGAItOYS6fKRM2EhSOTt12oiMA+GzyqAidKLRX20dYQnMTr MgMzh1HzCmRBwZyRJjJnzqLbT12tzUawQZIR248jc4mYlnwUOoPvz6AdGWiYYy8riMWBtB 2os97ox1vVHCL+wBFxNeg+ZBu28bzH0= X-MC-Unique: X68tWZhyPKadvX4wAwH2dA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/14] virInterfaceDefParseXML: Inline trivial virInterfaceDefParseName Date: Wed, 12 Jan 2022 14:10:08 +0100 Message-Id: <20220112131015.100288-8-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993124609100004 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 47f9da797d..f3fc47bd69 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -116,23 +116,6 @@ virInterfaceDefFree(virInterfaceDef *def) } =20 =20 -static int -virInterfaceDefParseName(virInterfaceDef *def, - xmlXPathContextPtr ctxt) -{ - char *tmp; - - tmp =3D virXPathString("string(./@name)", ctxt); - if (tmp =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, - "%s", _("interface has no name")); - return -1; - } - def->name =3D tmp; - return 0; -} - - static int virInterfaceDefParseMtu(virInterfaceDef *def, xmlXPathContextPtr ctxt) @@ -662,8 +645,10 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, } def->type =3D type; =20 - if (virInterfaceDefParseName(def, ctxt) < 0) - return NULL; + if ((def->name =3D virXMLPropString(ctxt->node, "name")) =3D=3D NULL) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("interface has no name"= )); + return NULL; + } =20 if (parentIfType =3D=3D VIR_INTERFACE_TYPE_LAST) { /* only recognize these in toplevel bond interfaces */ --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993137; cv=none; d=zohomail.com; s=zohoarc; b=hjTQWmkZKyCJKyFymJ8FZBaDGEbg3yvtUSL+Z+jNIEw8roxeqPT3LkkmNwaHf/MdsONsfCtt8Sne8SU/q2eQuYy4Ukvv42pJgO7ugVLcov5ICkjbta+YjjgNzdNV5ngycJ0GQpK8398OuWcrh//VTP04Zp4Qx2wC6kbB+NTbvi0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993137; h=Content-Type:Content-Transfer-Encoding:Cc: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=XoXhZeBy0q4ORWFD/oSLwQakuYHJA47+Ci22N0/Ez2U=; b=gjhLOVfgzDaKtdkJ81BMnPibGo4cDtGAsKv4OA01apUZzkJZ67rB+nyknsWBtH2yTdrN7BaGqfUCvRZuhSE4rXk6LqJE3KrvugzSnQHuuAdAxbFPgWvhoec9BVcMJnWNtEwNY6kWnr0/vCX8uJYhMQbfQ2A2VDfnHKIq/dQWm4w= 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 1641993137292923.5181854175305; Wed, 12 Jan 2022 05:12:17 -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-558-aMUO52rbOkav_l77SXsdUA-1; Wed, 12 Jan 2022 08:11:30 -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 65031100CCE0; Wed, 12 Jan 2022 13:11:23 +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 141C36E1F0; Wed, 12 Jan 2022 13:11:23 +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 C2EA11806D2C; Wed, 12 Jan 2022 13:11:22 +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 20CDBGvr004337 for ; Wed, 12 Jan 2022 08:11:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id BEE9B26358; Wed, 12 Jan 2022 13:11:16 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FF2D2634A; Wed, 12 Jan 2022 13:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993136; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=XoXhZeBy0q4ORWFD/oSLwQakuYHJA47+Ci22N0/Ez2U=; b=ej1H1AjyKl19TseabUHGgXYuD2/D6/a+yXxNRqBeP7QGNkcgF0al+xpaIeGtP2rWS+sExE I8hl3MSEL8R9Zm8uifzfSp8aYIaum/HiYSj6Dr2qU9jDZ81zWGS2MlOUNszmWrDED/MbCf f9ttFA2e27aDC2ISaUnnc8vNvetarlY= X-MC-Unique: aMUO52rbOkav_l77SXsdUA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 08/14] virInterfaceDefParseIP: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:09 +0100 Message-Id: <20220112131015.100288-9-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993137998100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index f3fc47bd69..0b3e5716f3 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -252,24 +252,13 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDef *def, =20 static int virInterfaceDefParseIP(virInterfaceIPDef *def, - xmlXPathContextPtr ctxt) + xmlNodePtr node) { - int ret =3D 0; - char *tmp; - long l; - - tmp =3D virXPathString("string(./@address)", ctxt); - def->address =3D tmp; - if (tmp !=3D NULL) { - ret =3D virXPathLong("string(./@prefix)", ctxt, &l); - if (ret =3D=3D 0) { - def->prefix =3D (int) l; - } else if (ret =3D=3D -2) { - virReportError(VIR_ERR_XML_ERROR, - "%s", _("Invalid ip address prefix value")); - return -1; - } - } + if ((def->address =3D virXMLPropString(node, "address")) =3D=3D NULL) + return 0; + + if (virXMLPropInt(node, "prefix", 0, VIR_XML_PROP_NONE, &def->prefix, = 0) < 0) + return -1; =20 return 0; } @@ -309,8 +298,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef *= def, =20 ip =3D g_new0(virInterfaceIPDef, 1); =20 - ctxt->node =3D ipNodes[i]; - if (virInterfaceDefParseIP(ip, ctxt) < 0) { + if (virInterfaceDefParseIP(ip, ipNodes[i]) < 0) { virInterfaceIPDefFree(ip); return -1; } @@ -359,8 +347,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *= def, =20 ip =3D g_new0(virInterfaceIPDef, 1); =20 - ctxt->node =3D ipNodes[i]; - if (virInterfaceDefParseIP(ip, ctxt) < 0) { + if (virInterfaceDefParseIP(ip, ipNodes[i]) < 0) { virInterfaceIPDefFree(ip); return -1; } --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993109; cv=none; d=zohomail.com; s=zohoarc; b=NkI07zGd2MpJEw8jZ3LQFEmBijz+Dxqvq+EGvvtbJZROiIRzqM8QzawUglUdjKfLN4aQ8Hrgtc3TgE0oFtkAedKeLKWrugCnmKjdiiqsZP67jzpgkOOr7X1AZXbixpojHYK+Xq7yuBdaJT9DEAKWoHwOtGDyC92/VZRu/xU6RRY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993109; h=Content-Type:Content-Transfer-Encoding:Cc: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=707mHZw8++laanl0Lr67kYe6yLpj8cj4X1bX94xzUr8=; b=BEnil3a3XTf8RtO41EDrG1cOSgW3kOvmPs9yhXwZfFUv0y5mrBkYtg8y5Ka507fXCILKITDl74yU5IDLeqn3iwtuCwmYXYlOEHq6h1XQU8M3psoy2KdM2Av/18N2O1AL/wsHndn+UW9nEqElxvwiidvu22JYDCyx8rQfQRyFaNk= 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 1641993109040820.1985926198165; Wed, 12 Jan 2022 05:11: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-622-XU7G2X8VPLunqIgfYE0UiQ-1; Wed, 12 Jan 2022 08:11:44 -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 C4F5F100CCD4; Wed, 12 Jan 2022 13:11: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 A14777E913; Wed, 12 Jan 2022 13:11:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 668A91806D2C; Wed, 12 Jan 2022 13:11: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 20CDBHFh004352 for ; Wed, 12 Jan 2022 08:11:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id E2A862634A; Wed, 12 Jan 2022 13:11:17 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2092626364; Wed, 12 Jan 2022 13:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993108; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=707mHZw8++laanl0Lr67kYe6yLpj8cj4X1bX94xzUr8=; b=WmqTjwz/QmhbR6rtInOFyGOei9vWoPH5ZXs1H6I0jD3bh/jUAQd8nxWlJGsf8Ek9JADPZY hu+obWJY7PflEfVHJNGiDDbUVCYrF8jbA8EsJjalTq5qHzElR/TPKmdnAJInGNhxjpjP3r HebHr5rYRXu6Z/8hz8x/1tp4ri2kodA= X-MC-Unique: XU7G2X8VPLunqIgfYE0UiQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 09/14] virInterfaceDefParseDhcp: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:10 +0100 Message-Id: <20220112131015.100288-10-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993110669100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 0b3e5716f3..bfeb69e664 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -226,24 +226,18 @@ virInterfaceDefParseBondArpValid(xmlXPathContextPtr c= txt) =20 static int virInterfaceDefParseDhcp(virInterfaceProtocolDef *def, - xmlNodePtr dhcp, xmlXPathContextPtr ctxt) + xmlNodePtr dhcp) { - VIR_XPATH_NODE_AUTORESTORE(ctxt) - g_autofree char *tmp =3D NULL; + virTristateBool peerdns; =20 def->dhcp =3D 1; - ctxt->node =3D dhcp; def->peerdns =3D -1; - /* Not much to do in the current version */ - tmp =3D virXPathString("string(./@peerdns)", ctxt); - if (tmp) { - bool state =3D false; - if (virStringParseYesNo(tmp, &state) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown dhcp peerdns value %s"), tmp); - return -1; - } - def->peerdns =3D state ? 1 : 0; + + if (virXMLPropTristateBool(dhcp, "peerdns", VIR_XML_PROP_NONZERO, &pee= rdns) < 0) + return -1; + + if (peerdns !=3D VIR_TRISTATE_BOOL_ABSENT) { + def->peerdns =3D peerdns =3D=3D VIR_TRISTATE_BOOL_YES ? 1 : 0; } =20 return 0; @@ -279,7 +273,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef *= def, =20 dhcp =3D virXPathNode("./dhcp", ctxt); if (dhcp !=3D NULL) { - if (virInterfaceDefParseDhcp(def, dhcp, ctxt) < 0) + if (virInterfaceDefParseDhcp(def, dhcp) < 0) return -1; } =20 @@ -328,7 +322,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *= def, =20 dhcp =3D virXPathNode("./dhcp", ctxt); if (dhcp !=3D NULL) { - if (virInterfaceDefParseDhcp(def, dhcp, ctxt) < 0) + if (virInterfaceDefParseDhcp(def, dhcp) < 0) return -1; } =20 --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993098; cv=none; d=zohomail.com; s=zohoarc; b=WlMbKPkARdcXbpGIAbQSXOBcOCpZv9Hhz9RfPTDnCIII8lA7jJH2W2RpyewNe7GAi6ZDq5VMVn4tR1KHNJ3I0vJ3jCDYlm2MvDiurJWK6ydllrRGt7fjdljft7S64W5wWqNU3XyNdpnSCJtsfpQL1OV0N/mA7xxPCnkh20LYUSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993098; h=Content-Type:Content-Transfer-Encoding:Cc: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=KSeH+xp2fSNEnHvRMNB9np4MzrINTuHsspW10rPt/p8=; b=Yk3vybFQiMr27axew5mw1Wns/SvMExBtGvyXuIoiFRIRjtShH/Am1dnjFLxUnZcLb29Vb9Ez+h3BpRXP5JVYPBksX1g4ohWocbamMWw8zp0AQ5ZMQDgtTWImiKdio26bx+EiosqprTsUzl1S1uP9jMpynMaQiMwZOSnA3tBLhqU= 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 1641993098297246.97287818534062; Wed, 12 Jan 2022 05:11: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-533-eHXheYxzNkWVLADO4oCohA-1; Wed, 12 Jan 2022 08:11:34 -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 BABA8835E20; Wed, 12 Jan 2022 13:11:28 +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 9567070D32; Wed, 12 Jan 2022 13:11:28 +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 627084BB7C; Wed, 12 Jan 2022 13:11:28 +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 20CDBRvF004461 for ; Wed, 12 Jan 2022 08:11:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id DD39E26379; Wed, 12 Jan 2022 13:11:27 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2820526370; Wed, 12 Jan 2022 13:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993097; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=KSeH+xp2fSNEnHvRMNB9np4MzrINTuHsspW10rPt/p8=; b=TiKkbQ/deGA254y7t9qs10K+NV3XMVm6Xy/UOCkNXqmx4LAKIGB55neiY9XIVjNcUKgfZ9 /EC3nmPiXSUWehmtZ9E913oBlaewEN0J92+oyJy4YiJhixRS0jMBeqpahGTvp9hgHOzapF xtE9qrwDlRUR0uffQjmrPzjEzeh+L2E= X-MC-Unique: eHXheYxzNkWVLADO4oCohA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 10/14] virInterfaceDefParseProtoIPv4: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:11 +0100 Message-Id: <20220112131015.100288-11-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993100412100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index bfeb69e664..c41eecac29 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -266,10 +266,8 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef = *def, g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes; size_t i; - char *tmp; =20 - tmp =3D virXPathString("string(./route[1]/@gateway)", ctxt); - def->gateway =3D tmp; + def->gateway =3D virXPathString("string(./route[1]/@gateway)", ctxt); =20 dhcp =3D virXPathNode("./dhcp", ctxt); if (dhcp !=3D NULL) { @@ -287,10 +285,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef = *def, =20 def->nips =3D 0; for (i =3D 0; i < nipNodes; i++) { - - virInterfaceIPDef *ip; - - ip =3D g_new0(virInterfaceIPDef, 1); + virInterfaceIPDef *ip =3D g_new0(virInterfaceIPDef, 1); =20 if (virInterfaceDefParseIP(ip, ipNodes[i]) < 0) { virInterfaceIPDefFree(ip); --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993101; cv=none; d=zohomail.com; s=zohoarc; b=L2yXr1tXcyIC2nBnKlvWc5E1v/0W44riut5pak9XeES/ZgjHVj/fvq8S1voVlMZnrr5mg+Ie2jxFmYF55Yggh/7e7yYgRHAZTW0qYXGM47CE7dwE0t9LM+o+5aQiz8snijrK96IBv2JAQkh96Wd7ZKdVPP5dk68yT40lIebFIMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993101; h=Content-Type:Content-Transfer-Encoding:Cc: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=RU+h9JKXYMAojcvCI/vWUmsQ58N4mchDFdqHh6k40BU=; b=ZG1mJ4+HkMq1BDHme+HJ5nKvoqLHL5s7wf1hhPctj5RWgp9+ggbkLIg9yhTfaDH/bIYL92DHQgs+qEMvncz08pvqHYB0mTk2492QG+hiV0jx4U1uGQSSZnPXGx9Ax121UuQ7Nn+GLxCraYM7KPTqrVzllG8pgFJNLZVplytvYnA= 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 1641993100998466.46087033836034; Wed, 12 Jan 2022 05:11: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-111-tX50gZUCNWai67HpSF-HfA-1; Wed, 12 Jan 2022 08:11:36 -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 EE73513EA; Wed, 12 Jan 2022 13:11: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 CA93C56F8F; Wed, 12 Jan 2022 13:11:30 +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 9AF171806D1C; Wed, 12 Jan 2022 13:11:30 +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 20CDBTI0004501 for ; Wed, 12 Jan 2022 08:11:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3E9B26379; Wed, 12 Jan 2022 13:11:28 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EAC026373; Wed, 12 Jan 2022 13:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993100; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=RU+h9JKXYMAojcvCI/vWUmsQ58N4mchDFdqHh6k40BU=; b=V1D1b5HV3WYKBEMx1QUR0zVhVdUV10Y3WpihKhQn4I+qD6lmNdc83m39LPIW1c1EaspP+g eJg4cYWs8hYm7MRUI7OHE4qaxDFz1vIX2GHV7nfj/qSnroGR9f7VDCwHjgyczvLMDRht0r f8LeijW8Bu38VTMjFj29x9KwQcbNcLU= X-MC-Unique: tX50gZUCNWai67HpSF-HfA-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 11/14] virInterfaceDefParseProtoIPv6: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:12 +0100 Message-Id: <20220112131015.100288-12-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993102907100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index c41eecac29..8be439a2a1 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -302,17 +302,14 @@ static int virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *def, xmlXPathContextPtr ctxt) { - xmlNodePtr dhcp, autoconf; + xmlNodePtr dhcp; g_autofree xmlNodePtr *ipNodes =3D NULL; int nipNodes; size_t i; - char *tmp; =20 - tmp =3D virXPathString("string(./route[1]/@gateway)", ctxt); - def->gateway =3D tmp; + def->gateway =3D virXPathString("string(./route[1]/@gateway)", ctxt); =20 - autoconf =3D virXPathNode("./autoconf", ctxt); - if (autoconf !=3D NULL) + if (virXPathNode("./autoconf", ctxt) !=3D NULL) def->autoconf =3D 1; =20 dhcp =3D virXPathNode("./dhcp", ctxt); @@ -331,10 +328,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef = *def, =20 def->nips =3D 0; for (i =3D 0; i < nipNodes; i++) { - - virInterfaceIPDef *ip; - - ip =3D g_new0(virInterfaceIPDef, 1); + virInterfaceIPDef *ip =3D g_new0(virInterfaceIPDef, 1); =20 if (virInterfaceDefParseIP(ip, ipNodes[i]) < 0) { virInterfaceIPDefFree(ip); --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993102; cv=none; d=zohomail.com; s=zohoarc; b=Wvli9o75aCe/zvm8nNcyQsLwF2wAUbC3ANfnIZdi4eI/AcZYOQJMa4Ehps+AugotjlJkgznX7lroldVXNPTwcQH3e1OhHhNax6M/SMEkVHPrPF3RzqMNA+DzZXR5BRKYlroRR3zflLLDeGUpwznQjWrgnZjjwt8XsW0T5nG3MwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993102; h=Content-Type:Content-Transfer-Encoding:Cc: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=9eyDk7399ndE1Vft0vkozauoa3wns505jjdmksufotI=; b=BXG+vZItt8QEcXgNlW0RNVNVykOdLRDw/R0PD2FeTu7POA8XFC0wHlo8feqOpKb2PK/Et2RW4/bHtvAoyKfLScOnppLgTWCgpGdOdKHusDqQey8cN8d1VtBq53vgFExsHnO7iNePaWMJuOnY60TtoouINA0JEkqqeuwvjt5f02M= 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 1641993102856846.7995324290495; Wed, 12 Jan 2022 05:11:42 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-642-kRfbB9X_P164Cb0UXAfP5g-1; Wed, 12 Jan 2022 08:11:40 -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 B14A21083F65; Wed, 12 Jan 2022 13:11:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A36F7BB51; Wed, 12 Jan 2022 13:11:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 563D11806D2B; Wed, 12 Jan 2022 13:11:35 +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 20CDBYYq004646 for ; Wed, 12 Jan 2022 08:11:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id BAF4026358; Wed, 12 Jan 2022 13:11:34 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 094FD2634A; Wed, 12 Jan 2022 13:11:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993101; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=9eyDk7399ndE1Vft0vkozauoa3wns505jjdmksufotI=; b=KQY3n9r+vQ+mj4TFKkimzY2u2RIPc1LUGcdvfsIXIQ6ir5jnpuE9gj2sGOHRdQ4Q/AuWxe VHJtwQnyIJ22LnhZrUZ1jiliFlDtjTndi49sYoSXuOW3OCqgXVpse0fW2z65vTvloXILwZ EL+27uHDG+GuXcKIIEZD0LBfW/So22U= X-MC-Unique: kRfbB9X_P164Cb0UXAfP5g-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 12/14] virInterfaceDefParseIfAdressing: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:13 +0100 Message-Id: <20220112131015.100288-13-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993103214100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 8be439a2a1..8f8e8871cb 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -348,7 +348,6 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree xmlNodePtr *protoNodes =3D NULL; int nProtoNodes, pp; - char *tmp; =20 nProtoNodes =3D virXPathNodeSet("./protocol", ctxt, &protoNodes); if (nProtoNodes < 0) @@ -363,26 +362,24 @@ virInterfaceDefParseIfAdressing(virInterfaceDef *def, =20 def->nprotos =3D 0; for (pp =3D 0; pp < nProtoNodes; pp++) { - g_autoptr(virInterfaceProtocolDef) proto =3D g_new0(virInterfacePr= otocolDef, 1); =20 - ctxt->node =3D protoNodes[pp]; - tmp =3D virXPathString("string(./@family)", ctxt); - if (tmp =3D=3D NULL) { + if ((proto->family =3D virXMLPropString(protoNodes[pp], "family"))= =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("protocol misses the family attribute")= ); return -1; } - proto->family =3D tmp; - if (STREQ(tmp, "ipv4")) { + + ctxt->node =3D protoNodes[pp]; + if (STREQ(proto->family, "ipv4")) { if (virInterfaceDefParseProtoIPv4(proto, ctxt) !=3D 0) return -1; - } else if (STREQ(tmp, "ipv6")) { + } else if (STREQ(proto->family, "ipv6")) { if (virInterfaceDefParseProtoIPv6(proto, ctxt) !=3D 0) return -1; } else { virReportError(VIR_ERR_XML_ERROR, - _("unsupported protocol family '%s'"), tmp); + _("unsupported protocol family '%s'"), proto->f= amily); return -1; } def->protos[def->nprotos++] =3D g_steal_pointer(&proto); --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993122; cv=none; d=zohomail.com; s=zohoarc; b=XLA0F0uUJqPqWC8otYW3tKcDHvVP5DshJkCDevPZnq1ZjGNnUBwjBWNT4vdDGHjNT7nvSH5X3B1J3upXlnay43pqU0DkIzh7eago+lTQ0CYjZAnKwldjgAJrb7SUrEBodHUyH9tW2qeldySJ6H/0HqRxLlbbKHcq8ew+4AHb45U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993122; h=Content-Type:Content-Transfer-Encoding:Cc: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=eVA9wnm2s7VSJ2bLJ0IpCeO5PUcYQOXXCFEZ51n77Fk=; b=Fp9lvCRrR75QxZftY13JEToOIuuN/u6OBCzaCjRqng3m83qPiribUf0JOB79eE2bDbFWZrSym5rcy6R32Yxbg8QGG+EYASoO3LF9N5PpvLfJFcwuTWHg3d1jtuuZSge714HCPWboZhTuK9pxs5uVJc8u/gb0BpGO9b+HQQlpfs4= 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 1641993122596774.157213648034; Wed, 12 Jan 2022 05:12:02 -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-622-bRLM2W0MPHuZkh1InArl-Q-1; Wed, 12 Jan 2022 08:11:44 -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 CC4181F2DC; Wed, 12 Jan 2022 13:11:38 +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 A8A2E7BB5E; Wed, 12 Jan 2022 13:11:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 722804A7CB; Wed, 12 Jan 2022 13:11: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 20CDBZ6n004693 for ; Wed, 12 Jan 2022 08:11:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id DC5D42634C; Wed, 12 Jan 2022 13:11:35 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25A0526364; Wed, 12 Jan 2022 13:11:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993121; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=eVA9wnm2s7VSJ2bLJ0IpCeO5PUcYQOXXCFEZ51n77Fk=; b=iL7aWNpluA96wsNGpR1TfCi/QHrfwgfIb3RMEZfssAIFFiHJrk/yVyuWnDVtUZ5Ty8YgQg Yrg+IoInjoBN3C6xsJdxTW8zngbbF/i0L8HM5CHIzPmcSwYszC8nadAcw+5+S8xrnB3k3Y fV7NpjOmu/42/9WEEQIJkVzGwwz99S8= X-MC-Unique: bRLM2W0MPHuZkh1InArl-Q-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 13/14] virInterfaceDefParseXML: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:14 +0100 Message-Id: <20220112131015.100288-14-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993124526100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 8f8e8871cb..7c2a0f162c 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -573,26 +573,14 @@ static virInterfaceDef * virInterfaceDefParseXML(xmlXPathContextPtr ctxt, int parentIfType) { - g_autoptr(virInterfaceDef) def =3D NULL; - int type; - g_autofree char *tmp =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) + g_autoptr(virInterfaceDef) def =3D NULL; + virInterfaceType type; xmlNodePtr lnk; =20 - - /* check @type */ - tmp =3D virXPathString("string(./@type)", ctxt); - if (tmp =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, - "%s", _("interface misses the type attribute")); + if (virXMLPropEnum(ctxt->node, "type", virInterfaceTypeFromString, + VIR_XML_PROP_REQUIRED, &type) < 0) return NULL; - } - type =3D virInterfaceTypeFromString(tmp); - if (type =3D=3D -1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown interface type %s"), tmp); - return NULL; - } =20 def =3D g_new0(virInterfaceDef, 1); =20 @@ -680,7 +668,8 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, return NULL; break; } - + case VIR_INTERFACE_TYPE_LAST: + return NULL; } =20 return g_steal_pointer(&def); --=20 2.31.1 From nobody Thu Apr 25 01:13:43 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=1641993109; cv=none; d=zohomail.com; s=zohoarc; b=GdgTV5RKWTARXz7Z+bsmPiYwcLxhAofX71QqCeiYUjMnmpVXAOimx7hiUccHGjDr2bpDsN1zSayAjkTEQr7X2qC3NPPfRZ3bJJdZVPiE4hHWRSbUMFexzn9L8r7p+778uyjGcIUnP44N58lv2NSPRGvnuNBM24YtWNy+ThUDRjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1641993109; h=Content-Type:Content-Transfer-Encoding:Cc: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=rI48cr2VwCo5lEokJNNHwww1u7/h1nJoXkKS3E6q5Bs=; b=CY52IcPH3Jfcok5lOXlPfnDSkfI9fkrNXV+NyK9GHtl2+JrJKMQI/5gacNaEfXYUN78UD+jKeKlB5vgxnD3vzuPpl0uMg1+MRn+LSKE2WngtdOOdEtZ5eoTY7smWecLwNtB486SevzCL72j6duqwPqPCmIsMGlApEEMfbhrItqI= 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 1641993109869640.538810744731; Wed, 12 Jan 2022 05:11: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-445-I3bKRC4dOemJ_m8lrbqirQ-1; Wed, 12 Jan 2022 08:11:47 -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 8BA69100CD17; Wed, 12 Jan 2022 13:11: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 680797BB65; Wed, 12 Jan 2022 13:11: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 36B0B4A7CA; Wed, 12 Jan 2022 13:11:40 +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 20CDBbeL004708 for ; Wed, 12 Jan 2022 08:11:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 094B22634A; Wed, 12 Jan 2022 13:11:37 +0000 (UTC) Received: from work.speedport.ip (unknown [10.39.193.168]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43B3A26364; Wed, 12 Jan 2022 13:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641993108; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=rI48cr2VwCo5lEokJNNHwww1u7/h1nJoXkKS3E6q5Bs=; b=FyoQ5mBhj1cZd9O7MjtlEU2sfgbMdT7VHmTZHqtM2KrMAcDnGQ35/OmZyLY6HfDb/sGbQp 1IRdGh5zbXs7jACDD7hd/MmUHqhKzXJBhvbWxDeY5gEIp+9WbKguVI2aFyFhIB0K5vZh0c VS4Adi6ojveai+VfwpGIseQxWxWD33k= X-MC-Unique: I3bKRC4dOemJ_m8lrbqirQ-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 14/14] virInterfaceDefParse: Simplify and cleanup Date: Wed, 12 Jan 2022 14:10:15 +0100 Message-Id: <20220112131015.100288-15-twiederh@redhat.com> In-Reply-To: <20220112131015.100288-1-twiederh@redhat.com> References: <20220112131015.100288-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: 1641993110852100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: Michal Privoznik --- src/conf/interface_conf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 7c2a0f162c..305a312327 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -704,14 +704,13 @@ virInterfaceDefParse(const char *xmlStr, unsigned int flags) { g_autoptr(xmlDoc) xml =3D NULL; - virInterfaceDef *def =3D NULL; =20 - if ((xml =3D virXMLParse(filename, xmlStr, _("(interface_definition)")= , "interface.rng", - flags & VIR_INTERFACE_DEFINE_VALIDATE))) { - def =3D virInterfaceDefParseNode(xml, xmlDocGetRootElement(xml)); - } + xml =3D virXMLParse(filename, xmlStr, _("(interface_definition)"), + "interface.rng", flags & VIR_INTERFACE_DEFINE_VALIDA= TE); + if (!xml) + return NULL; =20 - return def; + return virInterfaceDefParseNode(xml, xmlDocGetRootElement(xml)); } =20 =20 --=20 2.31.1