From nobody Wed Sep 10 01:43:01 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=1753197255; cv=none; d=zohomail.com; s=zohoarc; b=IRFnzgBO3S6EeAFZXoFzWS0+Ag6tkjxRav8GmmXbCk6aoLZdRpyAvlr2kJG9J2GKV0h66AjD/9OkTA+zIkpeaVmLrZ5uCC7MTzLMykwpWbDbMQNcqUwEOa0xJhRZag60htc8cvVsc3zAI5QJNh1olE6Sq4jEhnRhJyDq8MjTuFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753197255; 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=pDWUzzbkpnUBgRW7R3RtRdraYyim12gbOXwDjZVBRXg=; b=AqoQk2HQ7fMh3tC0Kjcd7Exrtt2Ta6y+lh2FfdB63G5M4uAQJDz78ZjpFM9Dop0kGNEsZck7cBPCic1715rX3L7IQ25E/kIdosiHUnjk5zVaoTDoXa+Q9+ATrGN2mlkykK3UEbK9G4gLBRuBLV6XzZGFf/fLPWBjMm3ZPllP3L4= 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 1753197255336799.1874125344652; Tue, 22 Jul 2025 08:14:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 574A11319; Tue, 22 Jul 2025 11:14:14 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2E15B134E; Tue, 22 Jul 2025 11:13:12 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3C858E90; Tue, 22 Jul 2025 11:13:07 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 B61E9DC6 for ; Tue, 22 Jul 2025 11:13:06 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-359-QYaQSm5tOem-W9ey-dAn0g-1; Tue, 22 Jul 2025 11:13:04 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BB1CB1800165 for ; Tue, 22 Jul 2025 15:13:03 +0000 (UTC) Received: from kshcheti-thinkpadp1gen4i.tpbc.csb (unknown [10.43.2.246]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A357819560AD; Tue, 22 Jul 2025 15:13:02 +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=-0.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_PASS 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=1753197186; 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=+bBFWahinX0dAcUNPtP/KmR1zyzG7ECtrkZelRy2D8w=; b=EtoXELjVPjmF6xR8lqF11QjMcfhYGUk5ZitD8tppT0FT+urEelJvJfpw3z4bHcll6f1PwS dec1CvveEb/1F76Z6gEetAW1e86c8+4pME+J+BHWMPWT5kBeEQPr0BeZw8VSSBF/ZSHGNM YAzNvY74AIzbLMk0dYHt6K1AGvZJGgk= X-MC-Unique: QYaQSm5tOem-W9ey-dAn0g-1 X-Mimecast-MFC-AGG-ID: QYaQSm5tOem-W9ey-dAn0g_1753197183 To: devel@lists.libvirt.org Subject: [PATCH v2 2/4] util: virSecretLookupParseSecret refactor Date: Tue, 22 Jul 2025 17:12:03 +0200 Message-ID: <20250722151250.32533-3-kshcheti@redhat.com> In-Reply-To: <20250722151250.32533-1-kshcheti@redhat.com> References: <20250722151250.32533-1-kshcheti@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: YSBIh47GBISr4T9U2LgfdIgBdZQcbrd6ujzrtF1SDk0_1753197183 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WD7EFZOWZ2K7LBMKUX4G45H3EJZVWMWQ X-Message-ID-Hash: WD7EFZOWZ2K7LBMKUX4G45H3EJZVWMWQ 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: 1753197257636116600 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..d85a563949 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 rc; =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 ((rc =3D virXMLPropUUID(secretnode, "uuid", VIR_XML_PROP_NONE, def-= >u.uuid)) < 0) return -1; - } =20 - if (uuid && usage) { + if (!usage =3D=3D (rc =3D=3D 0)) { 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 (rc > 0) { 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