From nobody Fri May 3 08:47:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1583425935; cv=none; d=zohomail.com; s=zohoarc; b=eeBFb+pc/R/m/rQuOjzHO0lPQfF8kSFFn9c9HZ4Q3NvdRnbjtxssgMETW1tcHmfBCioFH4mbXGVijTWW5N/lu/aQMfYIDIAnNGKqvC+BrU/VmJBRAJacwJZlXLfIQ8/ZX61j/LHIjg+Qqny5QGjdH5XTf47TSy1Hy8BP86JUkd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583425935; 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=milcUWWBpuWgAD66RMOUNHWZMSlnthgW/u4DlV5URls=; b=FgPbo6BolgILRxnb4nGvoM8vPbvpRKOEIFxxgLFVDgRPHp4kG4oKyBwwNUgoE+FNmJEKG3kZlWKR3oHfMYuCIEIwmfZ1sgCF5dOTCVdpyeJX7N1rpx6zvzZ0KqwWyMMnt45a31VnWrI/TDXrEg0nqq12I8f9lhqr0Pz3+3aK6H0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 158342593535489.95199744835236; Thu, 5 Mar 2020 08:32:15 -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-404-E2M7v4OnMNqEC5KnHZgXeg-1; Thu, 05 Mar 2020 11:32:11 -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 E194A107ACC4; Thu, 5 Mar 2020 16:32:05 +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 AA6A5277A4; Thu, 5 Mar 2020 16:32:05 +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 4A11418089D0; Thu, 5 Mar 2020 16:32:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 025GVh2r023220 for ; Thu, 5 Mar 2020 11:31:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7E8605C21B; Thu, 5 Mar 2020 16:31:43 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04BAB5C557 for ; Thu, 5 Mar 2020 16:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583425934; 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=milcUWWBpuWgAD66RMOUNHWZMSlnthgW/u4DlV5URls=; b=Du/h35YSJei33e1NbwhRFEnAn9NZxxUYMDDfto0YHSEWnQpMWADZNCsc4RsggzFbbZcW7Y dqa/BUFx40YTJulkhT2h9EJu7jfAjVuzVCT38nm6R+D6UapVataoUkxI4oZnPiZ/g3ReoD +SmzDa0XRf2D0AJCMLBavr4HS7+bZAY= X-MC-Unique: E2M7v4OnMNqEC5KnHZgXeg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/3] virmacmap: Use g_autofree in virMacMapWriteFileLocked Date: Thu, 5 Mar 2020 17:31:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/util/virmacmap.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index 0c0ba90def..4a57edede8 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -261,19 +261,15 @@ static int virMacMapWriteFileLocked(virMacMapPtr mgr, const char *file) { - char *str; - int ret =3D -1; + g_autofree char *str =3D NULL; =20 if (virMacMapDumpStrLocked(mgr, &str) < 0) - goto cleanup; + return -1; =20 if (virFileRewriteStr(file, 0644, str) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - VIR_FREE(str); - return ret; + return 0; } =20 =20 --=20 2.24.1 From nobody Fri May 3 08:47:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1583425940; cv=none; d=zohomail.com; s=zohoarc; b=PUvhcaKtdks5TYJZBltAWwTOxY7uuAWcYBmljeBp87dIuCqda9g3hj01kZe7Cg36kOFtUBP9Qpmsa/QQXaDqmxqEs9wIzk2ckIJaWd3JBugnM+9nHeGVCEK0brsrkoqa1W1wnmO+cOs4Q5LZAYMhg3o8QD0v1Gs1s53JZT+soj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583425940; 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=97GAAlZyuAN2pVFzFmGVZph/wNxPKues8i24GTytJYM=; b=GWYMAnQXt5f6Cn12yVyafpF+ViHNjHn9DkPGsHs7cr+v7hCDUMrspMH4sasuaL+3aKnYqwkcWmuN66gXYwUhSfvPFjLEpTvTbm6UL+znndEV0fwoFDCcZWO9cFw8Dbc7ArFo4XJFA73SmamsHZwJG05p0utslshEY6iHrMxItps= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1583425940025193.48185977443757; Thu, 5 Mar 2020 08:32:20 -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-464-WX9GWuThNXqYLGZfHV38GA-1; Thu, 05 Mar 2020 11:32:16 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E45FF107ACC9; Thu, 5 Mar 2020 16:32:10 +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 57DAC91D94; Thu, 5 Mar 2020 16:32:10 +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 E5A3D18089D6; Thu, 5 Mar 2020 16:32:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 025GViiN023233 for ; Thu, 5 Mar 2020 11:31:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 53F8F5C557; Thu, 5 Mar 2020 16:31:44 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDEB65C21B for ; Thu, 5 Mar 2020 16:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583425938; 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=97GAAlZyuAN2pVFzFmGVZph/wNxPKues8i24GTytJYM=; b=bYyNeCINmrSMMCoP0HNAZhGAScMcMzlrfuZFNHbahmkiGNCPhKldwAT3tLsXVMgwhgTzf5 ReuRVTFzUQbjlT/a4DklJGfIIRRXse/+6tgbZygXgu0XpnTVYjIkPKhnyaZ8I7NJmOSg0+ LHoOs1tgVIBE86QsBceVhZwspT6cAso= X-MC-Unique: WX9GWuThNXqYLGZfHV38GA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/3] vz: use g_autofree in prlsdkConvertCpuInfo Date: Thu, 5 Mar 2020 17:31:34 +0100 Message-Id: <8e639fe9b2d2e75186a9dcad98da5c52d39fcb89.1583425889.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Convert the function to use g_autofree to silence -Wmaybe-uninitialized. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/vz/vz_sdk.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index c49204de1d..9cee6f1fde 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -1456,44 +1456,40 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom, virDomainDefPtr def, virDomainXMLOptionPtr xmlopt) { - char *buf; + g_autofree char *buf =3D NULL; int hostcpus; PRL_UINT32 cpuCount; PRL_RESULT pret; - int ret =3D -1; =20 if ((hostcpus =3D virHostCPUGetCount()) < 0) - goto cleanup; + return -1; =20 /* get number of CPUs */ pret =3D PrlVmCfg_GetCpuCount(sdkdom, &cpuCount); - prlsdkCheckRetGoto(pret, cleanup); + prlsdkCheckRetExit(pret, -1); =20 if (cpuCount > hostcpus) cpuCount =3D hostcpus; =20 if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0) - goto cleanup; + return -1; =20 if (virDomainDefSetVcpus(def, cpuCount) < 0) - goto cleanup; + return -1; =20 if (!(buf =3D prlsdkGetStringParamVar(PrlVmCfg_GetCpuMask, sdkdom))) - goto cleanup; + return -1; =20 if (strlen(buf) =3D=3D 0) { if (!(def->cpumask =3D virBitmapNew(hostcpus))) - goto cleanup; + return -1; virBitmapSetAll(def->cpumask); } else { if (virBitmapParse(buf, &def->cpumask, hostcpus) < 0) - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FREE(buf); - return ret; + return 0; } =20 static int --=20 2.24.1 From nobody Fri May 3 08:47:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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=1583425921; cv=none; d=zohomail.com; s=zohoarc; b=dx0M4hr7SQqCDdFUH0ilUc424hEblKF/Mvi17nPMibISM09yoVBnE5guAkYtCn414svhDSFf4yBfyFhk8kJRwhcWHh/f2kDnbPuqdaKWOx6VD+DyRoBMi7IpDLoGS71aj0TCkM/uKGVP+r1yYllE1SxZuvVy6/xpLVegV7fOSjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583425921; 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=8qEL0pWNOqKvqL1HmgCP3p25oTaD2voYTxxFck3aGfc=; b=V7T7jDFdzteOgz9r2WHm8ShE0RjZLJfkFNeM1c1wXehPfEAnqynXXhHLi7w4oaGQMjSaU26ExuGleMSUdi2d4Ge1PxJuHkopaOZTG1I6yTLqHkW0rr/+EgVx8tVZIhgEDadmolNA0/+FxDGTpiq/HgnZScdgYOdq4tRv2ijNFtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1583425921636514.6651988871052; Thu, 5 Mar 2020 08:32:01 -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-439-ok6PWr3INsWLZjpQKjVmBQ-1; Thu, 05 Mar 2020 11:31:58 -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 9F81418A8C88; Thu, 5 Mar 2020 16:31:50 +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 488452719A; Thu, 5 Mar 2020 16:31: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 A33E686A04; Thu, 5 Mar 2020 16:31:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 025GVkmu023246 for ; Thu, 5 Mar 2020 11:31:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 28A8E5C21B; Thu, 5 Mar 2020 16:31:46 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.81]) by smtp.corp.redhat.com (Postfix) with ESMTP id A27175C557 for ; Thu, 5 Mar 2020 16:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583425920; 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=8qEL0pWNOqKvqL1HmgCP3p25oTaD2voYTxxFck3aGfc=; b=fa2fUTS24GqjECg0KFbcpjATX4QRiINsER9ZQrfDeQnfN/i/abH+g7bTKiK6VU/N4KLQT4 qg4WUT5f8P+qh54jw3jiFX3E1LjpXCzYp1pYpfrdQjCI2awdDfQawn9jp6L4YpZyW43/AX 6Pv6gN8n4aVI2OsAG1TD9ajFGWvLLBQ= X-MC-Unique: ok6PWr3INsWLZjpQKjVmBQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] aa-helper: use g_autofree in create_profile Date: Thu, 5 Mar 2020 17:31:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'template' might be used uninitialized. Use g_autofree for everything and remove all the custom labels. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/security/virt-aa-helper.c | 45 +++++++++++++---------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index b6f58efdea..8526b7b985 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -264,22 +264,21 @@ static int create_profile(const char *profile, const char *profile_name, const char *profile_files, int virtType) { - char *template; - char *tcontent =3D NULL; - char *pcontent =3D NULL; - char *replace_name =3D NULL; - char *replace_files =3D NULL; + g_autofree char *template =3D NULL; + g_autofree char *tcontent =3D NULL; + g_autofree char *pcontent =3D NULL; + g_autofree char *replace_name =3D NULL; + g_autofree char *replace_files =3D NULL; char *tmp =3D NULL; const char *template_name =3D "\nprofile LIBVIRT_TEMPLATE"; const char *template_end =3D "\n}"; int tlen, plen; int fd; - int rc =3D -1; const char *driver_name =3D NULL; =20 if (virFileExists(profile)) { vah_error(NULL, 0, _("profile exists")); - goto end; + return -1; } =20 switch (virtType) { @@ -296,22 +295,22 @@ create_profile(const char *profile, const char *profi= le_name, =20 if (!virFileExists(template)) { vah_error(NULL, 0, _("template does not exist")); - goto end; + return -1; } =20 if ((tlen =3D virFileReadAll(template, MAX_FILE_LEN, &tcontent)) < 0) { vah_error(NULL, 0, _("failed to read AppArmor template")); - goto end; + return -1; } =20 if (strstr(tcontent, template_name) =3D=3D NULL) { vah_error(NULL, 0, _("no replacement string in template")); - goto clean_tcontent; + return -1; } =20 if (strstr(tcontent, template_end) =3D=3D NULL) { vah_error(NULL, 0, _("no replacement string in template")); - goto clean_tcontent; + return -1; } =20 /* '\nprofile \0' */ @@ -328,15 +327,15 @@ create_profile(const char *profile, const char *profi= le_name, =20 if (plen > MAX_FILE_LEN || plen < tlen) { vah_error(NULL, 0, _("invalid length for new profile")); - goto clean_replace; + return -1; } =20 if (!(pcontent =3D virStringReplace(tcontent, template_name, replace_n= ame))) - goto clean_all; + return -1; =20 if (virtType !=3D VIR_DOMAIN_VIRT_LXC) { if (!(tmp =3D virStringReplace(pcontent, template_end, replace_fil= es))) - goto clean_all; + return -1; VIR_FREE(pcontent); pcontent =3D g_steal_pointer(&tmp); } @@ -344,31 +343,21 @@ create_profile(const char *profile, const char *profi= le_name, /* write the file */ if ((fd =3D open(profile, O_CREAT | O_EXCL | O_WRONLY, 0644)) =3D=3D -= 1) { vah_error(NULL, 0, _("failed to create profile")); - goto clean_all; + return -1; } =20 if (safewrite(fd, pcontent, plen - 1) < 0) { /* don't write the '\0' */ VIR_FORCE_CLOSE(fd); vah_error(NULL, 0, _("failed to write to profile")); - goto clean_all; + return -1; } =20 if (VIR_CLOSE(fd) !=3D 0) { vah_error(NULL, 0, _("failed to close or write to profile")); - goto clean_all; + return -1; } - rc =3D 0; =20 - clean_all: - VIR_FREE(pcontent); - clean_replace: - VIR_FREE(replace_name); - VIR_FREE(replace_files); - clean_tcontent: - VIR_FREE(tcontent); - end: - VIR_FREE(template); - return rc; + return 0; } =20 /* --=20 2.24.1