From nobody Sun Feb 8 23:03:50 2026 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610999688; cv=none; d=zohomail.com; s=zohoarc; b=FZB7DD2dkbgvZmZ9ToOfuq+FF54rjdzgLNmnwCEfbYAVk0FHlJy/XHeNFJ+lKz2x4PToaSsh4QV1XbF6s+PZPUkrJVti47aN34AFZnr/Ex/OHzIakdYnZm/6IMmkydfikH8IBbXBTRqFJUzLs8N3K8b1UEC+Cu11938W1AbxLvc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610999688; 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=DAUwvkLPLgs8kyvOQ2pLJoFVWNA+dNDDKYN6xT1vjD8=; b=BKslGyiz8JWffxsZTzYemXmoRDemFNuNLX8zfP+RCIhxv6lngXN8BMZE3SLMhknaLDqp0Rd00kNW0z5Gs36YJ5ncwgNA9IZFdscHQeR6ssc5QmcnnHbfjZWW7/GflVbo0zW21wD3KYVROwuivK8xJjSImCGosxSTFvdFZAALMQk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= 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 1610999688797200.5886615403988; Mon, 18 Jan 2021 11:54:48 -0800 (PST) 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-529-WowP4ySDNmOHJyZ1-36RRQ-1; Mon, 18 Jan 2021 14:54:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AC99800D53; Mon, 18 Jan 2021 19:54:37 +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 34A4210023B4; Mon, 18 Jan 2021 19:54:37 +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 F1C8F50044; Mon, 18 Jan 2021 19:54:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10IJs8bA032534 for ; Mon, 18 Jan 2021 14:54:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id 952412166B29; Mon, 18 Jan 2021 19:54:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 900202166B28 for ; Mon, 18 Jan 2021 19:54:08 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B186800161 for ; Mon, 18 Jan 2021 19:54:08 +0000 (UTC) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-nTOGV-YQNFOV8p0i2ggewg-1; Mon, 18 Jan 2021 14:54:06 -0500 Received: by mail-qt1-f179.google.com with SMTP id z9so2203549qtv.6 for ; Mon, 18 Jan 2021 11:54:06 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:a75a:cb34:ba60:6de6:be1d]) by smtp.gmail.com with ESMTPSA id 16sm11309085qkf.112.2021.01.18.11.54.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jan 2021 11:54:05 -0800 (PST) X-MC-Unique: WowP4ySDNmOHJyZ1-36RRQ-1 X-MC-Unique: nTOGV-YQNFOV8p0i2ggewg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DAUwvkLPLgs8kyvOQ2pLJoFVWNA+dNDDKYN6xT1vjD8=; b=GtlGRRoS2r8YNEPHVh3raVHW5ahDoAcFROy1xKhXOsgWkwiSxfnh8XFt1yzsGtFfoo PtW8v5pa7DEM89rTPYxVmviIKNXcGXoTiDqM0B2YlgNqxZE5su7Ijlxx7+S+7AROCvgK Pi6AEepjZX7wtNZ5OjGyM5nUhdtXqXL/hHUlq0YSEGK6odYGo3IBtPwE8DQZDgr7W2ZO hbnTwF4yCyDIAGMgfAawosksZ6fOrD8jUqV5OqJ5nd7SC3Q9t+Ug5Ky7duNR6r7tqAxB 2tDALC0mFYXHQHohAgB7inqZ+XMf5pS/CduSSqvlGks9qiwDmknIlbjWqxWEYy/8FUc5 cUnw== X-Gm-Message-State: AOAM533pDs/+qfCGzm34dj4vmhUiwTJc5vTqm7Xq/R6wljPrpNwXUPPz 5DEzyhqjgJwPGhmA64L3qkfJ312vOBYlkA== X-Google-Smtp-Source: ABdhPJzK+8xqi5UNQZdivVW/4RbHy7MAHRmU124WLk9H4mQXJ6Sv68OD8JDjhaQcy3eAZJ3oMswNaQ== X-Received: by 2002:ac8:6edd:: with SMTP id f29mr1174784qtv.213.1610999645522; Mon, 18 Jan 2021 11:54:05 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH RESEND 12/20] libxl_driver.c: modernize libxlNodeDeviceReAttach() Date: Mon, 18 Jan 2021 16:53:28 -0300 Message-Id: <20210118195336.2090823-13-danielhb413@gmail.com> In-Reply-To: <20210118195336.2090823-1-danielhb413@gmail.com> References: <20210118195336.2090823-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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.84 on 10.5.11.22 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 Content-Type: text/plain; charset="utf-8" Use g_auto* wherever we can and remove the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza --- src/libxl/libxl_driver.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 3eaf106006..fbb67e9ed6 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5852,18 +5852,17 @@ libxlNodeDeviceDettach(virNodeDevicePtr dev) static int libxlNodeDeviceReAttach(virNodeDevicePtr dev) { - virPCIDevicePtr pci =3D NULL; + g_autoptr(virPCIDevice) pci =3D NULL; virPCIDeviceAddress devAddr; - int ret =3D -1; - virNodeDeviceDefPtr def =3D NULL; - char *xml =3D NULL; + g_autoptr(virNodeDeviceDef) def =3D NULL; + g_autofree char *xml =3D NULL; libxlDriverPrivatePtr driver =3D dev->conn->privateData; virHostdevManagerPtr hostdev_mgr =3D driver->hostdevMgr; - virConnectPtr nodeconn =3D NULL; - virNodeDevicePtr nodedev =3D NULL; + g_autoptr(virConnect) nodeconn =3D NULL; + g_autoptr(virNodeDevice) nodedev =3D NULL; =20 if (!(nodeconn =3D virGetConnectNodeDev())) - goto cleanup; + return -1; =20 /* 'dev' is associated with the QEMU virConnectPtr, * so for split daemons, we need to get a copy that @@ -5871,40 +5870,32 @@ libxlNodeDeviceReAttach(virNodeDevicePtr dev) */ if (!(nodedev =3D virNodeDeviceLookupByName( nodeconn, virNodeDeviceGetName(dev)))) - goto cleanup; + return -1; =20 xml =3D virNodeDeviceGetXMLDesc(nodedev, 0); if (!xml) - goto cleanup; + return -1; =20 def =3D virNodeDeviceDefParseString(xml, EXISTING_DEVICE, NULL); if (!def) - goto cleanup; + return -1; =20 /* ACL check must happen against original 'dev', * not the new 'nodedev' we acquired */ if (virNodeDeviceReAttachEnsureACL(dev->conn, def) < 0) - goto cleanup; + return -1; =20 if (virDomainDriverNodeDeviceGetPCIInfo(def, &devAddr) < 0) - goto cleanup; + return -1; =20 pci =3D virPCIDeviceNew(&devAddr); if (!pci) - goto cleanup; + return -1; =20 if (virHostdevPCINodeDeviceReAttach(hostdev_mgr, pci) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - virPCIDeviceFree(pci); - virNodeDeviceDefFree(def); - virObjectUnref(nodedev); - virObjectUnref(nodeconn); - VIR_FREE(xml); - return ret; + return 0; } =20 static int --=20 2.26.2