From nobody Tue Dec 16 03:43:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1751904386; cv=none; d=zohomail.com; s=zohoarc; b=Pg1Ev9EPxMYoj+5lwyPX6OWhNRboIUwIv6QL76KJY7BPebtt3j/E8jdFpuxBdQh4FBx4seNGKcX008V5scF/jSl8YwnnI0tYBmv41UJzOnKJ12GxrJvmZ9XN93WR4dA8G2kEWefcdbPyDi6UYNAG2biTPXE4bj6Yr9mVPt6KNnY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1751904386; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=BhdalNIB4P4pjUKT8kAkyfXgN80Nah19lGNKpEZCzB4=; b=Uo6sE1maUq1C0TXxSGvaT537uVh+dP3Iv4dv9JGV7gXMUJ7hw3qecO/R23sWihMlgQVqeKooGixWGPir+6Xnbv6h8DcwFgW5nVURrCfNJMlVRhklAlcXqSfI5zFcWPH0UEcgkTpfN9EIcI4Qschteig0toYeC38ArTkDt/VHW7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 175190438615184.1051569153866; Mon, 7 Jul 2025 09:06:26 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1816415C8; Mon, 7 Jul 2025 12:06:25 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 65FCB1515; Mon, 7 Jul 2025 12:04:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CDE6113D9; Mon, 7 Jul 2025 12:04:52 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9FFE61367 for ; Mon, 7 Jul 2025 12:04:46 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-kOH2IL8-NM261jhYg22USQ-1; Mon, 07 Jul 2025 12:04:45 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 888F818DA5CF for ; Mon, 7 Jul 2025 16:04:44 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.csb (unknown [10.43.2.22]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 74F401956087; Mon, 7 Jul 2025 16:04:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1751904286; h=from:from: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; bh=r74nrL3vpgEXDiLLdipS4uHdwYA3SCOL4Gya7QXo94Q=; b=Ah9K8sOwjDBYnSG8LfZkyo4fAUD9zIzHavDO67I/KpgJFsEJCF6KJm6jVXzp6AFevRFSVW pKq/CfrHr7ymCEBawwL/0+7zAEyoLGg45/JWmuYCr34l3PxQMCr34LYPTDfcGSNasZm+Bl mHb1fK7ntsXkoR2bxtVKTa3tBQCv6Gg= X-MC-Unique: kOH2IL8-NM261jhYg22USQ-1 X-Mimecast-MFC-AGG-ID: kOH2IL8-NM261jhYg22USQ_1751904284 To: devel@lists.libvirt.org Subject: [PATCH 3/5] util: virSecretLookupParseSecret refactor Date: Mon, 7 Jul 2025 18:03:48 +0200 Message-ID: <20250707160426.184333-4-kshcheti@redhat.com> In-Reply-To: <20250707160426.184333-1-kshcheti@redhat.com> References: <20250707160426.184333-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: M-8MoF4kWeGuWbyHOPbE3lMUWmZXs_inyvH6Evlb6Pw_1751904284 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LYL6LHFE6USM2FZI6I7CEUQUZ56PQWJC X-Message-ID-Hash: LYL6LHFE6USM2FZI6I7CEUQUZ56PQWJC X-MailFrom: kshcheti@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Kirill Shchetiniuk X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Kirill Shchetiniuk via Devel Reply-To: Kirill Shchetiniuk X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1751904392874116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Kirill Shchetiniuk Refactored the virSecretLookupParseSecret fucntion to use the virXMLPropUUID fucntion, avoid getting the string and parsing it later. Previously two separate error states merged into one by using boolean NXOR operation. Signed-off-by: Kirill Shchetiniuk --- src/util/virsecret.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/util/virsecret.c b/src/util/virsecret.c index 8a220a37ec..c5eb1055be 100644 --- a/src/util/virsecret.c +++ b/src/util/virsecret.c @@ -64,34 +64,27 @@ int virSecretLookupParseSecret(xmlNodePtr secretnode, virSecretLookupTypeDef *def) { - g_autofree char *uuid =3D NULL; g_autofree char *usage =3D NULL; + int ret; =20 - uuid =3D virXMLPropString(secretnode, "uuid"); usage =3D virXMLPropString(secretnode, "usage"); - if (uuid =3D=3D NULL && usage =3D=3D NULL) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("missing secret uuid or usage attribute")); + + if ((ret =3D virXMLPropUUID(secretnode, "uuid", VIR_XML_PROP_NONE, def= ->u.uuid)) < 0) return -1; - } =20 - if (uuid && usage) { + if (!(usage) =3D=3D !(ret)) { virReportError(VIR_ERR_XML_ERROR, "%s", _("either secret uuid or usage expected")); return -1; } =20 - if (uuid) { - if (virUUIDParse(uuid, def->u.uuid) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid secret uuid '%1$s'"), uuid); - return -1; - } + if (ret) { def->type =3D VIR_SECRET_LOOKUP_TYPE_UUID; } else { def->u.usage =3D g_steal_pointer(&usage); def->type =3D VIR_SECRET_LOOKUP_TYPE_USAGE; } + return 0; } =20 --=20 2.49.0