From nobody Sun Feb 8 05:08:01 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=1605217765; cv=none; d=zohomail.com; s=zohoarc; b=dMdtK/ck1Bn40BJSNGiSr1sZ05nzh85PlrufIgDLnNfHjY/l0z6XVScgL0XMun2QyQ5WWu1DeqpfbvmKS+LkB+Qr3y6TImF9m8pXbs7/7VCkspUj2C+ptOO52zv47hCmGDSUT0FCiBS0CaBoql5ylzuwhf1XI2RIkZbZQJZZPgk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605217765; 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=wQK+09gD1DHTRtY2gIHVfT5ZOONg47NHY4lEDkZA8tE=; b=WCG3NsfeP1JPnhxmuOSkNTcXX1l9Sx9FVwDHzoH/bBCbk2TpK+gpRLbZqaH9M+Pc7fDi4WJN5XLiu+GBgRDBxYtTpcpQLnCPT6vJCC7MsKiJ075W7ZCde3ve7qrI4HO6rEO8LfxW7MPOeW9qSp7pzAiBXQZ4j5tyVvbj4aDHa4U= 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 1605217765239899.9156922669714; Thu, 12 Nov 2020 13:49:25 -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-141-tMmuLuy2P7yt3yJ9ShuWFQ-1; Thu, 12 Nov 2020 16:49:21 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89256107464A; Thu, 12 Nov 2020 21:49:15 +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 6479119C66; Thu, 12 Nov 2020 21:49:15 +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 2F12E5811F; Thu, 12 Nov 2020 21:49:15 +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 0ACLn6sf005505 for ; Thu, 12 Nov 2020 16:49:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1675C2156A50; Thu, 12 Nov 2020 21:49:06 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 114462156A49 for ; Thu, 12 Nov 2020 21:49:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (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 EBA241823603 for ; Thu, 12 Nov 2020 21:49:05 +0000 (UTC) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-5WKzcwaKN6qjl7_aaOEWJw-1; Thu, 12 Nov 2020 16:49:03 -0500 Received: by mail-qt1-f194.google.com with SMTP id n63so5291762qte.4 for ; Thu, 12 Nov 2020 13:49:03 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:b9cd:904e:d02:53c4:1c05]) by smtp.gmail.com with ESMTPSA id i15sm5136931qke.16.2020.11.12.13.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 13:49:02 -0800 (PST) X-MC-Unique: tMmuLuy2P7yt3yJ9ShuWFQ-1 X-MC-Unique: 5WKzcwaKN6qjl7_aaOEWJw-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=wQK+09gD1DHTRtY2gIHVfT5ZOONg47NHY4lEDkZA8tE=; b=dB6NkI5t9b5bev5UZ2/pfUgdf7WfjqNFNyhueoEHVbhbnOli7HJWag64mZmNIUl0UO SGISeRJ2hbPdSoRD+NZQ7t7pQ8Ew/ghPr0+t57WfEGVm/GV0a5wrn1pZiaKb6+8F7jZd fwrCBoMcmGwCBHg2K6lh7G11x2Wyplnmykbab4g1ySHfEZVirx1I3QhCuAjnXyr73NlE 2wJgX3+gvrUJDakh9pFYWVgJ6USrUFNdr+e7hBNK2w2zxUspKFzqTcLqq0czNrRjjUbW f9LeB4Ar/9mRwekhAcsP+o6esjYE5oRdsYvX19WUJvzeRtq7dmmHznNFAG8qHJ8G8TEQ ZO0w== X-Gm-Message-State: AOAM530VJuGysM0jGABB0RmmsMoJyu9bDoLH8MVUf+VT4YhPp5gk/d3b 4giY0tbEPCo1s91ef/pH10hwEc8kpZs= X-Google-Smtp-Source: ABdhPJwNfkyCULO+X7d9DhXbgGmvpnkWHriqwzG3k3kTiRWnqNoWC7BfrH/cAzipiLgkBTs+lTTN/w== X-Received: by 2002:ac8:57c2:: with SMTP id w2mr1228521qta.213.1605217743049; Thu, 12 Nov 2020 13:49:03 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v1 09/10] qemu_domain.c: modernize qemuDomainWriteMasterKeyFile() Date: Thu, 12 Nov 2020 18:48:39 -0300 Message-Id: <20201112214840.636909-10-danielhb413@gmail.com> In-Reply-To: <20201112214840.636909-1-danielhb413@gmail.com> References: <20201112214840.636909-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.23 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 VIR_AUTOCLOSE with 'fd' and delete the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 67d11aca92..f28178af61 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -406,8 +406,7 @@ qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver, virDomainObjPtr vm) { g_autofree char *path =3D NULL; - int fd =3D -1; - int ret =3D -1; + VIR_AUTOCLOSE fd =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 /* Only gets filled in if we have the capability */ @@ -420,24 +419,19 @@ qemuDomainWriteMasterKeyFile(virQEMUDriverPtr driver, if ((fd =3D open(path, O_WRONLY|O_TRUNC|O_CREAT, 0600)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to open domain master key file for write"= )); - goto cleanup; + return -1; } =20 if (safewrite(fd, priv->masterKey, priv->masterKeyLen) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("failed to write master key file for domain")); - goto cleanup; + return -1; } =20 if (qemuSecurityDomainSetPathLabel(driver, vm, path, false) < 0) - goto cleanup; - - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); + return -1; =20 - return ret; + return 0; } =20 =20 --=20 2.26.2