From nobody Sun May 19 03:02:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1576845839; cv=none; d=zohomail.com; s=zohoarc; b=NwqbCL357hFOhdsqt9YMbrawgHothSiz8j9znmuR6qszGBITXOK+bEeR0mCBEE3S5K8kxhhe1T63DD8tnWeHYnMatiWilKob6hBqCBY7yzBijAXqTsMdzd5btOxQ1jUkxTZFqlxSWX7UDWGM7q2s3P62J99vEpACkGzB37Ki2x0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576845839; 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=9ofmJHOawATklwoTpmMt4bQBtIvM+x4gM6WdDsXBJYM=; b=kNpcFujvZShEzttGhug+LCPJ82FB7Q4qpDl4tn52uQgC63BFAbMT6Mp5guG+aGaJISduU9WmibZhG7uhIeMridlDz5luSRxtqP5bTWW1gM1jEaYI0C4MoRAA+6aIO3iN2FvUY00o9OWhDJNf9D6LwRle/B+lZSgaoqTDX6vDhsE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1576845839211850.669394311814; Fri, 20 Dec 2019 04:43:59 -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-161-oYSr8bgkP6aVU1WPmiCsiQ-1; Fri, 20 Dec 2019 07:43:56 -0500 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 2882F184BECD; Fri, 20 Dec 2019 12:43:48 +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 EE0075DA2C; Fri, 20 Dec 2019 12:43:47 +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 9D6C518089D5; Fri, 20 Dec 2019 12:43:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKChMpf026559 for ; Fri, 20 Dec 2019 07:43:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9BD281001B07; Fri, 20 Dec 2019 12:43:22 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFD5B1001B00; Fri, 20 Dec 2019 12:43:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576845837; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9ofmJHOawATklwoTpmMt4bQBtIvM+x4gM6WdDsXBJYM=; b=gxKu0rgR+/9ov2xmPbMUIIHulNRFGp0XEow9q/a3cPlsLWioPhWEzcf/yHbYEQPU0X/9Bs +1nK3sudcp+hjyZ6vgGb4fNF0itJICDMmdyB97rbsN8kEHj4WCpbxtUuo8WRscnNIB1u4z Ce7G4puieF0/62f/6Ki9EV3871qF+0o= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 13:43:11 +0100 Message-Id: <20191220124315.1558772-2-fidencio@redhat.com> In-Reply-To: <20191220124315.1558772-1-fidencio@redhat.com> References: <20191220124315.1558772-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH 1/5] conf: Get rid of "no_memory" labels 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 X-MC-Unique: oYSr8bgkP6aVU1WPmiCsiQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As pointed out by J=C3=A1n Tomko, "no_memory seems suspicious in the times = of abort()". As libvirt decided to take the path to not report OOM and simply abort when it happens, let's get rid of the no_memory labels and simplify the code around them. Signed-off-by: Fabiano Fid=C3=AAncio Reviewed-by: Cole Robinson --- src/conf/capabilities.c | 16 +++------------- src/conf/domain_audit.c | 40 ++++++++++------------------------------ 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index da54591c11..82129feaac 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -619,26 +619,16 @@ virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSe= cModelPtr secmodel, const char *type, const char *label) { - char *t =3D NULL, *l =3D NULL; - if (type =3D=3D NULL || label =3D=3D NULL) return -1; =20 - t =3D g_strdup(type); - l =3D g_strdup(label); - if (VIR_EXPAND_N(secmodel->labels, secmodel->nlabels, 1) < 0) - goto no_memory; + return -1; =20 - secmodel->labels[secmodel->nlabels - 1].type =3D t; - secmodel->labels[secmodel->nlabels - 1].label =3D l; + secmodel->labels[secmodel->nlabels - 1].type =3D g_strdup(type); + secmodel->labels[secmodel->nlabels - 1].label =3D g_strdup(label); =20 return 0; - - no_memory: - VIR_FREE(l); - VIR_FREE(t); - return -1; } =20 =20 diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index a55dcd5f91..fdccc585fb 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -89,12 +89,12 @@ virDomainAuditGenericDev(virDomainObjPtr vm, const char *reason, bool success) { - char *newdev =3D NULL; - char *olddev =3D NULL; + g_autofree char *newdev =3D NULL; + g_autofree char *olddev =3D NULL; + g_autofree char *vmname =3D NULL; + g_autofree char *oldsrc =3D NULL; + g_autofree char *newsrc =3D NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; - char *vmname =3D NULL; - char *oldsrc =3D NULL; - char *newsrc =3D NULL; const char *virt =3D virDomainAuditGetVirtType(vm->def); =20 /* if both new and old source aren't provided don't log anything */ @@ -107,29 +107,17 @@ virDomainAuditGenericDev(virDomainObjPtr vm, virUUIDFormat(vm->def->uuid, uuidstr); =20 if (!(vmname =3D virAuditEncode("vm", vm->def->name))) - goto no_memory; + return; =20 if (!(newsrc =3D virAuditEncode(newdev, VIR_AUDIT_STR(newsrcpath)))) - goto no_memory; + return; =20 if (!(oldsrc =3D virAuditEncode(olddev, VIR_AUDIT_STR(oldsrcpath)))) - goto no_memory; + return; =20 VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, "virt=3D%s resrc=3D%s reason=3D%s %s uuid=3D%s %s %s", virt, type, reason, vmname, uuidstr, oldsrc, newsrc); - - cleanup: - VIR_FREE(newdev); - VIR_FREE(olddev); - VIR_FREE(vmname); - VIR_FREE(oldsrc); - VIR_FREE(newsrc); - return; - - no_memory: - VIR_WARN("OOM while encoding audit message"); - goto cleanup; } =20 =20 @@ -957,13 +945,13 @@ virDomainAuditInput(virDomainObjPtr vm, bool success) { char uuidstr[VIR_UUID_STRING_BUFLEN]; - char *vmname; + g_autofree char *vmname =3D NULL; const char *virt =3D virDomainAuditGetVirtType(vm->def); =20 virUUIDFormat(vm->def->uuid, uuidstr); =20 if (!(vmname =3D virAuditEncode("vm", vm->def->name))) - goto no_memory; + return; =20 switch ((virDomainInputType) input->type) { case VIR_DOMAIN_INPUT_TYPE_MOUSE: @@ -980,12 +968,4 @@ virDomainAuditInput(virDomainObjPtr vm, case VIR_DOMAIN_INPUT_TYPE_LAST: break; } - - cleanup: - VIR_FREE(vmname); - return; - - no_memory: - VIR_WARN("OOM while encoding audit message"); - goto cleanup; } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 03:02:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1576845844; cv=none; d=zohomail.com; s=zohoarc; b=FVKuXWbt98YIw6f1pJ+MXSta64QXRsYeWZLubaGd6rNDns7c2LmGXT+MqlzhzqfZ/PBi1ZfoMKc6Qig0afMm9gIFHdT5vVrFhUguDYrFwdUlxbcP/9jKRZrervT9CrVhlguum8N+ksUIdpLHEUci6oRU92qzte+JPnZ6QLMNp5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576845844; 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=T4rShAxGt++VTwySWAXJwYQrnDWrRaB03ckdCr7WNzY=; b=UPVOazP7SmVSQId+zpbngwK7JAP/ss1vqkJoTc1o90LUFWlvOr/P+l0KW09fzPh11cK5TPPGkZ0bD+WD/zm101ge59gq0p0q2djHtJhHI7Ot/x8cfx5xYVgGh7xB91Jyz6uT3TL3k1PGFj1E28ItGYsv69YAkKN6hACnCrtvRLk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1576845844951155.4147228080742; Fri, 20 Dec 2019 04:44:04 -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-52-cs2pMEIUMhG8pKZg43bztw-1; Fri, 20 Dec 2019 07:43:33 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A692B800D48; Fri, 20 Dec 2019 12:43:28 +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 3A3FD63B99; Fri, 20 Dec 2019 12:43:28 +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 0B78118089CE; Fri, 20 Dec 2019 12:43:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKChNjo026568 for ; Fri, 20 Dec 2019 07:43:23 -0500 Received: by smtp.corp.redhat.com (Postfix) id 969E61001B07; Fri, 20 Dec 2019 12:43:23 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9EC81001B00; Fri, 20 Dec 2019 12:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576845842; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=T4rShAxGt++VTwySWAXJwYQrnDWrRaB03ckdCr7WNzY=; b=K5Qv3naklNoewxC+E/UUmI0z0j5bZDRqN+jTFoJ97lEZmLilVcjX9hGyRrNH2ch8whlQOB MAPAGzx0jKBrXwB0t01wvg9W/b58mNWDaCk5w/gKClQRCwj1ZHjg2OHMF8Z022O3+mwxJ3 /Jff//B/AYgoPGlZECSpVdDjdaKy9kM= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 13:43:12 +0100 Message-Id: <20191220124315.1558772-3-fidencio@redhat.com> In-Reply-To: <20191220124315.1558772-1-fidencio@redhat.com> References: <20191220124315.1558772-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH 2/5] openvz: Get rid of "no_memory" labels 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.11 X-MC-Unique: cs2pMEIUMhG8pKZg43bztw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As pointed out by J=C3=A1n Tomko, "no_memory seems suspicious in the times = of abort()". As libvirt decided to take the path to not report OOM and simply abort when it happens, let's get rid of the no_memory labels and simplify the code around them. Signed-off-by: Fabiano Fid=C3=AAncio Reviewed-by: Cole Robinson --- src/openvz/openvz_conf.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 971adaf71c..c4c6dec2f7 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -148,18 +148,18 @@ openvzParseBarrierLimit(const char* value, =20 virCapsPtr openvzCapsInit(void) { - virCapsPtr caps; + g_autoptr(virCaps) caps =3D NULL; virCapsGuestPtr guest; =20 if ((caps =3D virCapabilitiesNew(virArchFromHost(), false, false)) =3D=3D NULL) - goto no_memory; + return NULL; =20 if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) - goto no_memory; + return NULL; =20 if (virCapabilitiesInitCaches(caps) < 0) - goto no_memory; + return NULL; =20 if ((guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_EXE, @@ -168,7 +168,7 @@ virCapsPtr openvzCapsInit(void) NULL, 0, NULL)) =3D=3D NULL) - goto no_memory; + return NULL; =20 if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_OPENVZ, @@ -176,13 +176,9 @@ virCapsPtr openvzCapsInit(void) NULL, 0, NULL) =3D=3D NULL) - goto no_memory; + return NULL; =20 - return caps; - - no_memory: - virObjectUnref(caps); - return NULL; + return g_steal_pointer(&caps); } =20 =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 03:02:49 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=1576845820; cv=none; d=zohomail.com; s=zohoarc; b=m0Njj0d/H20KAfbQQoecISYd8nDPhyKAJvQh5Pf8ZH+r0rz7S0WThc+x3Co0Xns8yRI2c1+Mn+caYkYjpem3E09ALtvy9rSJiQ4azh0f0Wf4FuldsyInk/W9kv7hFEGATLthJ2yXpV4/s4TZ/MbD41TdRO+rs/HloZFqsUqo1yE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576845820; 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=ICJYzMZQ/A63uhsYGMcRhrW/VaBo+K6nnwXASot82KE=; b=dZhBTmF2Tr4wiYTmaTS6X0zZ1aAGQhWL+Mm2Bwl/Hz5gN0h09d3sN4NbTI2oYK2Vk2j3oMAQ7i6yTe8E+86ZAHKThLFeqaHaXkUhNNZYPqnw7n3erdlGCiPRxnJ3wCaBdkpKdb27tf5FpdreMBLMtlooJe8Ffo6gWILh3nQFwt8= 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 1576845820420917.2472124240586; Fri, 20 Dec 2019 04:43:40 -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-295-EeuEaQfNOmWnKM5THZrFSQ-1; Fri, 20 Dec 2019 07:43:34 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 029B1800D4C; Fri, 20 Dec 2019 12:43:29 +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 A614560BEC; Fri, 20 Dec 2019 12:43:27 +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 8BA3718089CD; Fri, 20 Dec 2019 12:43:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKChOkc026573 for ; Fri, 20 Dec 2019 07:43:24 -0500 Received: by smtp.corp.redhat.com (Postfix) id 911831001DD7; Fri, 20 Dec 2019 12:43:24 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id E49C61001DC0; Fri, 20 Dec 2019 12:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576845817; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ICJYzMZQ/A63uhsYGMcRhrW/VaBo+K6nnwXASot82KE=; b=QbcfjUFEQ8c5sAeQvKyELPYJT/I4ZQ26sx/wGg0Xtc6k+jmDQmnF8SRhjENN3dCznfYIWM NxYZcDHZsB2jPxNISfVjBBm6X3/4e02xkq5bySlXFgHdj3cAKECJ93uwWN/iDBwnt/NdaP 7wTlwGpvqNh2b3Qt/Qbs0RIgh1dYhWA= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 13:43:13 +0100 Message-Id: <20191220124315.1558772-4-fidencio@redhat.com> In-Reply-To: <20191220124315.1558772-1-fidencio@redhat.com> References: <20191220124315.1558772-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH 3/5] rpc: Get rid of "no_memory" labels 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.12 X-MC-Unique: EeuEaQfNOmWnKM5THZrFSQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As pointed out by J=C3=A1n Tomko, "no_memory seems suspicious in the times = of abort()". As libvirt decided to take the path to not report OOM and simply abort when it happens, let's get rid of the no_memory labels and simplify the code around them. Signed-off-by: Fabiano Fid=C3=AAncio Reviewed-by: Cole Robinson --- src/rpc/virnetclient.c | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index eba8b865d1..50489b754c 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -439,7 +439,6 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, virURIPtr uri) { virNetSocketPtr sock =3D NULL; - virNetClientPtr ret =3D NULL; =20 virBuffer buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *nc =3D NULL; @@ -457,7 +456,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, confdir =3D virGetUserConfigDirectory(); virBufferAsprintf(&buf, "%s/known_hosts", confdir); if (!(knownhosts =3D virBufferContentAndReset(&buf))) - goto no_memory; + return NULL; } =20 if (privkeyPath) { @@ -465,7 +464,7 @@ virNetClientPtr virNetClientNewLibSSH2(const char *host, } else { homedir =3D virGetUserDirectory(); if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0) - goto no_memory; + return NULL; } =20 if (!authMethods) { @@ -483,11 +482,11 @@ virNetClientPtr virNetClientNewLibSSH2(const char *ho= st, =20 virBufferEscapeShell(&buf, netcatPath); if (!(nc =3D virBufferContentAndReset(&buf))) - goto no_memory; + return NULL; virBufferEscapeShell(&buf, nc); VIR_FREE(nc); if (!(nc =3D virBufferContentAndReset(&buf))) - goto no_memory; + return NULL; =20 virBufferAsprintf(&buf, "sh -c " @@ -500,24 +499,16 @@ virNetClientPtr virNetClientNewLibSSH2(const char *ho= st, nc, nc, socketPath); =20 if (!(command =3D virBufferContentAndReset(&buf))) - goto no_memory; + return NULL; =20 if (virNetSocketNewConnectLibSSH2(host, port, family, username, privkey, knownhosts, knownHostsVerify, authMe= thods, command, authPtr, uri, &sock) !=3D 0) - goto cleanup; - - if (!(ret =3D virNetClientNew(sock, NULL))) - goto cleanup; - - cleanup: - return ret; + return NULL; =20 - no_memory: - virReportOOMError(); - goto cleanup; + return virNetClientNew(sock, NULL); } #undef DEFAULT_VALUE =20 @@ -538,7 +529,6 @@ virNetClientPtr virNetClientNewLibssh(const char *host, virURIPtr uri) { virNetSocketPtr sock =3D NULL; - virNetClientPtr ret =3D NULL; =20 virBuffer buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *nc =3D NULL; @@ -562,7 +552,7 @@ virNetClientPtr virNetClientNewLibssh(const char *host, } else { homedir =3D virGetUserDirectory(); if (virNetClientFindDefaultSshKey(homedir, &privkey) < 0) - goto no_memory; + return NULL; } =20 if (!authMethods) { @@ -580,11 +570,11 @@ virNetClientPtr virNetClientNewLibssh(const char *hos= t, =20 virBufferEscapeShell(&buf, netcatPath); if (!(nc =3D virBufferContentAndReset(&buf))) - goto no_memory; + return NULL; virBufferEscapeShell(&buf, nc); VIR_FREE(nc); if (!(nc =3D virBufferContentAndReset(&buf))) - goto no_memory; + return NULL; =20 command =3D g_strdup_printf("sh -c " "'if '%s' -q 2>&1 | grep \"requires an argum= ent\" >/dev/null 2>&1; then " @@ -596,17 +586,9 @@ virNetClientPtr virNetClientNewLibssh(const char *host, username, privkey, knownhosts, knownHostsVerify, authMet= hods, command, authPtr, uri, &sock) !=3D 0) - goto cleanup; - - if (!(ret =3D virNetClientNew(sock, NULL))) - goto cleanup; - - cleanup: - return ret; + return NULL; =20 - no_memory: - virReportOOMError(); - goto cleanup; + return virNetClientNew(sock, NULL); } #undef DEFAULT_VALUE =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 03:02:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1576845834; cv=none; d=zohomail.com; s=zohoarc; b=WoUpLjhGdsCVzR57zaRd+VdfxMFEDkHJCE7zpozQDITNSBVduo1Kt0u3vXAoaFiT+MLyO2obuASEsxDr/6vxY6tmzQ+At0qFmpLuAoutKHLIcazVbKV0U83VWqNuJ6TDpPgbl/zg+hFv6Kbz7MOhucAe2gqPULDaf9vUyYfba6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576845834; 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=0gStxHrK2/dyuniRomJlG1a4yEqUVxoI9RY+mqbiSsI=; b=P1bu0/r/foPHApO6+qABetO0ojaOCl+p/Qi0XNhtSxriJGQpDxvnXByovqmIn5bMzOZyWX0MjWSzlLN4uZyIXpuLQiyvF4W1J0xUzH1PjmjE19Ie1C6zinsWuMc3WHKvbKT79c/zXEB5hbq2QKAEcOuAqskFDq07LSpdjh4nfmU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1576845834423315.07107384742596; Fri, 20 Dec 2019 04:43:54 -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-7-g6kNugBrO5mur38vhYydFg-1; Fri, 20 Dec 2019 07:43:50 -0500 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 42F33184BECA; Fri, 20 Dec 2019 12:43:45 +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 CD10D5DA75; Fri, 20 Dec 2019 12:43:44 +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 92BD8252E5; Fri, 20 Dec 2019 12:43:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKChPQt026579 for ; Fri, 20 Dec 2019 07:43:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8C6A31001B07; Fri, 20 Dec 2019 12:43:25 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFA731001B00; Fri, 20 Dec 2019 12:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576845833; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0gStxHrK2/dyuniRomJlG1a4yEqUVxoI9RY+mqbiSsI=; b=D2cik7raYi1EjecI+T+n2wgcwZErbD2VoYnzFTUOiP3ZMJKhtFFgrHB96i9h9VWpJ/pXh9 CJ13EVUVCQVcd/Trc9utMQ1GmH1IQXm3aZxJoJpbCfQH+sakBtVGnO1DTAhAzpMd38t0d7 MVNubSh+TV34ehMS85lHoIDqlF6DO4I= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 13:43:14 +0100 Message-Id: <20191220124315.1558772-5-fidencio@redhat.com> In-Reply-To: <20191220124315.1558772-1-fidencio@redhat.com> References: <20191220124315.1558772-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH 4/5] util: Get rid of "no_memory" labels 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 X-MC-Unique: g6kNugBrO5mur38vhYydFg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As pointed out by J=C3=A1n Tomko, "no_memory seems suspicious in the times = of abort()". As libvirt decided to take the path to not report OOM and simply abort when it happens, let's get rid of the no_memory labels and simplify the code around them. Mind that virfirewall.c was not touched and still contains no_memory labels. The reason those are left behind, at least for now, is because the conversion seems to be slightly more complicated than the rest, as some other places are relying on firewall->err being set to ENOMEM. Signed-off-by: Fabiano Fid=C3=AAncio Reviewed-by: Cole Robinson --- src/util/virsysinfo.c | 64 ++++++++++++++++--------------------------- src/util/virsysinfo.h | 2 ++ src/util/viruri.c | 28 +++++++------------ 3 files changed, 35 insertions(+), 59 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 8132ab7a07..e5af4f25e0 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -302,33 +302,27 @@ virSysinfoParsePPCProcessor(const char *base, virSysi= nfoDefPtr ret) virSysinfoDefPtr virSysinfoReadPPC(void) { - virSysinfoDefPtr ret =3D NULL; - char *outbuf =3D NULL; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_autofree char *outbuf =3D NULL; =20 if (VIR_ALLOC(ret) < 0) - goto no_memory; + return NULL; =20 if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), CPUINFO); - goto no_memory; + return NULL; } =20 ret->nprocessor =3D 0; ret->processor =3D NULL; if (virSysinfoParsePPCProcessor(outbuf, ret) < 0) - goto no_memory; + return NULL; =20 if (virSysinfoParsePPCSystem(outbuf, &ret->system) < 0) - goto no_memory; - - VIR_FREE(outbuf); - return ret; + return NULL; =20 - no_memory: - VIR_FREE(outbuf); - virSysinfoDefFree(ret); - return NULL; + return g_steal_pointer(&ret); } =20 =20 @@ -433,13 +427,13 @@ virSysinfoParseARMProcessor(const char *base, virSysi= nfoDefPtr ret) virSysinfoDefPtr virSysinfoReadARM(void) { - virSysinfoDefPtr ret =3D NULL; - char *outbuf =3D NULL; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_autofree char *outbuf =3D NULL; =20 /* Some ARM systems have DMI tables available. */ if ((ret =3D virSysinfoReadDMI())) { if (!virSysinfoDefIsEmpty(ret)) - return ret; + return g_steal_pointer(&ret); virSysinfoDefFree(ret); } =20 @@ -447,29 +441,23 @@ virSysinfoReadARM(void) virResetLastError(); =20 if (VIR_ALLOC(ret) < 0) - goto no_memory; + return NULL; =20 if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), CPUINFO); - goto no_memory; + return NULL; } =20 ret->nprocessor =3D 0; ret->processor =3D NULL; if (virSysinfoParseARMProcessor(outbuf, ret) < 0) - goto no_memory; + return NULL; =20 if (virSysinfoParseARMSystem(outbuf, &ret->system) < 0) - goto no_memory; - - VIR_FREE(outbuf); - return ret; + return NULL; =20 - no_memory: - VIR_FREE(outbuf); - virSysinfoDefFree(ret); - return NULL; + return g_steal_pointer(&ret); } =20 static char * @@ -606,21 +594,21 @@ virSysinfoParseS390Processor(const char *base, virSys= infoDefPtr ret) virSysinfoDefPtr virSysinfoReadS390(void) { - virSysinfoDefPtr ret =3D NULL; - char *outbuf =3D NULL; + g_auto(virSysinfoDefPtr) ret =3D NULL; + g_autofree char *outbuf =3D NULL; =20 if (VIR_ALLOC(ret) < 0) - goto no_memory; + return NULL; =20 /* Gather info from /proc/cpuinfo */ if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), CPUINFO); - goto no_memory; + return NULL; } =20 if (virSysinfoParseS390Processor(outbuf, ret) < 0) - goto no_memory; + return NULL; =20 /* Free buffer before reading next file */ VIR_FREE(outbuf); @@ -629,19 +617,13 @@ virSysinfoReadS390(void) if (virFileReadAll(SYSINFO, 8192, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), SYSINFO); - goto no_memory; + return NULL; } =20 if (virSysinfoParseS390System(outbuf, &ret->system) < 0) - goto no_memory; - - VIR_FREE(outbuf); - return ret; + return NULL; =20 - no_memory: - virSysinfoDefFree(ret); - VIR_FREE(outbuf); - return NULL; + return g_steal_pointer(&ret); } =20 =20 diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h index f30809294b..3ce936205c 100644 --- a/src/util/virsysinfo.h +++ b/src/util/virsysinfo.h @@ -144,6 +144,8 @@ void virSysinfoChassisDefFree(virSysinfoChassisDefPtr d= ef); void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def); void virSysinfoDefFree(virSysinfoDefPtr def); =20 +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(virSysinfoDefPtr, virSysinfoDefFree, NULL); + int virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); =20 diff --git a/src/util/viruri.c b/src/util/viruri.c index 11163a2b40..1b848bd336 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -71,7 +71,8 @@ virURIParseParams(virURIPtr uri) return 0; =20 while (*query) { - char *name =3D NULL, *value =3D NULL; + g_autofree char *name =3D NULL; + g_autofree char *value =3D NULL; =20 /* Find the next separator, or end of the string. */ end =3D strchr(query, '&'); @@ -92,13 +93,15 @@ virURIParseParams(virURIPtr uri) * and consistent with CGI.pm we assume value is "". */ name =3D xmlURIUnescapeString(query, end - query, NULL); - if (!name) goto no_memory; + if (!name) + return -1; } else if (eq+1 =3D=3D end) { /* Or if we have "name=3D" here (works around annoying * problem when calling xmlURIUnescapeString with len =3D 0). */ name =3D xmlURIUnescapeString(query, eq - query, NULL); - if (!name) goto no_memory; + if (!name) + return -1; } else if (query =3D=3D eq) { /* If the '=3D' character is at the beginning then we have * "=3Dvalue" and consistent with CGI.pm we _ignore_ this. @@ -108,22 +111,15 @@ virURIParseParams(virURIPtr uri) /* Otherwise it's "name=3Dvalue". */ name =3D xmlURIUnescapeString(query, eq - query, NULL); if (!name) - goto no_memory; + return -1; value =3D xmlURIUnescapeString(eq+1, end - (eq+1), NULL); - if (!value) { - VIR_FREE(name); - goto no_memory; - } + if (!value) + return -1; } =20 /* Append to the parameter set. */ - if (virURIParamAppend(uri, name, NULLSTR_EMPTY(value)) < 0) { - VIR_FREE(name); - VIR_FREE(value); + if (virURIParamAppend(uri, name, NULLSTR_EMPTY(value)) < 0) return -1; - } - VIR_FREE(name); - VIR_FREE(value); =20 next: query =3D end; @@ -131,10 +127,6 @@ virURIParseParams(virURIPtr uri) } =20 return 0; - - no_memory: - virReportOOMError(); - return -1; } =20 /** --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 19 03:02:49 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1576845833; cv=none; d=zohomail.com; s=zohoarc; b=LsmXCGYf56Mf4GNBQHyokAf5VRld0iJPwlnnAvYreHY3C+f8fBWqqmdOS4XGX120ur3ywNmZEojK6eKmiMIjfpuIpM9F9jlawso5SvgrWoA2vh9VxjPHj3aIHft9Ke/yj7iqN3Ut1yh2xo3KOk00V2owVXs1gxrkzdYly50BD8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576845833; 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=4i1YJBqLWC2LANvruHhmpXGBBSojtIl6ECYS3wvnsuY=; b=Pn7N7H633E1VsJUs6lLhkNMjgMg/xsIBzBiG8edOI+A1qDQafpHBskjF4/NEp4zG/nuZSvvKB+xfvfdD3h1oaOxyy3j7qDjNjQGkduRGLaGXgpQ3BmdkU/7Ns1VigQYF11gC5VNVPk4nJG4PuXKyQTcL+SnOjHFVD+CBTPltdec= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 1576845833330892.6790107207439; Fri, 20 Dec 2019 04:43:53 -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-293-i8gcypcxP5y_Ur3TuYZHmQ-1; Fri, 20 Dec 2019 07:43:50 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C008C800D48; Fri, 20 Dec 2019 12:43:44 +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 9DBF263BAC; Fri, 20 Dec 2019 12:43:44 +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 5B67A252DB; Fri, 20 Dec 2019 12:43:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xBKChQQu026591 for ; Fri, 20 Dec 2019 07:43:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id 865BA1001DD7; Fri, 20 Dec 2019 12:43:26 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id DA4DC1001DC0; Fri, 20 Dec 2019 12:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576845832; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=4i1YJBqLWC2LANvruHhmpXGBBSojtIl6ECYS3wvnsuY=; b=WiAR2EgMGAFtgkCxcciiT283JXgtubZGm361SEp2hjOLWx88lMx9P8pcG53eZ6r1MVd46Q Tp1QbdlC/94CQsauG5F6nDN78Uo0N+U6Yy/YmrK9XUPrUPQi2x4GD0TffHuMSxIbQeN847 MBACWesFhVZ6WAk9T+8iW2UcfsTdcAk= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Fri, 20 Dec 2019 13:43:15 +0100 Message-Id: <20191220124315.1558772-6-fidencio@redhat.com> In-Reply-To: <20191220124315.1558772-1-fidencio@redhat.com> References: <20191220124315.1558772-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH 5/5] vbox: Get rid of "no_memory" labels 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.11 X-MC-Unique: i8gcypcxP5y_Ur3TuYZHmQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As pointed out by J=C3=A1n Tomko, "no_memory seems suspicious in the times = of abort()". As libvirt decided to take the path to not report OOM and simply abort when it happens, let's get rid of the no_memory labels and simplify the code around them. Signed-off-by: Fabiano Fid=C3=AAncio Reviewed-by: Cole Robinson --- src/vbox/vbox_common.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4493fe8582..fc67b716da 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -69,18 +69,18 @@ static virDomainDefParserConfig vboxDomainDefParserConf= ig =3D { static virCapsPtr vboxCapsInit(void) { - virCapsPtr caps; - virCapsGuestPtr guest; + g_autoptr(virCaps) caps =3D NULL; + virCapsGuestPtr guest =3D NULL; =20 if ((caps =3D virCapabilitiesNew(virArchFromHost(), false, false)) =3D=3D NULL) - goto no_memory; + return NULL; =20 if (!(caps->host.numa =3D virCapabilitiesHostNUMANewHost())) - goto no_memory; + return NULL; =20 if (virCapabilitiesInitCaches(caps) < 0) - goto no_memory; + return NULL; =20 if ((guest =3D virCapabilitiesAddGuest(caps, VIR_DOMAIN_OSTYPE_HVM, @@ -89,7 +89,7 @@ vboxCapsInit(void) NULL, 0, NULL)) =3D=3D NULL) - goto no_memory; + return NULL; =20 if (virCapabilitiesAddGuestDomain(guest, VIR_DOMAIN_VIRT_VBOX, @@ -97,13 +97,9 @@ vboxCapsInit(void) NULL, 0, NULL) =3D=3D NULL) - goto no_memory; - - return caps; + return NULL; =20 - no_memory: - virObjectUnref(caps); - return NULL; + return g_steal_pointer(&caps); } =20 static void --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list