From nobody Fri Apr 26 05:41:07 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=1668589926; cv=none; d=zohomail.com; s=zohoarc; b=TIq5ln3KnW8WTu6rhBNJb5ir1GaULCVy/9sSBBpzSUOl/J1hSuftQSTddii0wlJRSnpK7NnJ2ZNX/mRapXpyuW162mHomLxmCYCfqTc6K9T6Hr4AMzcYalnZVuEcRn0KnvQhbV3TmElS4Te+0IiwcxImh6KnvGsHV3e8GTvTphs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589926; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vxwY17HWzgz62ESvVLzaPuZMxEz2TOZtboquduK/F8E=; b=UVNU16iMs+Njy7xmwCPe5DEYyobqri3OJs8pQyNyIQEhVHYd5/YQ4Pe4O55EAfztj3pf0yvxRCcC1TMsOlLrDwWUS4OrVso6mSMTXKY08gUuut5YYJUh3q5HiVe5uOOkqvQ/Vt8jwzG8R/l4DPklSR4XZ6xOT7juM8M9qNthmQw= 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 1668589926345678.4151867662857; Wed, 16 Nov 2022 01:12:06 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-173-jJJX5Eu3NJCGpEI9A_ZrtQ-1; Wed, 16 Nov 2022 04:11:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3623285A59D; Wed, 16 Nov 2022 09:11:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 217DE140EBF3; Wed, 16 Nov 2022 09:11:55 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DBF6319465A3; Wed, 16 Nov 2022 09:11:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 900B919465A4 for ; Wed, 16 Nov 2022 09:11:47 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A41D340C83AA; Wed, 16 Nov 2022 09:11:47 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48DF740C835A for ; Wed, 16 Nov 2022 09:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589924; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vxwY17HWzgz62ESvVLzaPuZMxEz2TOZtboquduK/F8E=; b=QiLVDGiToi1j5PBDQM6ulXY8UaY+gTZTJbBxLQSsQvDDJfPAOWfKY/jFGLXrQYvDuZ1+Em UKJKnKvb62KeArQ4F0XCIKdtviEDByA822DHCGC2klFAmH55ZBx2RJRAdGMfiXXUJmvYWJ 7b8jmfbLkQqujT7OO/ilE2S6wVzVrsg= X-MC-Unique: jJJX5Eu3NJCGpEI9A_ZrtQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/7] coding-style: Follow our own recommendation wrt spacing around commas Date: Wed, 16 Nov 2022 10:11:39 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: 1668589926864100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We require a space after a comma and even document this in our coding style document. However, our own rule is broken in the very same document when listing string comparison macros. Separate macro arguments properly. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- docs/coding-style.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/coding-style.rst b/docs/coding-style.rst index 81bd4474f1..d4c9d3b8ab 100644 --- a/docs/coding-style.rst +++ b/docs/coding-style.rst @@ -705,35 +705,35 @@ use one of the following semantically named macros =20 :: =20 - STREQ(a,b) - STRNEQ(a,b) + STREQ(a, b) + STRNEQ(a, b) =20 - For case insensitive equality: =20 :: =20 - STRCASEEQ(a,b) - STRCASENEQ(a,b) + STRCASEEQ(a, b) + STRCASENEQ(a, b) =20 - For strict equality of a substring: =20 :: =20 - STREQLEN(a,b,n) - STRNEQLEN(a,b,n) + STREQLEN(a, b, n) + STRNEQLEN(a, b, n) =20 - For case insensitive equality of a substring: =20 :: =20 - STRCASEEQLEN(a,b,n) - STRCASENEQLEN(a,b,n) + STRCASEEQLEN(a, b, n) + STRCASENEQLEN(a, b, n) =20 - For strict equality of a prefix: =20 :: =20 - STRPREFIX(a,b) + STRPREFIX(a, b) =20 - To avoid having to check if a or b are NULL: =20 --=20 2.37.4 From nobody Fri Apr 26 05:41:07 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=1668589929; cv=none; d=zohomail.com; s=zohoarc; b=IcFjMCnGPvw0Y1HN+IxE+JM0x/yXLa7Wb1XFYc0NJKCx5hCi5XzB68K7OGPiTU8Ci13NrSDMwm20covt745wynRrFB6EQv6+p47cvxjlRhV3aYcB7SFFAgA5o2fqkqmiMudELwUz3SRKpyyOn2UwHP/3acT5kBEfOGnHokpQPdk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589929; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nh+OxNoQzcP8ThjGLQdQ7DFQkc7VYGzePSAMRLiPjXA=; b=LXDP/dyImUxNfLv0F5P65xwGH7O9Vrz1MUZWEn4QN8yYz3mJFjdUFsFx2mrkQ7wcYjUT+Ufcq7Z+HAPqpcWm8JwvIcDYjvAH37NSzKW8/Oma+kzayET7aPjbHuKgR0su1K56xeAENh7Ogh4oTi1s4kZrrvY27O1c5S2aXF+AwTE= 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 1668589929037987.3131666446482; Wed, 16 Nov 2022 01:12:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-a-WAXwfhNL64s-KMUFBy5Q-1; Wed, 16 Nov 2022 04:12:02 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E5732833B02; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D21D517595; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C2A531946A6C; Wed, 16 Nov 2022 09:11:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5156419465A2 for ; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4348E40C83DA; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC51940C83D9 for ; Wed, 16 Nov 2022 09:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589927; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nh+OxNoQzcP8ThjGLQdQ7DFQkc7VYGzePSAMRLiPjXA=; b=VgIiqXLW5tItwrm2AtMZp3FtDshNIgZC9ckUo0kbxhCSIaunIW0Tkl9h8XUv3ChDnbLdXZ YcWb+er380mgBxIWh+NBx1hBDm67peHZUtiP0vTmWLy0tWU9XioReTh/mcyaO/pExeYUQE nC14Zv14p6zmAnGNyBFb0l+YAAmRbDo= X-MC-Unique: a-WAXwfhNL64s-KMUFBy5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/7] docs: Fill missing docs on STRCASEPREFIX() and STRSKIP() Date: Wed, 16 Nov 2022 10:11:40 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1668589930804100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We document use of our STR*() macros, but somehow missed STRCASEPREFIX() and STRSKIP(). Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- docs/coding-style.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/coding-style.rst b/docs/coding-style.rst index d4c9d3b8ab..1faaf681e4 100644 --- a/docs/coding-style.rst +++ b/docs/coding-style.rst @@ -735,6 +735,21 @@ use one of the following semantically named macros =20 STRPREFIX(a, b) =20 +- For case insensitive equality of a prefix: + + :: + + STRCASEPREFIX(a, b) + +- For skipping prefix: + + :: + + /* Instead of: + * STRPREFIX(a, b) ? a + strlen(b) : NULL + * use: */ + STRSKIP(a, b) + - To avoid having to check if a or b are NULL: =20 :: --=20 2.37.4 From nobody Fri Apr 26 05:41:07 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=1668589929; cv=none; d=zohomail.com; s=zohoarc; b=Ki18ZYKmNYUcwbOXf+tlrzSj0rf8k3Iu6DH1mCtwNewlqFRtAruZofw4TkaBfyAkkIET+cM3bBJsAZjp0bywPXKTjkoE5KEZigonwULYpPf5nIqRdhl/R2CNNyEl95CE8WRBsvfIrd5o1PX7L7uaJtxW6cJ5pnxb+mr12PxWlZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589929; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ud5V28TkHnEP7q9G71KXK4BFYCIZuv5ug2ZiuvuI1iM=; b=BnPpfkDQUHyyDnztkv7goTSETfsgB82gpTsDSfYh4aG67EsAFn9NnLMUC4QKIJR0ULLdGKHQfY2GVJctTLDaxr9eUYR98TwaYWUQhRBaqjR/eN1Bppc06w1Woa8sicLhtjn8u3vcgukzbW8DWnMU5TWAiCdGqMyFB5qLEBPIE2Q= 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 1668589929503383.83208247293715; Wed, 16 Nov 2022 01:12:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-369-8EY8T3WCNCu8nlmE8o1m8g-1; Wed, 16 Nov 2022 04:12:03 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8FD5F3C0F45B; Wed, 16 Nov 2022 09:11:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79C972166B29; Wed, 16 Nov 2022 09:11:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5159919465BA; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 19C9619465BA for ; Wed, 16 Nov 2022 09:11:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D703640C835A; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B5C040C83D9 for ; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589927; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ud5V28TkHnEP7q9G71KXK4BFYCIZuv5ug2ZiuvuI1iM=; b=bfzA4u/0Mo5mX9hmPS7t5wfRQ0/YOD/KxtdwVxRDBnR0Er4rr7/xFWOCw+1uX7LTOgCSE2 llt27yNMgCmHFF6ohRDqjHAFGFCShBvIa5lI25EjvTRpQqIYkC6lom+NsMd6Ir8MGJbXah EUI5Hb3lpcIQWfThIm5H+zhdAD8eAvY= X-MC-Unique: 8EY8T3WCNCu8nlmE8o1m8g-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/7] internal: Introduce STRCASESKIP() Date: Wed, 16 Nov 2022 10:11:41 +0100 Message-Id: <9657bb469e0b265a5f6bd00b45b531662b001d62.1668589451.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: 1668589930805100002 Content-Type: text/plain; charset="utf-8"; x-default="true" There is so far one case where STRCASEPREFIX(a, b) && a + strlen(b) combo is used (in virVMXConfigScanResultsCollector()), but there will be more. Do what we do usually: introduce a macro. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- docs/coding-style.rst | 9 +++++++++ src/internal.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/docs/coding-style.rst b/docs/coding-style.rst index 1faaf681e4..02d99330bf 100644 --- a/docs/coding-style.rst +++ b/docs/coding-style.rst @@ -750,6 +750,15 @@ use one of the following semantically named macros * use: */ STRSKIP(a, b) =20 +- For skipping prefix case insensitively: + + :: + + /* Instead of: + * STRCASEPREFIX(a, b) ? a + strlen(b) : NULL + * use: */ + STRCASESKIP(a, b) + - To avoid having to check if a or b are NULL: =20 :: diff --git a/src/internal.h b/src/internal.h index 1e8e2908bf..35cc22ee3d 100644 --- a/src/internal.h +++ b/src/internal.h @@ -87,6 +87,8 @@ #define STRPREFIX(a, b) (strncmp(a, b, strlen(b)) =3D=3D 0) #define STRCASEPREFIX(a, b) (g_ascii_strncasecmp(a, b, strlen(b)) =3D=3D 0) #define STRSKIP(a, b) (STRPREFIX(a, b) ? (a) + strlen(b) : NULL) +#define STRCASESKIP(a, b) (STRCASEPREFIX(a, b) ? (a) + strlen(b) : NULL) + /** * STRLIM * @str: pointer to a string (evaluated once) --=20 2.37.4 From nobody Fri Apr 26 05:41:07 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=1668589993; cv=none; d=zohomail.com; s=zohoarc; b=JN/Wef0fyUfwLGPKkHt8nf7m/DaJU0MH5Ln68YnZaH3qR43AsqrMjCvtgNrGWSWKTxzH+T7/NdiyCjDUvDuif31IdUDhMp8R3ikhcyidVw4bg5e32QHJPjFoDyHmTkFPyYa6iYjFplf+fNYfSR45ioOfB7vXQT2UgcF+zmC045g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589993; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o4N9ffnDP/xPQ8nMkYGz3AOadtVrOF52CckZT2pRWyU=; b=BYbTE6ZHvuUVQcx0IkfmivIOE1brUtILm639sYj2VDrU4AWs1XLBEAGkhF/fUoOzylSOAfij6GCThEFuKIYtRoLt8tAAI2hfAJ8BOUB+2wOZzM6OVVhpke+coB4jU9GKokwvhQV76j9017lFympmye4WnFlbiJVnpB2H/idfTPw= 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 1668589993402469.625689954163; Wed, 16 Nov 2022 01:13:13 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-yKvK-dAVO_m9G2EjEixQeA-1; Wed, 16 Nov 2022 04:12:04 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E9167802534; Wed, 16 Nov 2022 09:11:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D21F7C2C8C5; Wed, 16 Nov 2022 09:11:59 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C6DD519465A3; Wed, 16 Nov 2022 09:11:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 85C3C1946A52 for ; Wed, 16 Nov 2022 09:11:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7695C40C83DC; Wed, 16 Nov 2022 09:11:49 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ACE240C83D9 for ; Wed, 16 Nov 2022 09:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589992; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=o4N9ffnDP/xPQ8nMkYGz3AOadtVrOF52CckZT2pRWyU=; b=dikDeEhyJetDetgQKh1/K4wmYKTHfy5bP3WV9oXpLT6u3VZYoVnH9CLYnMQ00moZjfF+ll qtnTVVQi6j4+o3LRPETvEbFRsjkdq2PJZpN0UAlTgVDHmMUrmHsDtRs17j3ETS3eoE9NAl nzlOjj1lYQNaLOODPZatU2rsSubcID4= X-MC-Unique: yKvK-dAVO_m9G2EjEixQeA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/7] vmx: Convert virVMXConfigScanResultsCollector() to use STRCASESKIP() Date: Wed, 16 Nov 2022 10:11:42 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1668589995122100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Now that we have STRCASESKIP() there's no need to open code it. Convert virVMXConfigScanResultsCollector() so that it uses this new macro. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/vmx/vmx.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index bf0dba17d8..d3e452e3ef 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1321,12 +1321,13 @@ virVMXConfigScanResultsCollector(const char* name, void *opaque) { struct virVMXConfigScanResults *results =3D opaque; + const char *suffix =3D NULL; =20 - if (STRCASEPREFIX(name, "ethernet")) { + if ((suffix =3D STRCASESKIP(name, "ethernet"))) { unsigned int idx; char *p; =20 - if (virStrToLong_uip(name + 8, &p, 10, &idx) < 0 || + if (virStrToLong_uip(suffix, &p, 10, &idx) < 0 || *p !=3D '.') { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse the index of the VMX key '%s= '"), --=20 2.37.4 From nobody Fri Apr 26 05:41:07 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=1668589994; cv=none; d=zohomail.com; s=zohoarc; b=gBMGufVoJEf9t4Av8J+gEguIYQOrhCHKsKlpPwWkYr0lFlpojUtePXedFEYwoRnXjEBw+W6EJzecWk6CWsMS5ogJDGhyeRqL6N4q7o70+EzzA+ddY/8duFizJdRJCYAJZ96I5Mmhj6TDP6CI84n/rclH+UIqkEYxrnRs1qTYGa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589994; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MhPb5nMe5XIqt6MfZFLoiJ8EYxiiniUC5yp5BF5+kQg=; b=dwcMJn0leC58kmBnIrQ3tUA/SWrxBw3XkdIo0e9sgVfQSUbQBDIlr2ycgyWWvhmx+sgv5rUVTK9B4LhoC5vPCIakVDXiWwkkHlKOccTmQSDK3Ewb+1reMbaBlPhBvqoeQxRgtUQtC0R+GgnE1cpJ7EhY/of6VxJnpo4HeJZp/sU= 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 1668589994470212.0584364774511; Wed, 16 Nov 2022 01:13:14 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-ZKAXywrdOuC9u5PSoGw83A-1; Wed, 16 Nov 2022 04:12:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 329A718F0242; Wed, 16 Nov 2022 09:11:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D44C4EA59; Wed, 16 Nov 2022 09:11:57 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0B48F1946A73; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A6C5D19465B7 for ; Wed, 16 Nov 2022 09:11:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 14E9540C83EB; Wed, 16 Nov 2022 09:11:50 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE21840C83D9 for ; Wed, 16 Nov 2022 09:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589993; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MhPb5nMe5XIqt6MfZFLoiJ8EYxiiniUC5yp5BF5+kQg=; b=Cd6EqvADaZU2TWSBSQp0pVvccw3z8oOxQcR8Uglw9oLIuQgGtHM17ltyYlbxiqOsDlsZwr oTA6NzlO2XSVOcv3N8gpwike6QzzcF0E766/nhhDA/bCNukDbk3mZjFiYbPxw1hKVlEmhL oXQA28Xu72N85xXWqWNz9Bq4NQ73g6Y= X-MC-Unique: ZKAXywrdOuC9u5PSoGw83A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 5/7] vmx: Rework virVMXConfigScanResultsCollector slightly Date: Wed, 16 Nov 2022 10:11:43 +0100 Message-Id: <0eaf784a9bb6d6694ca722cb6278044a4a86e7b6.1668589451.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: 1668589995127100002 Content-Type: text/plain; charset="utf-8"; x-default="true" The idea here is that virVMXConfigScanResultsCollector() sets the networks_max_index to the highest ethernet index seen. Well, the struct member is signed int, we parse just seen index into uint and then typecast to compare the two. This is not necessary, because the maximum number of NICs a vSphere domain can have is (): ten [1]. This will fit into signed int easily anywhere. 1: https://configmax.esp.vmware.com/guest?vmwareproduct=3DvSphere&release= =3DvSphere%208.0&categories=3D1-0 Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/vmx/vmx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index d3e452e3ef..287a877b4a 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -1324,10 +1324,10 @@ virVMXConfigScanResultsCollector(const char* name, const char *suffix =3D NULL; =20 if ((suffix =3D STRCASESKIP(name, "ethernet"))) { - unsigned int idx; + int idx; char *p; =20 - if (virStrToLong_uip(suffix, &p, 10, &idx) < 0 || + if (virStrToLong_i(suffix, &p, 10, &idx) < 0 || *p !=3D '.') { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse the index of the VMX key '%s= '"), @@ -1335,8 +1335,8 @@ virVMXConfigScanResultsCollector(const char* name, return -1; } =20 - if ((int)idx > results->networks_max_index) - results->networks_max_index =3D (int)idx; + if (idx > results->networks_max_index) + results->networks_max_index =3D idx; } =20 return 0; --=20 2.37.4 From nobody Fri Apr 26 05:41:07 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=1668589922; cv=none; d=zohomail.com; s=zohoarc; b=lAmH0rhEJDIbdVRoKdxVZV7xc0C+d0VB2X30C7ZI9L1LwoWaYGQNQNbYQ7hmCKazRk5C6CHp/6MVpr044aWLZUZSYbzj0HtY1ol0qZgoOeLCblwuisDsUP2aLsq1q/y/JOXoCtlhrsc8HllAvhTtai/ADuGppmk7q23VqOcjeoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589922; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=seQ/1Vdpf0Zj2kZmezegbsF9SAZJoOyHCpfmt0xJtd8=; b=BGv63flLqPw1ZiWLRW/gBn76MIF9+OP5XrO4xDblnBRIPjSMhXPfhjmmW2IbdxVO6YLLQ/u3yAgOgMNYEbiMSO4CoIzDmcLi1HU3iRl6vJAMMFFUEUa2iN4lo79Db4tAMZ87CozNrr8tA5pAxhajRu/VxOCEDkAaGaRKIngm/2Q= 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 166858992245915.17641690236394; Wed, 16 Nov 2022 01:12:02 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-478-CdQfKXxZOfqzlRQ8joisQQ-1; Wed, 16 Nov 2022 04:11:59 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FA58857AB4; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ED27C2C8C7; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 53AFC1946A49; Wed, 16 Nov 2022 09:11:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A4E1919465A8 for ; Wed, 16 Nov 2022 09:11:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A7F6740C83DF; Wed, 16 Nov 2022 09:11:50 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4CD9640C83D9 for ; Wed, 16 Nov 2022 09:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589921; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=seQ/1Vdpf0Zj2kZmezegbsF9SAZJoOyHCpfmt0xJtd8=; b=Hku4SXGZ0jwIwTrEyE3BjsPT8yxqpIH2Vvf//ORBXuOVv6QWdKMtVH2as7q3KgAkUFoLRU gFN7EcinL62/z+UFdxoDh12bn10vU+x5W/2ssWAje0MZI0IhGxuAMaqAUnX+tYUDtc1tCh I9BjZ/OEknNT8c6kKfCVmQAf+vBGM3w= X-MC-Unique: CdQfKXxZOfqzlRQ8joisQQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 6/7] conf: Introduce virDomainMemoryDefNew() Date: Wed, 16 Nov 2022 10:11:44 +0100 Message-Id: <42f5c275db040b4a2e6c1181104d7f67a68ac832.1668589451.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: 1668589922775100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This is new allocator for virDomainMemoryDef struct which also sets some default values: @model and @targetNode. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/conf/domain_conf.c | 26 +++++++++++++++++++------- src/conf/domain_conf.h | 1 + 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 622f83590f..d3b8ef3656 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13088,9 +13088,6 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, =20 ctxt->node =3D node; =20 - /* initialize to value which marks that the user didn't specify it */ - def->targetNode =3D -1; - if ((rv =3D virXPathInt("string(./node)", ctxt, &def->targetNode)) =3D= =3D -2 || (rv =3D=3D 0 && def->targetNode < 0)) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -13226,6 +13223,20 @@ virDomainSecDefParseXML(xmlNodePtr lsecNode, } =20 =20 +virDomainMemoryDef * +virDomainMemoryDefNew(virDomainMemoryModel model) +{ + virDomainMemoryDef *def =3D NULL; + + def =3D g_new0(virDomainMemoryDef, 1); + def->model =3D model; + /* initialize to value which marks that the user didn't specify it */ + def->targetNode =3D -1; + + return def; +} + + static virDomainMemoryDef * virDomainMemoryDefParseXML(virDomainXMLOption *xmlopt, xmlNodePtr memdevNode, @@ -13234,18 +13245,19 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xm= lopt, { VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr node; - virDomainMemoryDef *def; + virDomainMemoryDef *def =3D NULL; + virDomainMemoryModel model; g_autofree char *tmp =3D NULL; =20 - def =3D g_new0(virDomainMemoryDef, 1); - ctxt->node =3D memdevNode; =20 if (virXMLPropEnum(memdevNode, "model", virDomainMemoryModelTypeFromSt= ring, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, - &def->model) < 0) + &model) < 0) goto error; =20 + def =3D virDomainMemoryDefNew(model); + if (virXMLPropEnum(memdevNode, "access", virDomainMemoryAccessTypeFrom= String, VIR_XML_PROP_NONZERO, &def->access) < 0) goto error; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e16558988d..d29ebf8b8a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2619,6 +2619,7 @@ struct _virDomainMemoryDef { virDomainDeviceInfo info; }; =20 +virDomainMemoryDef *virDomainMemoryDefNew(virDomainMemoryModel model); void virDomainMemoryDefFree(virDomainMemoryDef *def); =20 struct _virDomainIdMapEntry { --=20 2.37.4 From nobody Fri Apr 26 05:41:07 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=1668589942; cv=none; d=zohomail.com; s=zohoarc; b=m+yECz7PUuQCK2rSyRCVrF6bSjYoGPTImNmx3xn9nG/dB/CVPLna7zM5kDViFZUO1+wctA77Fdp209t73iLcV+p1Xdu2R0Yl96cHp/cXVUHVuDX5kk77XS7SxXiB4OBm2EwEixvcfKKK38V4o04CoB8OEBTuMdTMqrzQnip1nIE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668589942; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iVcg0iNsJAsAO6nQqwlImG4yKhlJe/dJH79CxWuAlwU=; b=f2CVOdf/GlzQPT7oR/krt0mX4saQWURL/zT+cwDxrP7BYs/Uj5HYicniCjnmtdhZC4Eozt53ZJGlQIahZrhK3MNGBTKf4iZmbJw0+D5V2E9ftNspAXjH4HXETimoQk4N2E7dS3Uz10Nihyaf9hJocQLyYbP6gq9UjDX94ycr49Q= 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 1668589942026608.081542235217; Wed, 16 Nov 2022 01:12:22 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-DbssUCePNby4AnwTT_fC1w-1; Wed, 16 Nov 2022 04:12:00 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B8CDD80600D; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 924C140C845A; Wed, 16 Nov 2022 09:11:56 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9E38A1946A61; Wed, 16 Nov 2022 09:11:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A548819465B1 for ; Wed, 16 Nov 2022 09:11:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 47933400E577; Wed, 16 Nov 2022 09:11:51 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id E035840C83D9 for ; Wed, 16 Nov 2022 09:11:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668589940; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iVcg0iNsJAsAO6nQqwlImG4yKhlJe/dJH79CxWuAlwU=; b=VluzE7G3F/YieQHkv4cIcbJDPXcs2T1HNZvFBoRh6WeLCZ5vc7MuZkk5AVo7r+k/UCTubd SdUy0ya8SRpHJzw0jFqo5nd9lZEZ2LL1l46WAwzgvSWS04ISO/L+tKmCG44VQnsgkrUKsV soF9lSviJqNQ4HOI1itW12uLxwsd3uY= X-MC-Unique: DbssUCePNby4AnwTT_fC1w-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 7/7] conf: Declare and use autoptr for virDomainMemoryDef Date: Wed, 16 Nov 2022 10:11:45 +0100 Message-Id: <8135bdcad254fc0712e7ca6c373c52acc820ee0f.1668589451.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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: 1668589942866100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Register virDomainMemoryDefFree() to do the cleanup. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- src/conf/domain_conf.c | 24 ++++++++++-------------- src/conf/domain_conf.h | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d3b8ef3656..3790121cf7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13245,7 +13245,7 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xmlo= pt, { VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr node; - virDomainMemoryDef *def =3D NULL; + g_autoptr(virDomainMemoryDef) def =3D NULL; virDomainMemoryModel model; g_autofree char *tmp =3D NULL; =20 @@ -13254,17 +13254,17 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xm= lopt, if (virXMLPropEnum(memdevNode, "model", virDomainMemoryModelTypeFromSt= ring, VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, &model) < 0) - goto error; + return NULL; =20 def =3D virDomainMemoryDefNew(model); =20 if (virXMLPropEnum(memdevNode, "access", virDomainMemoryAccessTypeFrom= String, VIR_XML_PROP_NONZERO, &def->access) < 0) - goto error; + return NULL; =20 if (virXMLPropTristateBool(memdevNode, "discard", VIR_XML_PROP_NONE, &def->discard) < 0) - goto error; + return NULL; =20 /* Extract NVDIMM UUID. */ if (def->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && @@ -13274,34 +13274,30 @@ virDomainMemoryDefParseXML(virDomainXMLOption *xm= lopt, if (virUUIDParse(tmp, def->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed uuid element")); - goto error; + return NULL; } } =20 /* source */ if ((node =3D virXPathNode("./source", ctxt)) && virDomainMemorySourceDefParseXML(node, ctxt, def) < 0) - goto error; + return NULL; =20 /* target */ if (!(node =3D virXPathNode("./target", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing element for device")); - goto error; + return NULL; } =20 if (virDomainMemoryTargetDefParseXML(node, ctxt, def) < 0) - goto error; + return NULL; =20 if (virDomainDeviceInfoParseXML(xmlopt, memdevNode, ctxt, &def->info, flags) < 0) - goto error; + return NULL; =20 - return def; - - error: - virDomainMemoryDefFree(def); - return NULL; + return g_steal_pointer(&def); } =20 =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index d29ebf8b8a..a9f7e8d977 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2621,6 +2621,7 @@ struct _virDomainMemoryDef { =20 virDomainMemoryDef *virDomainMemoryDefNew(virDomainMemoryModel model); void virDomainMemoryDefFree(virDomainMemoryDef *def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainMemoryDef, virDomainMemoryDefFree); =20 struct _virDomainIdMapEntry { unsigned int start; --=20 2.37.4