From nobody Mon May 6 14:13:41 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=1629460944; cv=none; d=zohomail.com; s=zohoarc; b=hjaYMNYrLpmb6NVagex/Kq+CT5vqFrejfheMHxck0pH076xHhtEN2J0mIGMjFinNDDXJ6yI1l+yv6ekcXGIPmcWAiU4T0zh5v5CiefmroJR9O1UwzNP+xBoqVEhJaMHms6SsRx0Q3qBWPxkCGHPxfjcHg8F98tkdEe1zEeHtzcc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629460944; 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=DJnc+HaEAgo++5Kg+5OgGgeI8djuV7LM/j4guywie3g=; b=WiNSiAYmcDIp0wi0gc0jOKX+ZZOvs+1i5YpWWPYIO9w4edpRlbZ5q9AyscmB4MAbjoViAKTI9otqKtx4DaZryYWFrL7PFlHYi6+j/HXYj+TPVKjmnSCsFuLTNIwnknsUfnd167GiRSJsSa17EZV7/T2EGI1+M2Si9XBqq+irBEA= 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 162946094427955.36879468500081; Fri, 20 Aug 2021 05:02:24 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-JRuaiCUQM-uYP5zx8HNu5Q-1; Fri, 20 Aug 2021 08:01:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A984C100CF94; Fri, 20 Aug 2021 12:01:50 +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 619B86B54D; Fri, 20 Aug 2021 12:01:50 +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 26574181A2A9; Fri, 20 Aug 2021 12:01:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBw6Bs007924 for ; Fri, 20 Aug 2021 07:58:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2ECBA19C87; Fri, 20 Aug 2021 11:58:06 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADF266E6E9 for ; Fri, 20 Aug 2021 11:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629460943; 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=DJnc+HaEAgo++5Kg+5OgGgeI8djuV7LM/j4guywie3g=; b=gfE1qUXcvAObfrJ7sl5w+LmZXq6sSBXDobvJOeIgu+bTwLOdNlokwuQgAwj0XimeV9mG+c QANZxTMzTpb6wIvhBafGcHELM5IqLJOBFbivWWzBykFTFhZu9FN1alVM0+HkVuo9jXEeBz OuEssm8uAB0Ein3qe6Ry6AfTBhK1tO8= X-MC-Unique: JRuaiCUQM-uYP5zx8HNu5Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] tests: use g_auto in testQemuGetCaps Date: Fri, 20 Aug 2021 13:57:54 +0200 Message-Id: <013c36fedf52f72a6300e53a5ee425da6e7d26d8.1629460644.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629460946400100003 Refactor testQemuGetCaps to use g_auto for cleanup, remove the error label and use g_steal_pointer for the successful return path. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Kristina Hanicova Reviewed-by: Martin Kletzander --- tests/qemucaps2xmltest.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c index ce1116b792..78a2148e1a 100644 --- a/tests/qemucaps2xmltest.c +++ b/tests/qemucaps2xmltest.c @@ -50,22 +50,22 @@ testQemuDataInit(testQemuData *data) static virQEMUCaps * testQemuGetCaps(char *caps) { - virQEMUCaps *qemuCaps =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; ssize_t i, n; g_autofree xmlNodePtr *nodes =3D NULL; =20 if (!(xml =3D virXMLParseStringCtxt(caps, "(test caps)", &ctxt))) - goto error; + return NULL; =20 if ((n =3D virXPathNodeSet("/qemuCaps/flag", ctxt, &nodes)) < 0) { fprintf(stderr, "failed to parse qemu capabilities flags"); - goto error; + return NULL; } =20 if (!(qemuCaps =3D virQEMUCapsNew())) - goto error; + return NULL; =20 for (i =3D 0; i < n; i++) { g_autofree char *str =3D virXMLPropString(nodes[i], "name"); @@ -73,17 +73,13 @@ testQemuGetCaps(char *caps) int flag =3D virQEMUCapsTypeFromString(str); if (flag < 0) { fprintf(stderr, "Unknown qemu capabilities flag %s", str); - goto error; + return NULL; } virQEMUCapsSet(qemuCaps, flag); } } =20 - return qemuCaps; - - error: - virObjectUnref(qemuCaps); - return NULL; + return g_steal_pointer(&qemuCaps); } =20 static virCaps * --=20 2.31.1 From nobody Mon May 6 14:13:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629461142; cv=none; d=zohomail.com; s=zohoarc; b=blKJBGyDX/+RDZtkOYAAqtVR6GsQe3efhes197IbAiFIJ8waSBkuW1F15XfRyA8cIxqd+8brKgQj1oQnFm/n38KFAMChyqknhM/WmN9f8k5tg3GGAx5Ob4IEEVRD20oM2MIjREGbBMoSqbrkbV/uskp9jE9sNMK4yjnZ3foHEYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629461142; 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=doPAeX6WNgrcvOG3WYuP7GVgboD4v05Kc18Sp5Ef0C4=; b=gJVT3438F3nkXgWcXID9p3LZuqrQnm3L1bjvnZaqq0E0KNXbY/4xOVTowsTxAwCuF8KTp4iRwIQH5EUw4xDgwsGYwR4U6IXcUK0Hn7nXsypc53XUW4zD1vFuNYnjlwzJ/OVJzt0g5QP39wWVxoXJNbXD6YswA/JCrFquCrVouxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629461142083274.34743504064124; Fri, 20 Aug 2021 05:05:42 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-lk3nBXiBOYOR2UySmQ_Otw-1; Fri, 20 Aug 2021 08:05:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 434F41082925; Fri, 20 Aug 2021 12:05:33 +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 2246517B5B; Fri, 20 Aug 2021 12:05:33 +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 E4382181A2A8; Fri, 20 Aug 2021 12:05:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17KBw67u007929 for ; Fri, 20 Aug 2021 07:58:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id F11422C175; Fri, 20 Aug 2021 11:58:06 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AF3E19C87 for ; Fri, 20 Aug 2021 11:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629461140; 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=doPAeX6WNgrcvOG3WYuP7GVgboD4v05Kc18Sp5Ef0C4=; b=QIfc7mbEzV3iGhQOHWdv5Uu1dcGL1E6GDC0xM2ONHsuqoPnJPCVBVZF55DayJ6HsdqbW8I 3g6WOCYwt+3MmS9ZR0c4H3w9SIUmAENdqqzIfxLpP0Efd3iRRc3LPE844AZ24gL8osYSqD Uj426r2qG15a2wzf54OmfoVLu9LL6ok= X-MC-Unique: lk3nBXiBOYOR2UySmQ_Otw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/2] tests: use g_auto in qemuTestParseCapabilitiesArch Date: Fri, 20 Aug 2021 13:57:55 +0200 Message-Id: <483d8587e58ce856f700bb4aaa25907022cde5ae.1629460644.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1629461142803100001 Refactor qemuTestParseCapabilitiesArch to use g_auto fro cleanup. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Kristina Hanicova Reviewed-by: Martin Kletzander --- tests/testutilsqemu.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 81d4a44f9a..ea9a283297 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -304,19 +304,15 @@ virQEMUCaps * qemuTestParseCapabilitiesArch(virArch arch, const char *capsFile) { - virQEMUCaps *qemuCaps =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; g_autofree char *binary =3D g_strdup_printf("/usr/bin/qemu-system-%s", virArchToString(arch)); =20 if (!(qemuCaps =3D virQEMUCapsNewBinary(binary)) || virQEMUCapsLoadCache(arch, qemuCaps, capsFile, true) < 0) - goto error; + return NULL; =20 - return qemuCaps; - - error: - virObjectUnref(qemuCaps); - return NULL; + return g_steal_pointer(&qemuCaps); } =20 =20 --=20 2.31.1