From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183458; cv=none; d=zohomail.com; s=zohoarc; b=aYvrLg24WL/97Qh6omt7Cqm8v6ofCqZHzsvfs/Y+R1L57juQu9qLC+SVWDlKI3u/d79zpkihSpotYkxfZgQkqdDId3oR0sN/NzyuuRd+9e+Q3dyoGcyiU0/1U7GzJ9+D41i/TQ/uin8xbbmPFLv90cku1uf2pznplYIyAbxw5Kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183458; 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=PNFcgcoBrw9bCS1bTSnCyIa920+zQksg8xbIwgQ/eQw=; b=hz/sR6g4xWtltELZqh9If+FjD0rU5/kskgMCumuvOYwDGDBoR1q92Ctg5nG7aOO4/IOg4dANNLls5vCCcEz9XnOqitWZNuFo4oQFLPRPDWboUfHs9TWFNbq31kMUg4zJcqsgLWtyrCuT1GFBFHWAROGQskRyfwxHIWS6IqW25KY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183458208278.5707186236308; Wed, 24 Feb 2021 08:17:38 -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-304-E9QawMFePDyUDhlfUj4NBg-1; Wed, 24 Feb 2021 11:17:33 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 79AF418E6FC1; Wed, 24 Feb 2021 16:17:27 +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 4FB5D5C22B; Wed, 24 Feb 2021 16:17: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 B2F8F58076; Wed, 24 Feb 2021 16:17:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHEA5015470 for ; Wed, 24 Feb 2021 11:17:14 -0500 Received: by smtp.corp.redhat.com (Postfix) id 39A70646DC; Wed, 24 Feb 2021 16:17:14 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E86460862 for ; Wed, 24 Feb 2021 16:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183455; 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=PNFcgcoBrw9bCS1bTSnCyIa920+zQksg8xbIwgQ/eQw=; b=P0WUpq4TngZlRxMByWZdSjoiqd+SfMTBJcGpMVvWrnr6JjwJKjj1yYWEArv0wkp2IgTr2A MNDob3JOPcMqvu2trGIkQMfMTHtU6rslJe5rD7Dvto6MpbnRxzTWHz705oiGHKwtH5JCTp wQjvcFXdTpSeRp88NvWfWpWwSJYL8mE= X-MC-Unique: E9QawMFePDyUDhlfUj4NBg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/33] Remove useless comments for VIR_FROM_THIS definition Date: Wed, 24 Feb 2021 17:16:36 +0100 Message-Id: <10d35bfa8a62def661296d3a5ee4ba3ff2bf8472.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/util/virpci.c | 1 - src/util/virscsi.c | 1 - src/util/virscsivhost.c | 1 - 3 files changed, 3 deletions(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 8147ce11e9..3df4199532 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -103,7 +103,6 @@ struct _virPCIDeviceList { }; -/* For virReportOOMError() and virReportSystemError() */ #define VIR_FROM_THIS VIR_FROM_NONE /* Specifications referenced in comments: diff --git a/src/util/virscsi.c b/src/util/virscsi.c index 2a9f6da76a..d0ba33e254 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -37,7 +37,6 @@ #define SYSFS_SCSI_DEVICES "/sys/bus/scsi/devices" -/* For virReportOOMError() and virReportSystemError() */ #define VIR_FROM_THIS VIR_FROM_NONE VIR_LOG_INIT("util.scsi"); diff --git a/src/util/virscsivhost.c b/src/util/virscsivhost.c index b7bf0da1b3..a0dfb8021a 100644 --- a/src/util/virscsivhost.c +++ b/src/util/virscsivhost.c @@ -28,7 +28,6 @@ #include "virstring.h" #include "viralloc.h" -/* For virReportOOMError() and virReportSystemError() */ #define VIR_FROM_THIS VIR_FROM_NONE VIR_LOG_INIT("util.scsihost"); --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183456; cv=none; d=zohomail.com; s=zohoarc; b=mBWdJ8L5R+24biOT4RL8yD+GruR2ZM+VDyhE0OHPxk4DAjAs3F7KcclMs2Mzec4eJ1a5YXSXhZROAXYb9Rp7XMsacv4D5B3Qw9nfgvz4P7XOaY7qWtRRnayxUWB2QMfLpfUMnTVkiW5Oq45n0tC4c+YNZ/k0w2b45GDosaxYbbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183456; 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=7e6ZQkvJ2AVAdACyeJGE+F1xRmkocClqi4CtIAeMWRE=; b=N+nG1wX8+igtI9lKIjaRdTiyJw4VS25Cykg9JNDhLBWhYWhSVKMfobHCMU7NqcDjdT1TeT0AGJl+idfofjghH2jjIjcFf7AAAk5G7fj5joV2PWF5yV6kahG2r2QTbaN3a2fLrW0j9JcEM6RXfTcP22BMIeVq92z1716k7Thcnno= 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) 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 1614183456777490.1553949922892; Wed, 24 Feb 2021 08:17:36 -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-345-QCOUJzTeMHGRzRPVpVQ5aw-1; Wed, 24 Feb 2021 11:17:33 -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 6E08C804039; Wed, 24 Feb 2021 16:17:27 +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 3BEE610021AA; Wed, 24 Feb 2021 16:17: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 6011758077; Wed, 24 Feb 2021 16:17:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHFmP015476 for ; Wed, 24 Feb 2021 11:17:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 618B0646DC; Wed, 24 Feb 2021 16:17:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 980F960862 for ; Wed, 24 Feb 2021 16:17:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183455; 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=7e6ZQkvJ2AVAdACyeJGE+F1xRmkocClqi4CtIAeMWRE=; b=evGlrbTEJzJsPgjWeRV9plWvFguTR7dbAMT19wTTNxPu9b/BQ5otqee3/jvt/3poeOWLox QYKAfv6OkhR5eYqwc5rJ8V0sfCIzFnkuKyh5VaVLB2EtclPZubE/Iq1R3Hzira029eGel4 Z2e0OYFscaG8gX68zQ2wD3CnjId++Wo= X-MC-Unique: QCOUJzTeMHGRzRPVpVQ5aw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/33] util: xml: Introduce autoptr cleanup support for 'xmlNode' Date: Wed, 24 Feb 2021 17:16:37 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/util/virxml.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virxml.h b/src/util/virxml.h index f73b8975ba..e696dd25f5 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -255,6 +255,7 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virXPathContextNodeSav= e, virXPathContextNodeRes G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlDoc, xmlFreeDoc); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPathFreeContext); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlBuffer, xmlBufferFree); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlNode, xmlFreeNode); typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr ctxt, void **nsdata= ); typedef void (*virXMLNamespaceFree)(void *nsdata); --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183625; cv=none; d=zohomail.com; s=zohoarc; b=Z3xAcSz/9t9WVI7MV4XaD6wh3zQh4vY6YbrI2WO+F7lpm93mtPeXTgZsxbm5DNvkKJMt6WLrBm1Iok+nhAan9N0sFfGMcUlIa4mBngXErZfvyKX+EHvEhK5C8rPvWnFrWRQtKSgVo44urRP7yXadJylqaDdM853u1606VuaDihs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183625; 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=Vdo2zeDghtz+wKo14kx+vZec9jBV17IpX33k87KyA/4=; b=GT7tLnHyWiyRk2d6T8ySNp/O6KimEy13QBPDrVRMjZtmsJFtkBH7OKvbwzOzYv6wSPtPjkPeUlXL4yJxYwvCopugQ+x1rJXv82NfdvyQKmXLkSwmBbZI32Jz6/H5mOSt6dgDEF1CZVGNhqF6jr8N2eOx2MAsyfNTYU40x/As4Eo= 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) 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 1614183625199616.4994621175233; Wed, 24 Feb 2021 08:20: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-433-47aljio_OFSIhJtLRCw-JA-1; Wed, 24 Feb 2021 11:17:42 -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 BD8B780403C; Wed, 24 Feb 2021 16:17:35 +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 90F6D5D9DC; Wed, 24 Feb 2021 16:17:35 +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 5707F18095CC; Wed, 24 Feb 2021 16:17:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHGsY015484 for ; Wed, 24 Feb 2021 11:17:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 71321646DC; Wed, 24 Feb 2021 16:17:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id C35B660862 for ; Wed, 24 Feb 2021 16:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183465; 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=Vdo2zeDghtz+wKo14kx+vZec9jBV17IpX33k87KyA/4=; b=gOFVkh3W16+lc0yPN7VMcKDz7h9/NB5+hw7hjoPd+CTuoQfxxqTK6rZHCEGaAbWuYnD4iY BOn6a1wGdi/PgDmiHIclk1ymX9/IaMQs8ZLTHbxDKCkz7u1AgBN0McsZ6N9KCgVyPjIRMy gJjtRUXARVGtKlvbtyE0BpSKLS+pF/0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183622; 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=Vdo2zeDghtz+wKo14kx+vZec9jBV17IpX33k87KyA/4=; b=ISvkepVx3sKhziUM7zdDeX+r7BljDJubvTsAYyR3TMfzfWOIQgZjq/wVVPwbbAPQLycmut a5EeMag8uuKkEExbgRT035mA+I2bW1O6Qc6BxBxyEjIFfKX30d/0nFloU4vY9qxT8lWREz xhItsYV7kIkPxjkQyn4WXdRtgol719s= X-MC-Unique: 47aljio_OFSIhJtLRCw-JA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/33] virDomainDefSetMetadata: Avoid temporary variable for string copy Date: Wed, 24 Feb 2021 17:16:38 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Since error checking was removed when switching to g_strdup, it doesn't make much sense to have 'tmp' around. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b731744f04..6f4487fcfc 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30426,7 +30426,6 @@ virDomainDefSetMetadata(virDomainDefPtr def, xmlDocPtr doc =3D NULL; xmlNodePtr old; xmlNodePtr new =3D NULL; - char *tmp =3D NULL; int ret =3D -1; if (type >=3D VIR_DOMAIN_METADATA_LAST) { @@ -30437,19 +30436,17 @@ virDomainDefSetMetadata(virDomainDefPtr def, switch ((virDomainMetadataType) type) { case VIR_DOMAIN_METADATA_DESCRIPTION: - if (STRNEQ_NULLABLE(metadata, "")) - tmp =3D g_strdup(metadata); + g_clear_pointer(&def->description, g_free); - VIR_FREE(def->description); - def->description =3D tmp; + if (STRNEQ_NULLABLE(metadata, "")) + def->description =3D g_strdup(metadata); break; case VIR_DOMAIN_METADATA_TITLE: - if (STRNEQ_NULLABLE(metadata, "")) - tmp =3D g_strdup(metadata); + g_clear_pointer(&def->title, g_free); - VIR_FREE(def->title); - def->title =3D tmp; + if (STRNEQ_NULLABLE(metadata, "")) + def->title =3D g_strdup(metadata); break; case VIR_DOMAIN_METADATA_ELEMENT: --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183544; cv=none; d=zohomail.com; s=zohoarc; b=HC2MHi+Jc23BrBCLZrWOrv1XwRsQRZnAWaC3djgp3FRLdZyBTzlq2NMh4GBRfHpAK2Y3fEzi2SWVhmmD9szrkIaKbmM3HBsWGbGDgun+1SjecbTNonbcHdWngReMQ4b1+PUmPObA59QizdHZbDTQDklSkGG0rvNI9luINoyJxcQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183544; 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=1pM4vuZy9BqsBOh2PlZLeYNl7CMi1oC09II6U3scA9U=; b=DLPOl7y4oAfBw8k8m+RoigkK1zVjrs01/AVEyegnTg5i/eedVssnyeCSYfwpwjJP1815F5FYdvLRaBphf3n3u74XQdgAaSDSSAL25mjyr01vm/c3Ah/GjQ2PSprf2lk9SfI4qZzKupBs2QDWtXdGCdIjlMLY/0D2LDGso7VS+MY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183544179370.25639999157477; Wed, 24 Feb 2021 08:19: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-275-AznUyQDuOUycQ_2srGFLQw-1; Wed, 24 Feb 2021 11:17:46 -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 C4CD1107ACF4; Wed, 24 Feb 2021 16:17:35 +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 9285210016FD; Wed, 24 Feb 2021 16:17:35 +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 5726518095CD; Wed, 24 Feb 2021 16:17:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHK2e015502 for ; Wed, 24 Feb 2021 11:17:20 -0500 Received: by smtp.corp.redhat.com (Postfix) id 063CE646DC; Wed, 24 Feb 2021 16:17:20 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22CA960862 for ; Wed, 24 Feb 2021 16:17:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183543; 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=1pM4vuZy9BqsBOh2PlZLeYNl7CMi1oC09II6U3scA9U=; b=a9Ypq379SOIwNs3wmkuO2ZqeC3cgPF+h31APxRDNBBgn/QyDhlrtTSNz5VXTIK8p+1wyQe hwGpK/OhuNbzuEG69G94iT5cdSgH/WbP9lARSYWGzodXMGB4+f6uOloABoxQ0GPoy1hVFp nXMtkYBMJWIdKVkPAfoL6mtmd7CMU04= X-MC-Unique: AznUyQDuOUycQ_2srGFLQw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/33] virCommandAddEnv: Make stealing of argument more obvious Date: Wed, 24 Feb 2021 17:16:39 +0100 Message-Id: <6f36d6f77b8e888a16535209b09fc05baeb9d1e3.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function is supposed to always consume the passed environment variable string. Use a temp variable with autofree and g_steal_pointer to prevent having to free it manually. Signed-off-by: Peter Krempa --- src/util/vircommand.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 323f841b98..b94ab615d5 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1325,8 +1325,10 @@ virCommandRawStatus(virCommandPtr cmd) * already set, then it is replaced in the list. */ static void -virCommandAddEnv(virCommandPtr cmd, char *env) +virCommandAddEnv(virCommandPtr cmd, + char *envstr) { + g_autofree char *env =3D envstr; size_t namelen; size_t i; @@ -1336,19 +1338,18 @@ virCommandAddEnv(virCommandPtr cmd, char *env) /* + 1 because we want to match the '=3D' character too. */ if (STREQLEN(cmd->env[i], env, namelen + 1)) { VIR_FREE(cmd->env[i]); - cmd->env[i] =3D env; + cmd->env[i] =3D g_steal_pointer(&env); return; } } /* Arg plus trailing NULL. */ if (VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1) < 0) { - VIR_FREE(env); cmd->has_error =3D ENOMEM; return; } - cmd->env[cmd->nenv++] =3D env; + cmd->env[cmd->nenv++] =3D g_steal_pointer(&env); } /** --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183472; cv=none; d=zohomail.com; s=zohoarc; b=A36Hn6++id1SQGY/aKkTyfXlqPhC7V6LVTkXSIsDFGJ3ZO9G6jhgTBF0h3Yur+GJFjNgTXWnnWvN/ZEnYrwAEJZk9F73pmbr6CLQAawCbn3+FgVN2XkBzM32DR5DURGDtU9kcDFAE9Yfv9k0HYwHrqSkjPpG8nWtzn87dblvhlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183472; 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=4BOtAzYFXHWQHLnL8CS0i3b4JKqv9WWzdUidvh1n/iI=; b=RZeqqLID7+t7/4bmnfZwhzXlcyj6Sds34mXpUqmWVVRnhsx2DG1Q8uLlEHk2MQkreOa0gCX6EcLJC6w2HDrXsIVbZ64rKpOgHdoi+WWOdBWI5b+7ixz6Ne71hjlNEKFb7j/j755KjIQyg2GpfmHWp2PfjdrHldm18+K41eqfPVg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183472337330.05322754531915; Wed, 24 Feb 2021 08:17:52 -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-106-uEhDMoc_OWCi6PEOo5_Z4g-1; Wed, 24 Feb 2021 11:17:47 -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 E4B5910B9CA3; Wed, 24 Feb 2021 16:17:38 +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 C072A10016F9; Wed, 24 Feb 2021 16:17:38 +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 80D2218089C9; Wed, 24 Feb 2021 16:17:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHLfn015509 for ; Wed, 24 Feb 2021 11:17:21 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1E03460C5B; Wed, 24 Feb 2021 16:17:21 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7435360862 for ; Wed, 24 Feb 2021 16:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183469; 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=4BOtAzYFXHWQHLnL8CS0i3b4JKqv9WWzdUidvh1n/iI=; b=QBgI/oom8ZbgyMKV+OHKrufO1sXEnPrmGAie0B9Svtkv824pl7u4QbZk65S3kK651YaynI eCjt2i6SJdiQJkUur/XxaX5azJ/TXHU26v/sU68Y+jf9TxjuEXpG87cjlsCSfkeUka+aG6 J/srz5IsXoX4K9anhStg0E/FGavqPsg= X-MC-Unique: uEhDMoc_OWCi6PEOo5_Z4g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/33] virCommandAddArgBuffer: Simplify clearing of @buf Date: Wed, 24 Feb 2021 17:16:40 +0100 Message-Id: <52b31e32ead0db7353f5449edaafc6ca6c9be6af.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Get the buffer contents into a temporary variable with automatic clearing so that the error branches don't have to reset the buffer. Additionally handle the NULL string case before assignment. Signed-off-by: Peter Krempa --- src/util/vircommand.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index b94ab615d5..f11caf0d6e 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -1550,21 +1550,21 @@ virCommandAddArg(virCommandPtr cmd, const char *val) void virCommandAddArgBuffer(virCommandPtr cmd, virBufferPtr buf) { - if (!cmd || cmd->has_error) { - virBufferFreeAndReset(buf); + g_autofree char *str =3D virBufferContentAndReset(buf); + + if (!cmd || cmd->has_error) return; - } + + if (!str) + str =3D g_strdup(""); /* Arg plus trailing NULL. */ if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) { cmd->has_error =3D ENOMEM; - virBufferFreeAndReset(buf); return; } - cmd->args[cmd->nargs] =3D virBufferContentAndReset(buf); - if (!cmd->args[cmd->nargs]) - cmd->args[cmd->nargs] =3D g_strdup(""); + cmd->args[cmd->nargs] =3D g_steal_pointer(&str); cmd->nargs++; } --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183546; cv=none; d=zohomail.com; s=zohoarc; b=ZRaFjyHMTNvoa2+Qd3d6rkBv/ar53wYcO87l9PM2aI7VzFEKKIQxxvK48ZH+X1OP6wJPmx0NvrCZhfojuhK+0/ags+kV080EO7/I2W4RvKysE5GbRnUavGUmMI5mIcmx6DV8nAZb+QJ2CghdOwJws78TGX7u1enXFKPYfjySgx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183546; 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=L3zoSjQhvgHc/WYP1TGyK6mo6aPYu8+4AyvCAh0p6qA=; b=JYQCwOUA16bL6XsuZZr8VR74QMIEOt320zpyc68dnGBtFgfXWt2ri4G9YzfNcMuxH5gl56YiS8fpg5poZQUxdO7qUtAnExbcMvveBI+Yv2lf1YWYy2TSZ3MGHkiTYWOYF1LkK3Y4kGPCMRt7ToiL7fe76YfMi+HHSclQwf4guqw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183546163143.528212611674; Wed, 24 Feb 2021 08:19:06 -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-317-tJSp7CTCPyObyamvhpFMOQ-1; Wed, 24 Feb 2021 11:17:47 -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 0261418E6FD2; Wed, 24 Feb 2021 16:17:39 +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 D04672BFC7; Wed, 24 Feb 2021 16:17:38 +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 947415807D; Wed, 24 Feb 2021 16:17:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHRqZ015539 for ; Wed, 24 Feb 2021 11:17:27 -0500 Received: by smtp.corp.redhat.com (Postfix) id 68FE060862; Wed, 24 Feb 2021 16:17:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EA856E51F for ; Wed, 24 Feb 2021 16:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183545; 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=L3zoSjQhvgHc/WYP1TGyK6mo6aPYu8+4AyvCAh0p6qA=; b=Vp9CQaX0R3pqwnCbPONNnqpiVact82ZcJdsoEL9bHVvZKBCiYXPgmLbhwrm/4WVrXE3gNS gZktRPEYYAXQYf4kWvqezeAUTyFOfS/zS+7FJOZvjSY/DSqjNSFV4ZVB5eqI/hmJmWMfoH 0R5yYdBb0LWi7EbaOpnJoKg+RcPmtuI= X-MC-Unique: tJSp7CTCPyObyamvhpFMOQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/33] virCPUx86DataParse: Don't check error from x86FeatureNames Date: Wed, 24 Feb 2021 17:16:41 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" x86FeatureNames uses virBuffer and thus can't fail nowadays. Signed-off-by: Peter Krempa --- src/cpu/cpu_x86.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 92f945beb4..79c5868ae6 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1856,11 +1856,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) */ #define virX86CpuIncompatible(MSG, CPU_DEF) \ do { \ - g_autofree char *flagsStr =3D NULL; \ - if (!(flagsStr =3D x86FeatureNames(map, ", ", (CPU_DEF)))) { \ - virReportOOMError(); \ - return VIR_CPU_COMPARE_ERROR; \ - } \ + g_autofree char *flagsStr =3D x86FeatureNames(map, ", ", (CPU_= DEF)); \ if (message) \ *message =3D g_strdup_printf("%s: %s", _(MSG), flagsStr); \ VIR_DEBUG("%s: %s", MSG, flagsStr); \ --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183471; cv=none; d=zohomail.com; s=zohoarc; b=REk+zZ7Vh5MrsqQbOHibqJHZV8vTK8WjnQynPWS3uGZE1J7PRavyxUfk3onWk9ExRhelXS3Ak1O6ZkXT06B8QeR1AYNrXVvT0HdGlGsrAxHoyCa2IPO42HCKvgjZmLfa9r0OQbD658Q/sI0MPX6rxywUKRAsDJ1chHECLGQYSHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183471; 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=atIHgQedb9PfPp1506GH7QNziPVb9PuHBO4tEHSZlEs=; b=H+tA6ANzBqR1fih8OBrGsqj/e/76ureyTsn1fRt/iry0FGN4qN5ByA1w7MzOitxdWVZv7v03RZhVYyWrpWsJuvIG9wO5iHo8CwdwY4MDL5+DX7oXCohOBAU/Zg/A1u3kVXEtsP4jnw38GgW0nW0W4e30AXE2IJkAqKLL5DMGnBA= 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) 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 1614183471009400.5337915828717; Wed, 24 Feb 2021 08:17:51 -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-73-TkMmPbUrOfymu9_qLtPPZg-1; Wed, 24 Feb 2021 11:17:43 -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 A14F3804023; Wed, 24 Feb 2021 16:17:36 +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 79EE8100760C; Wed, 24 Feb 2021 16:17:36 +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 0D3AF1809C8F; Wed, 24 Feb 2021 16:17:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHSTj015548 for ; Wed, 24 Feb 2021 11:17:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E40A60C5B; Wed, 24 Feb 2021 16:17:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2A5F60862 for ; Wed, 24 Feb 2021 16:17:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183466; 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=atIHgQedb9PfPp1506GH7QNziPVb9PuHBO4tEHSZlEs=; b=ZAR8a7DIvyAOqwL+QbF0QWWfyu9KBDV1jUjYlWM7tiTI7/wZ7QrwTy+ucqE2VcHqla+sjG CeM++MGpxmwSS91gj/ZGO52c1UP0E8BkSOtqdfqc8EvPlZsvpmHStr4GYt374xnhLF8Vo9 oZiaEv6YK93p5YDtoQGwHZ3cW8c04YE= X-MC-Unique: TkMmPbUrOfymu9_qLtPPZg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/33] virhostcputest: linuxCPUStatsCompareFiles: Don't check return value of virBufferContentAndReset Date: Wed, 24 Feb 2021 17:16:42 +0100 Message-Id: <186d638243adeb8b3217e7dccf22b54f3156d29e.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The buffer won't encounter OOM condition nowadays Signed-off-by: Peter Krempa --- tests/virhostcputest.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index 786a363e48..2608f0becc 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -141,10 +141,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, goto fail; } - if (!(actualData =3D virBufferContentAndReset(&buf))) { - virReportOOMError(); - goto fail; - } + actualData =3D virBufferContentAndReset(&buf); if (virTestCompareToFile(actualData, outfile) < 0) goto fail; --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183474; cv=none; d=zohomail.com; s=zohoarc; b=gy2KDyUI++SWCCTnoOtf+L/bQvdYTcBSkU/YiY8JrAw9OERbeSB2CSHiTn7CxI5fOxYlKJr7Vb74wDSJ3iuBV2M4H13/cTXR3yEOnHWurHhtaH5i/foEoCWlheFGIhjBuQGZvRGX6NjmpXB9UH9nJKTFBYqqXJi6/RK0VUA7g9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183474; 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=kxnjZTHqbWGI776astVs1WbWZcQW1SVm+s3NVqJw0e4=; b=cGQvKT1LrDbAd4hyn4CHu04stCvNf2xCBlV/OPdlhhELvExx/knKxEiivJ+kX46fTeMYhio2VQlbJuuIcpHkdOIqSOELDcOzKnYeAtFA6fUsW0ILXHutjS0znCI03fgFAbrtvFcNZGeFl3mN3CjKY0GhAylJibQoRlstbLab6Xg= 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) 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 161418347424279.37783140577619; Wed, 24 Feb 2021 08:17: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-361-QAXrS-a2MNqtmI3J2eYJFA-1; Wed, 24 Feb 2021 11:17:48 -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 BA484801989; Wed, 24 Feb 2021 16:17:39 +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 9189E2BFC7; Wed, 24 Feb 2021 16:17:39 +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 26EA358080; Wed, 24 Feb 2021 16:17:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHWS6015566 for ; Wed, 24 Feb 2021 11:17:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7BE5C60CE7; Wed, 24 Feb 2021 16:17:32 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D141960D79 for ; Wed, 24 Feb 2021 16:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183471; 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=kxnjZTHqbWGI776astVs1WbWZcQW1SVm+s3NVqJw0e4=; b=Am7ROTgLB28u+yHLeFl4ZBBhVzbp2BUDQ4bbR3cPFHL1K1JU1DKTCasCZ8jvHamZAxMYS0 ah85GxhCXLXRNKssx3datFEqNbuhXtvJvIROANEaHsCu9Mavmvxhz1UTCwRB6PQseBUkoL brX4e+/f/1HrUvf8Dx8yQJE0iNdecRA= X-MC-Unique: QAXrS-a2MNqtmI3J2eYJFA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/33] virBuildPath: Remove return value Date: Wed, 24 Feb 2021 17:16:43 +0100 Message-Id: <82427e5ea3589d0ae519a4b06bb1e0decde01eee.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function can't fail nowadays, remove the return value and adjust callers. Signed-off-by: Peter Krempa --- docs/internals/command.html.in | 8 +------- src/util/virfcp.c | 3 +-- src/util/virfile.c | 7 +------ src/util/virfile.h | 2 +- src/util/virhook.c | 14 ++------------ src/util/virpci.c | 11 ++--------- 6 files changed, 8 insertions(+), 37 deletions(-) diff --git a/docs/internals/command.html.in b/docs/internals/command.html.in index 823d89cc71..634afdc937 100644 --- a/docs/internals/command.html.in +++ b/docs/internals/command.html.in @@ -568,13 +568,7 @@ int runhook(const char *drvstr, const char *id, char *path; virCommandPtr cmd; - ret =3D virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); - if ((ret < 0) || (path =3D=3D NULL)) { - virHookReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - drvstr); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); cmd =3D virCommandNew(path); VIR_FREE(path); diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 80773c7c5d..5e8fe72fec 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -40,8 +40,7 @@ virFCIsCapableRport(const char *rport) { g_autofree char *path =3D NULL; - if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) - return false; + virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport); return virFileExists(path); } diff --git a/src/util/virfile.c b/src/util/virfile.c index 5710495bbf..27a647d1d0 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1308,13 +1308,12 @@ virFileFindMountPoint(const char *type G_GNUC_UNUSE= D) #endif /* defined WITH_MNTENT_H && defined WITH_GETMNTENT_R */ -int +void virBuildPathInternal(char **path, ...) { char *path_component =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; va_list ap; - int ret =3D 0; va_start(ap, path); @@ -1329,10 +1328,6 @@ virBuildPathInternal(char **path, ...) va_end(ap); *path =3D virBufferContentAndReset(&buf); - if (*path =3D=3D NULL) - ret =3D -1; - - return ret; } /* Read no more than the specified maximum number of bytes. */ diff --git a/src/util/virfile.h b/src/util/virfile.h index 733d652ac9..f237e98290 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -300,7 +300,7 @@ char *virFileFindMountPoint(const char *type); /* NB: this should be combined with virFileBuildPath */ #define virBuildPath(path, ...) \ virBuildPathInternal(path, __VA_ARGS__, NULL) -int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; +void virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; typedef struct _virHugeTLBFS virHugeTLBFS; typedef virHugeTLBFS *virHugeTLBFSPtr; diff --git a/src/util/virhook.c b/src/util/virhook.c index e4e1945225..b52e2cd814 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -155,12 +155,7 @@ virHookCheck(int no, const char *driver) return -1; } - if (virBuildPath(&path, LIBVIRT_HOOK_DIR, driver) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - driver); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, driver); if (!virFileExists(path)) { VIR_DEBUG("No hook script %s", path); @@ -405,12 +400,7 @@ virHookCall(int driver, if (extra =3D=3D NULL) extra =3D "-"; - if (virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to build path for %s hook"), - drvstr); - return -1; - } + virBuildPath(&path, LIBVIRT_HOOK_DIR, drvstr); script_ret =3D 1; diff --git a/src/util/virpci.c b/src/util/virpci.c index 3df4199532..515b642db4 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2293,10 +2293,7 @@ virPCIGetPhysicalFunction(const char *vf_sysfs_path, *pf =3D NULL; - if (virBuildPath(&device_link, vf_sysfs_path, "physfn") =3D=3D -1) { - virReportOOMError(); - return -1; - } + virBuildPath(&device_link, vf_sysfs_path, "physfn"); if ((*pf =3D virPCIGetDeviceAddressFromSysfsLink(device_link))) { VIR_DEBUG("PF for VF device '%s': " VIR_PCI_DEVICE_ADDRESS_FMT, @@ -2470,11 +2467,7 @@ virPCIGetNetName(const char *device_link_sysfs_path, *netname =3D NULL; - if (virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, - "net") =3D=3D -1) { - virReportOOMError(); - return -1; - } + virBuildPath(&pcidev_sysfs_net_path, device_link_sysfs_path, "net"); if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0) { /* this *isn't* an error - caller needs to check for netname =3D= =3D NULL */ --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183472; cv=none; d=zohomail.com; s=zohoarc; b=US6MArJcwDIeWAC8QF55SN9An8DwpSzl5dXzVzPS9UUo7O4sfo1VFa7p0lJIRvYsoTVD6+V9MmXqDpJHMC3R1rEQri2SzCVT1dKA18fns8XSczJhkztqtwmFHKzTWHcev0fmNWU3XYyUztDd5t+Jn3831bTSggoZfzKJBPM7U7Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183472; 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=ytZMfDJyzuu1ti6Arf4DuQcrp3HigsQkSJ14XcLZKm4=; b=Gpfqq4Tk1ECBh61QQ1DI+ejIel7Z43NHPLRUUHoY4O8cEsL9G/t5d6MoNLg0mZ/khnKqhCLrsKNU5Q8A3Nhry21X73xLuSv0BBxvM5bKmryeKNBldMsVqIxnNxDDPzXHGjkZLRdzJyEbKzKqhSY2/RSMVLckWpeIUFWkJ46yKRw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183472874484.69407983410144; Wed, 24 Feb 2021 08:17:52 -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-346-r7VHClsLOJqB8R1H5EhHFQ-1; Wed, 24 Feb 2021 11:17:48 -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 3321F801978; Wed, 24 Feb 2021 16:17:42 +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 07F0010016F9; Wed, 24 Feb 2021 16:17:42 +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 BB4E718089D3; Wed, 24 Feb 2021 16:17:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHXn7015572 for ; Wed, 24 Feb 2021 11:17:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 8662460862; Wed, 24 Feb 2021 16:17:33 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7D4B60C5B for ; Wed, 24 Feb 2021 16:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183471; 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=ytZMfDJyzuu1ti6Arf4DuQcrp3HigsQkSJ14XcLZKm4=; b=cUfCZOQTHhEzkwIW7TSEcQiXt6nyAEjfLlA5xdb99Pwg2WCJUpG2RDmgDg0pGRFteGVEg7 /JZmq6NoUqmlN7BM7AozTdPyOQk3rKpx+KucaKZJcwinY9bknJ7TxD12eG4gjjMkBRGiSc nxaYK4Y/YDSAfnZM2enK+FNH6XXICfA= X-MC-Unique: r7VHClsLOJqB8R1H5EhHFQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/33] lxc_process: Remove OOM handling from logging setup Date: Wed, 24 Feb 2021 17:16:44 +0100 Message-Id: <2ae7e16c1607aa472cafe28ce51dba980ef6dcc8.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'virLogGetFilters' doesn't return failure and 'virLogGetOutputs' reports it's own errors. Signed-off-by: Peter Krempa --- src/lxc/lxc_process.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index cbc04a3dcd..679709605e 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -960,21 +960,14 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr drive= r, if (virLogGetNbFilters() > 0) { filterstr =3D virLogGetFilters(); - if (!filterstr) { - virReportOOMError(); - goto error; - } virCommandAddEnvPair(cmd, "LIBVIRT_LOG_FILTERS", filterstr); } if (cfg->log_libvirtd) { if (virLogGetNbOutputs() > 0) { - outputstr =3D virLogGetOutputs(); - if (!outputstr) { - virReportOOMError(); + if (!(outputstr =3D virLogGetOutputs())) goto error; - } virCommandAddEnvPair(cmd, "LIBVIRT_LOG_OUTPUTS", outputstr); } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183475; cv=none; d=zohomail.com; s=zohoarc; b=YnK0StLNtHVPzjqhwEoxLjT4X5dfTHGdqPEijMZNG7O6HYNvFpVRSuCJltVdTI/hjq0PgPiLhoJOc4cmEwa2J0y26adfzc8Cp1SSxUdKv5TCAi9wb/txvtdII0yRCd4iQqUnScSz4iF2ZYKg6FmVvJTlrogvgIuaBl4g/CwVnJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183475; 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=PuCx6MAkwE/Kjlujg66QrxH6oquR9HTseqkWP8tgfTU=; b=EyOQdo1xr1PqN+AUME4irWgdDavdY/l2kOCJIWaLsciIiMEiTG6ka9zvh8ULLk9YdL7YVeLAAEDyYaXBHDmeCQysDbEHvZIHvruNq9/FTTiWzzXSm+jgD0iHOsuXmuyn9NsDDgtLtFGJOMD3nXOQuqMygaqKoO4H9a5enPY+PsE= 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) 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 1614183475210436.97734510630676; Wed, 24 Feb 2021 08:17:55 -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-507-G7VpPMcsNfuBBozC-hqqKA-1; Wed, 24 Feb 2021 11:17:48 -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 097B980403D; Wed, 24 Feb 2021 16:17:42 +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 D867360C64; Wed, 24 Feb 2021 16:17:41 +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 997B018089D4; Wed, 24 Feb 2021 16:17:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHYtT015578 for ; Wed, 24 Feb 2021 11:17:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9FBD660CDE; Wed, 24 Feb 2021 16:17:34 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2A8A60862 for ; Wed, 24 Feb 2021 16:17:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183473; 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=PuCx6MAkwE/Kjlujg66QrxH6oquR9HTseqkWP8tgfTU=; b=L1ZxdObHdm6Z+abJxsGWgKoVbXqP5zZ4g/1TW9Ka7f/aF6TEW5xoDm3753hXcZN69SqqOT T8dqdnCgroQKWxC7wmWoJRi20ATliuw/HMq1cTuizIzG7FiFJh7u68C38lD6h3CZfxN8aC 5vZG9icixDoWhGIbuB0IDuKY80dfXzc= X-MC-Unique: G7VpPMcsNfuBBozC-hqqKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/33] virDomainDefSetMetadata: Rework memory handling Date: Wed, 24 Feb 2021 17:16:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Switch to use g_autoptr for 'doc' and 'new' local variables. Additionally report proper error when 'xmlAddChild' fails because OOM is not the only error it can report. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6f4487fcfc..46620d38ed 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30423,15 +30423,14 @@ virDomainDefSetMetadata(virDomainDefPtr def, const char *key, const char *uri) { - xmlDocPtr doc =3D NULL; + g_autoptr(xmlDoc) doc =3D NULL; xmlNodePtr old; - xmlNodePtr new =3D NULL; - int ret =3D -1; + g_autoptr(xmlNode) new =3D NULL; if (type >=3D VIR_DOMAIN_METADATA_LAST) { virReportError(VIR_ERR_INVALID_ARG, _("unknown metadata type '%d'"), type); - goto cleanup; + return -1; } switch ((virDomainMetadataType) type) { @@ -30451,23 +30450,24 @@ virDomainDefSetMetadata(virDomainDefPtr def, case VIR_DOMAIN_METADATA_ELEMENT: if (metadata) { + /* parse and modify the xml from the user */ if (!(doc =3D virXMLParseString(metadata, _("(metadata_xml)"))= )) - goto cleanup; + return -1; if (virXMLInjectNamespace(doc->children, uri, key) < 0) - goto cleanup; + return -1; /* create the root node if needed */ if (!def->metadata && !(def->metadata =3D xmlNewNode(NULL, (unsigned char *)"met= adata"))) { virReportOOMError(); - goto cleanup; + return -1; } if (!(new =3D xmlCopyNode(doc->children, 1))) { virReportOOMError(); - goto cleanup; + return -1; } } @@ -30477,11 +30477,13 @@ virDomainDefSetMetadata(virDomainDefPtr def, xmlFreeNode(old); } - if (new && - !(xmlAddChild(def->metadata, new))) { - xmlFreeNode(new); - virReportOOMError(); - goto cleanup; + if (new) { + if (!(xmlAddChild(def->metadata, new))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to add metadata to XML document")= ); + return -1; + } + new =3D NULL; } break; @@ -30490,11 +30492,7 @@ virDomainDefSetMetadata(virDomainDefPtr def, break; } - ret =3D 0; - - cleanup: - xmlFreeDoc(doc); - return ret; + return 0; } --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183557; cv=none; d=zohomail.com; s=zohoarc; b=aigAAuAJq1LFOhBHuPeEVAYOIBml7gPICx7CJL5WJo0VL/ombv7zQBVi5jB3sccKVHIstGvZsg37Rce/HWYeHI5NZz1+h3HPWG/7S/ZE0dNnePI1Ms30vrpeRXA3t2c2y1ieZUKSiI4ND15l4uA71SaPnOXIQcSJfW1+oVZxRAI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183557; 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=GPKj8xOdZPrT9sumfT9WwYlFuiELpFyBZ8SMP5jMCf0=; b=NC1kQot6iLHQPEgFNWexSOdvk0QUof8J9/r58+wgA8lk1OAiKbPxmcDELzshqsHWO49CIe8DHWlZ8sC8fJcgDJPz1m03zQ16+AxHrJGEj3edtl8jldkgBD8PtPp20LREsHFgYDp8FU85361xz7ymX8UtmBW4YiHFHOKm2d/WKS8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183557903377.16611465298035; Wed, 24 Feb 2021 08:19:17 -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-140-drTkKLXMOkq_DgOUj-F3iA-1; Wed, 24 Feb 2021 11:17:55 -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 4BCD25074D; Wed, 24 Feb 2021 16:17: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 2797160C64; Wed, 24 Feb 2021 16:17:45 +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 BCC1B58079; Wed, 24 Feb 2021 16:17:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHZo6015583 for ; Wed, 24 Feb 2021 11:17:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id A957460862; Wed, 24 Feb 2021 16:17:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1607460D79 for ; Wed, 24 Feb 2021 16:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183556; 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=GPKj8xOdZPrT9sumfT9WwYlFuiELpFyBZ8SMP5jMCf0=; b=Wi4o3kTw+Fb4PFK1j31+uYPY0V2S9bjJaapKkYuvheuvgVmEWCiMER6+Q9YdcDIAw1OFnw yojcBQtvP1eEnCvlUCRQl7zamV2t4JTdy1R1Kq8+UM61MgJwFU2vhLS1ixXy6ZuxgoPqC4 gZAy10TLFbr4yUioc626aVW7hwzoNPY= X-MC-Unique: drTkKLXMOkq_DgOUj-F3iA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/33] util: vircommand: Remove OOM handling Date: Wed, 24 Feb 2021 17:16:46 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.12 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The OOM error handling is dead code nowadays. Signed-off-by: Peter Krempa --- src/util/vircommand.c | 96 +++++++++---------------------------------- 1 file changed, 20 insertions(+), 76 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index f11caf0d6e..1a4b77ea24 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -90,7 +90,7 @@ struct _virCommandSendBuffer { }; struct _virCommand { - int has_error; /* ENOMEM on allocation failure, -1 for anything else. = */ + int has_error; /* 0 on success, -1 on error */ char **args; size_t nargs; @@ -198,7 +198,6 @@ virCommandFDIsSet(virCommandPtr cmd, * * Returns: 0 on success, * -1 on usage error, - * ENOMEM on OOM */ static int virCommandFDSet(virCommandPtr cmd, @@ -211,8 +210,7 @@ virCommandFDSet(virCommandPtr cmd, if (virCommandFDIsSet(cmd, fd)) return 0; - if (VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1) < 0) - return ENOMEM; + ignore_value(VIR_EXPAND_N(cmd->passfd, cmd->npassfd, 1)); cmd->passfd[cmd->npassfd - 1].fd =3D fd; cmd->passfd[cmd->npassfd - 1].flags =3D flags; @@ -1344,10 +1342,7 @@ virCommandAddEnv(virCommandPtr cmd, } /* Arg plus trailing NULL. */ - if (VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 1 + 1)); cmd->env[cmd->nenv++] =3D g_steal_pointer(&env); } @@ -1474,10 +1469,7 @@ virCommandAddEnvPassCommon(virCommandPtr cmd) if (!cmd || cmd->has_error) return; - if (VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 9)); virCommandAddEnvPair(cmd, "LC_ALL", "C"); @@ -1497,10 +1489,7 @@ virCommandAddEnvXDG(virCommandPtr cmd, const char *b= aseDir) if (!cmd || cmd->has_error) return; - if (VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 3) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->env, cmd->maxenv, cmd->nenv, 3)); virCommandAddEnvFormat(cmd, "XDG_DATA_HOME=3D%s/%s", baseDir, ".local/share"); @@ -1530,10 +1519,7 @@ virCommandAddArg(virCommandPtr cmd, const char *val) } /* Arg plus trailing NULL. */ - if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1)); cmd->args[cmd->nargs++] =3D g_strdup(val); } @@ -1559,10 +1545,7 @@ virCommandAddArgBuffer(virCommandPtr cmd, virBufferP= tr buf) str =3D g_strdup(""); /* Arg plus trailing NULL. */ - if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1)); cmd->args[cmd->nargs] =3D g_steal_pointer(&str); cmd->nargs++; @@ -1591,11 +1574,7 @@ virCommandAddArgFormat(virCommandPtr cmd, const char= *format, ...) va_end(list); /* Arg plus trailing NULL. */ - if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) { - VIR_FREE(arg); - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1)); cmd->args[cmd->nargs++] =3D arg; } @@ -1642,10 +1621,7 @@ virCommandAddArgSet(virCommandPtr cmd, const char *c= onst*vals) narg++; /* narg plus trailing NULL. */ - if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + = 1)); narg =3D 0; while (vals[narg] !=3D NULL) { @@ -1678,10 +1654,7 @@ virCommandAddArgList(virCommandPtr cmd, ...) va_end(list); /* narg plus trailing NULL. */ - if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + 1) < 0) { - cmd->has_error =3D ENOMEM; - return; - } + ignore_value(VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, narg + = 1)); va_start(list, cmd); while (1) { @@ -1765,10 +1738,7 @@ virCommandSetSendBuffer(virCommandPtr cmd, } i =3D virCommandGetNumSendBuffers(cmd); - if (VIR_REALLOC_N(cmd->sendBuffers, i + 1) < 0) { - cmd->has_error =3D ENOMEM; - return -1; - } + ignore_value(VIR_REALLOC_N(cmd->sendBuffers, i + 1)); cmd->sendBuffers[i].fd =3D fd; cmd->sendBuffers[i].buffer =3D buffer; @@ -2099,11 +2069,7 @@ virCommandToString(virCommandPtr cmd, bool linebreak= s) /* Cannot assume virCommandRun will be called; so report the error * now. If virCommandRun is called, it will report the same error. */ - if (!cmd ||cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return NULL; - } - if (cmd->has_error) { + if (!cmd || cmd->has_error) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return NULL; @@ -2339,11 +2305,7 @@ virCommandProcessIO(virCommandPtr cmd) */ int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups) { - if (!cmd ||cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } - if (cmd->has_error) { + if (!cmd || cmd->has_error) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return -1; @@ -2388,11 +2350,7 @@ virCommandRun(virCommandPtr cmd, int *exitstatus) char *str; int tmpfd; - if (!cmd ||cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } - if (cmd->has_error) { + if (!cmd || cmd->has_error) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return -1; @@ -2539,11 +2497,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) bool synchronous =3D false; int infd[2] =3D {-1, -1}; - if (!cmd || cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } - if (cmd->has_error) { + if (!cmd || cmd->has_error) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return -1; @@ -2692,11 +2646,7 @@ virCommandWait(virCommandPtr cmd, int *exitstatus) int ret; int status =3D 0; - if (!cmd ||cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } - if (cmd->has_error) { + if (!cmd || cmd->has_error) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return -1; @@ -2835,11 +2785,8 @@ int virCommandHandshakeWait(virCommandPtr cmd) { char c; int rv; - if (!cmd ||cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } - if (cmd->has_error || !cmd->handshake) { + + if (!cmd || cmd->has_error || !cmd->handshake) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return -1; @@ -2896,11 +2843,8 @@ int virCommandHandshakeWait(virCommandPtr cmd) int virCommandHandshakeNotify(virCommandPtr cmd) { char c =3D '1'; - if (!cmd ||cmd->has_error =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } - if (cmd->has_error || !cmd->handshake) { + + if (!cmd || cmd->has_error || !cmd->handshake) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid use of command API")); return -1; --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183547; cv=none; d=zohomail.com; s=zohoarc; b=NX9LyJDrIDAwjcDKt3C94V1eosw8nq0unpf4om3D8KUT1cmU1MklVGlFAM5gU9q3b5aTFW0Fi6Q92r/52YdYDuQaWy+fnQOqk0YymThoSMr69YqZnP6rvZIZI6z3ucwuOHg544yH3N+fpJj43gRL+2PMF4g3GlASl4JKNrN/icc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183547; 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=4El3SqSm5Av3Ak5sixB15HYVMVD2MU2nofM72VB9WHA=; b=GGmoZ8kttMMNeHdfF5+eBHNIYWragEMaDKQH0LA+/mQxv+Fk9pIq0JzM7Xi1acEuhMkIoz4hmf4kDF31g9yCYXHJ938wjuTI+ouMblnX1VccyO3ptFudt06yP2JY2tmJMd809DLztl+oAOtdgCR2lb3knATf/W9A0YoF4ZpA7SE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183547657586.3144315823944; Wed, 24 Feb 2021 08:19:07 -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-326-R4iv77z_Np-mncfZTVdS6Q-1; Wed, 24 Feb 2021 11:17:52 -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 5B638804023; Wed, 24 Feb 2021 16:17: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 2D49410021AA; Wed, 24 Feb 2021 16:17:45 +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 BE1815807A; Wed, 24 Feb 2021 16:17:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHauY015590 for ; Wed, 24 Feb 2021 11:17:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id C5FEA60C5B; Wed, 24 Feb 2021 16:17:36 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21E0760862 for ; Wed, 24 Feb 2021 16:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183546; 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=4El3SqSm5Av3Ak5sixB15HYVMVD2MU2nofM72VB9WHA=; b=TOgi0ERW8TUqSJPN403Xt2J/d8qNKtRQsyb6g4htfjdQterA1iYGPESfumQ6G+q6qCH/Pu uJ/Aa6o2kUFo5jqYxRUhEQ6/XvgGdsjzVWmrxxE+WTt1SUDYtUHbKssxHj6s6JgSOrcdjI GdThChJE4JHggQPIh0xB3EjLBbSzxsk= X-MC-Unique: R4iv77z_Np-mncfZTVdS6Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/33] virCloseCallbacksGetForConn: Remove OOM handling Date: Wed, 24 Feb 2021 17:16:47 +0100 Message-Id: <79a384a54931ecaf830d9c126691311f514f5e2c.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" VIR_EXPAND_N will abort so we can simplify the hash iterator. Signed-off-by: Peter Krempa --- src/hypervisor/virclosecallbacks.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index 2641f45a22..1fd4dd7adf 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -241,7 +241,6 @@ struct _virCloseCallbacksList { struct virCloseCallbacksData { virConnectPtr conn; virCloseCallbacksListPtr list; - bool oom; }; static int @@ -263,11 +262,7 @@ virCloseCallbacksGetOne(void *payload, if (data->conn !=3D closeDef->conn || !closeDef->cb) return 0; - if (VIR_EXPAND_N(data->list->entries, - data->list->nentries, 1) < 0) { - data->oom =3D true; - return 0; - } + ignore_value(VIR_EXPAND_N(data->list->entries, data->list->nentries, 1= )); memcpy(data->list->entries[data->list->nentries - 1].uuid, uuid, VIR_UUID_BUFLEN); @@ -286,17 +281,9 @@ virCloseCallbacksGetForConn(virCloseCallbacksPtr close= Callbacks, data.conn =3D conn; data.list =3D list; - data.oom =3D false; virHashForEach(closeCallbacks->list, virCloseCallbacksGetOne, &data); - if (data.oom) { - VIR_FREE(list->entries); - VIR_FREE(list); - virReportOOMError(); - return NULL; - } - return list; } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183489; cv=none; d=zohomail.com; s=zohoarc; b=F1excHjR5oOchfmeYArlyenbPGGcb86zOZRdgxLgkmvy0M5BL6wI0hOALdY13kKZvh/0aNQfDAg0PLawq742IuFxaVg5Nd/JCGisgY9H1M7CMDTY9xBLxDKLSjNuviPU6Rx7ho/qCdn9joygmg16Y839mrbzfzj0hxtnKjfBCqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183489; 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=79hjKsOi+VnJDt2Suutsm2CwSobl7ssr6Sy2TYvO+ys=; b=HSTArh7Dp9v4n+9EbrcgE8uqDusNTtcvzM7njpy56g9kZBQiWKuZm6F16hkpCkqrSfmaNvQcyRLrkUotgcLCpOPcOQAJSM1JQiFe8xJylMFZBfjM5NzSjaJLmJjjsDs/85GC2ZK0FoSBFfLHzEyH9KKaYTZuHRuwoc/xbTgQ/aI= 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) 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 1614183489703565.9932646810231; Wed, 24 Feb 2021 08:18:09 -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-408-wRIebOspOOKk9NMG7-0nlg-1; Wed, 24 Feb 2021 11:17:50 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A64E018E6FD6; Wed, 24 Feb 2021 16:17:42 +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 7E07A5C22B; Wed, 24 Feb 2021 16:17:42 +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 43E1858085; Wed, 24 Feb 2021 16:17:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHbxO015600 for ; Wed, 24 Feb 2021 11:17:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id D05FA60862; Wed, 24 Feb 2021 16:17:37 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DC2E60D79 for ; Wed, 24 Feb 2021 16:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183488; 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=79hjKsOi+VnJDt2Suutsm2CwSobl7ssr6Sy2TYvO+ys=; b=WJblVfSwa6fQ2b19Www4Yy+q6Wktm+qm19sBog90ljrBvb0v1m9/IraD6kRCywI8g7iUUH 894JNQvuyadnkNmgj/g9ffSsur+Jp6yfNRuX+9wqXXjw0q6oJDIw13HAumK2cMJqcW3BKg gHoAElQOgUkqwlCM6XETmTzIyuKgKus= X-MC-Unique: wRIebOspOOKk9NMG7-0nlg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/33] virfirewall: Don't check OOM in ADD_ARG macro Date: Wed, 24 Feb 2021 17:16:48 +0100 Message-Id: <4f58c38a18f756f120ba3fd21bffe8cac3d8544b.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" VIR_RESIZE_N can't fail nowadays, adjust the macro. Signed-off-by: Peter Krempa --- src/util/virfirewall.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 6b04a8011f..95962568f5 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -262,10 +262,9 @@ void virFirewallFree(virFirewallPtr firewall) #define ADD_ARG(rule, str) \ do { \ - if (VIR_RESIZE_N(rule->args, \ - rule->argsAlloc, \ - rule->argsLen, 1) < 0) \ - goto no_memory; \ + ignore_value(VIR_RESIZE_N(rule->args, \ + rule->argsAlloc, \ + rule->argsLen, 1)); \ \ rule->args[rule->argsLen++] =3D g_strdup(str); \ } while (0) @@ -433,9 +432,6 @@ void virFirewallRuleAddArg(virFirewallPtr firewall, ADD_ARG(rule, arg); return; - - no_memory: - firewall->err =3D ENOMEM; } @@ -455,9 +451,6 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewal= l, ADD_ARG(rule, arg); return; - - no_memory: - firewall->err =3D ENOMEM; } @@ -473,9 +466,6 @@ void virFirewallRuleAddArgSet(virFirewallPtr firewall, } return; - - no_memory: - firewall->err =3D ENOMEM; } @@ -496,10 +486,6 @@ void virFirewallRuleAddArgList(virFirewallPtr firewall, va_end(list); return; - - no_memory: - firewall->err =3D ENOMEM; - va_end(list); } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183657; cv=none; d=zohomail.com; s=zohoarc; b=hKz1AjFn0xyCAvLFgVhh1O6UbGqEtsYxLCsLHQJK5eNT7UFiuOCoCPWqTNpUDD37JKxU3CfAGq0HjMf50p4iGtX2ARfWT22eS+2mNRz8tahIrLJxP6uKKmNdgJZgMFHW0Lk0dsnMOsRqqFe0ufWFaooShtN68cK6wDDyW16WNT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183657; 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=OX37VHH8nMAXILwQuIv4/9nPzgPOlazKoLXR8RZfMg0=; b=N9cI9M9E+H8HsbJDVtoLx8NM8HXdAaVUBFbSyoRz34iYpOmXQKEZTdOabrbiQdEbE+cslNIo5aXUYwjljBEx0XlY90VHtagJNyX0yuG7fjt8uOX3mp0hGUdyJfUs0QIQphQOAwV16hg4hYc+dnkmaukltiSicHNkZbBwHAGbKRw= 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) 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 1614183657567636.2010314824519; Wed, 24 Feb 2021 08:20:57 -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-151-icClYHayNXG5hia18ISJag-1; Wed, 24 Feb 2021 11:17:56 -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 7043150757; Wed, 24 Feb 2021 16:17: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 4AD872BFE2; Wed, 24 Feb 2021 16:17:48 +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 CE6B818077BA; Wed, 24 Feb 2021 16:17:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHcCI015606 for ; Wed, 24 Feb 2021 11:17:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id EB30B6E505; Wed, 24 Feb 2021 16:17:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4403C646DC for ; Wed, 24 Feb 2021 16:17:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183654; 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=OX37VHH8nMAXILwQuIv4/9nPzgPOlazKoLXR8RZfMg0=; b=MIrICaUsZUKewj5P2eLp5Rp+WL0B53ltZy/CGGTsOmTFMACjoA6mm4/PQdlkTiSbZJ0Gjc zX+QisO3oGPGca2VFo5Uf/JfbgjNrw0i286d1ZAASDACrKqjz3DXqs1lu6FAE/t/BEWfrC IEOLz1V8z88tW61y+PBINSsTLTqW+D0= X-MC-Unique: icClYHayNXG5hia18ISJag-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/33] virfirewall: Remove OOM checks from virFirewallStartTransaction Date: Wed, 24 Feb 2021 17:16:49 +0100 Message-Id: <97ff114fd37f1244777871cd85debed20e4ab4f6.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Neither virFirewallGroupNew nor VIR_EXPAND_N can fail. Signed-off-by: Peter Krempa --- src/util/virfirewall.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 95962568f5..66b33d4a91 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -517,18 +517,11 @@ void virFirewallStartTransaction(virFirewallPtr firew= all, VIR_FIREWALL_RETURN_IF_ERROR(firewall); - if (!(group =3D virFirewallGroupNew())) { - firewall->err =3D ENOMEM; - return; - } + group =3D virFirewallGroupNew(); group->actionFlags =3D flags; - if (VIR_EXPAND_N(firewall->groups, - firewall->ngroups, 1) < 0) { - firewall->err =3D ENOMEM; - virFirewallGroupFree(group); - return; - } + ignore_value(VIR_EXPAND_N(firewall->groups, + firewall->ngroups, 1)); firewall->groups[firewall->ngroups - 1] =3D group; firewall->currentGroup =3D firewall->ngroups - 1; } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183481; cv=none; d=zohomail.com; s=zohoarc; b=e3ixQGyBV9+j+PyXq9a0APS08WOrRA4eBtdYcRGNGtbccE0IA7mW6J6/Mf57Ivl1RmEg+MhHym5Uhw4Udm5ZludhTz0RRRenzCm8ZmO1R/QL6G8KWSVGUFxcLBZgpgSaOt49ctV3Eea2LKk4k+wn2YM86nMEuz0CeK6XHgeICVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183481; 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=6OLELgCBbx0MvyxprO7l4MOXZLN8ytO8CYQjUGlTWtE=; b=JYHhmRnWSWgc2ltIoau0YivJZ0BdnaUR3Hh78bB0+Z4pJojRyc8hSOaeDPxAPbBSu8KKeGNo/DyJ7PP1EOktz1NgK+yry0gixHMDlpduKRQA6UZGFUOEZq9gQEPW3TP6bHSycIU7mgpSsZ5O2faZIzw1FFZ850im4oLUnxBqCcE= 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) 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 1614183481538499.8574897414604; Wed, 24 Feb 2021 08:18: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-13-L60UiHQKMBipcwynOcSq6Q-1; Wed, 24 Feb 2021 11:17:57 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 474C050750; Wed, 24 Feb 2021 16:17:48 +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 1EB361803D; Wed, 24 Feb 2021 16:17:48 +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 D28CF58087; Wed, 24 Feb 2021 16:17:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHeHO015616 for ; Wed, 24 Feb 2021 11:17:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 04A6B60C5B; Wed, 24 Feb 2021 16:17:40 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6437C60862 for ; Wed, 24 Feb 2021 16:17:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183480; 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=6OLELgCBbx0MvyxprO7l4MOXZLN8ytO8CYQjUGlTWtE=; b=berik1PRSqgJjmORHYIR+vGvnuXl1W1L3kVOesDqwK+gFSGUVh77zZBQcHmwe+gChqdCQB EhrVpXbuJzcUzxr0CpDl0lWqpSbq6se0TuaPski6v4JxKYKwsA082ypHE40Vspv7mNZP6+ WuISmZXGT9xvlp0MDheX9SWGY3tI6VQ= X-MC-Unique: L60UiHQKMBipcwynOcSq6Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/33] virfirewall: virFirewallAddRuleFullV: Remove OOM check from VIR_APPEND_ELEMENT Date: Wed, 24 Feb 2021 17:16:50 +0100 Message-Id: <2b90f103517e856b10b19cf7efe6c9dbf580f82f.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" VIR_APPEND_ELEMENT_COPY will abort the program on OOM so there's no need to check. Signed-off-by: Peter Krempa --- src/util/virfirewall.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 66b33d4a91..bbeb87e72d 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -315,24 +315,17 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, ADD_ARG(rule, str); if (group->addingRollback) { - if (VIR_APPEND_ELEMENT_COPY(group->rollback, - group->nrollback, - rule) < 0) - goto no_memory; + ignore_value(VIR_APPEND_ELEMENT_COPY(group->rollback, + group->nrollback, + rule)); } else { - if (VIR_APPEND_ELEMENT_COPY(group->action, - group->naction, - rule) < 0) - goto no_memory; + ignore_value(VIR_APPEND_ELEMENT_COPY(group->action, + group->naction, + rule)); } return rule; - - no_memory: - firewall->err =3D ENOMEM; - virFirewallRuleFree(rule); - return NULL; } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183482; cv=none; d=zohomail.com; s=zohoarc; b=K/zDSiRk/TZWnsF4zZBftc8xedPc1M/CvWJ43AASpoLP9LmNzlcdMx4LVKB3rVPSOEFkzm6E3KzBtdINkbf3vLSqBLggAIdfBxqUNOeMz9/DYfxKKtOMn8ccRkTl7gE6XVFz40pzeSwIPAaifcVn4YCtfHyNGyOF18vNgEuPk7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183482; 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=6mFa5IpS5tbVpsUGto47sHsGxCUji21+2Pua1jodiec=; b=ijj5UKAGLSOhzqVG0gAl+rP+izzwCH6z9uCSjsbtB+CV4BOTtDOFLu9mgRvyCZx9eP8GvT2na1rsgPwHh7bITfAU3hN4wKXUfp/nzc+WHRkK2Caw00ASJJT+Of9L8BbmcLjBtqILI9zmRZzrXAMn1PiDyaTonxYhsQ+oTWJ2x8Y= 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) 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 1614183482993380.0731414689993; Wed, 24 Feb 2021 08:18:02 -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-353-ayY4IEpNMsW7fGYah0GZKA-1; Wed, 24 Feb 2021 11:17:58 -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 787F8100CC8E; Wed, 24 Feb 2021 16:17:51 +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 513084F3C6; Wed, 24 Feb 2021 16:17:51 +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 13F5658085; Wed, 24 Feb 2021 16:17:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHfNR015625 for ; Wed, 24 Feb 2021 11:17:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2104760862; Wed, 24 Feb 2021 16:17:41 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73C0A60D79 for ; Wed, 24 Feb 2021 16:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183481; 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=6mFa5IpS5tbVpsUGto47sHsGxCUji21+2Pua1jodiec=; b=Z6QfScbXo2Djq2g0ZMfilgeBN3s6px3jqj6oWP2uCPk5BHZvXooQH3PqbIx0SEXGwysW36 vD3Dcsb5PHOs3Fm9pbvxigjFw2yzw1P363ec0kbEKU0H+JG22Rm608eFLrrSV51jPd6+sW RXwfN7B3u7NFrI/9Hq3O+AkCGJccxLM= X-MC-Unique: ayY4IEpNMsW7fGYah0GZKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/33] virfirewall: Remove impossible OOM error reporting Date: Wed, 24 Feb 2021 17:16:51 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There's nothing that would set the 'err' field of virFirewallPtr to ENOMEM so we can remove the checks. Signed-off-by: Peter Krempa --- src/util/virfirewall.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index bbeb87e72d..c1b7d2268b 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -698,10 +698,6 @@ virFirewallApplyRule(virFirewallPtr firewall, if (rule->queryCB(firewall, rule->layer, (const char *const *)line= s, rule->queryOpaque) < 0) return -1; - if (firewall->err =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } if (firewall->err) { virReportSystemError(firewall->err, "%s", _("Unable to create rule")); @@ -769,11 +765,7 @@ virFirewallApply(virFirewallPtr firewall) _("Failed to initialize a valid firewall backend")); goto cleanup; } - if (!firewall || firewall->err =3D=3D ENOMEM) { - virReportOOMError(); - goto cleanup; - } - if (firewall->err) { + if (!firewall || firewall->err) { virReportSystemError(firewall->err, "%s", _("Unable to create rule")); goto cleanup; --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183488; cv=none; d=zohomail.com; s=zohoarc; b=EkcCQIgkTCtqmzPtUyGNB7BQ32E/cxUIklHW7GUvT10L55qWcC6K6owajuaGtRoMMUNDzWMt7PLQtasP9I/eBo07qmZgVHSifErmUMbGr9TuxMDlo+PiVB/0s0rcl2joaHpzxk/WA74syM50IJEHTkxrCTKcIFIz70nm58zQTGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183488; 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=BYTdrrQwyYQh6WF/vBLFzBAdZ++unwyjietnYuqVDr4=; b=hJgx1RukJgyRYq/kPV7WAzbR5LHRE4+pH5q//rcCl90GrxKAGK4aH/9BSQnSV/Hs5cF47lc7UaDr2BAbjK597JrBwxNkQwMcMQ2HvjEZ7F/KvoetF52k5skZq/w48HNLxgbN2ek41ZhLq3BVxqP130GSc6LJV+o89U5wf1YOpdE= 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) 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 161418348855397.71144190832115; Wed, 24 Feb 2021 08:18:08 -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-91-UbIsLwOnMoe5hM5JgzHFsQ-1; Wed, 24 Feb 2021 11:18:03 -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 956EF5076A; Wed, 24 Feb 2021 16:17:54 +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 6E0DE50B44; Wed, 24 Feb 2021 16:17:54 +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 34C8318077CD; Wed, 24 Feb 2021 16:17:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHgja015631 for ; Wed, 24 Feb 2021 11:17:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2B8F660862; Wed, 24 Feb 2021 16:17:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CA0A646DC for ; Wed, 24 Feb 2021 16:17:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183486; 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=BYTdrrQwyYQh6WF/vBLFzBAdZ++unwyjietnYuqVDr4=; b=hlXED6btxBVyJ84/qbdeS4q8Bl8S/EWw2++Ov1PRKEglayyGinhQ7c0l1LMkTi1bj7Jj/w McqhtRYqZwC7i6BpOfgoDvIasrQRc0SXUnyhXJYRDIOjUAy8FtQIxTzjiaZBKlZygxwmMY GEipD8VV0KrEj/vqxHLqpiooBwcyyFY= X-MC-Unique: UbIsLwOnMoe5hM5JgzHFsQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/33] util: virnetlink: Add wrapper for 'nlmsg_alloc_simple' Date: Wed, 24 Feb 2021 17:16:52 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function is used in many places and fails only on allocation failures. Since trying to recover from allocation failure of a small buffer by reporting error doesn't make sense add a wrapper for 'nlmsg_alloc_simple' which will 'abort()' on failure and replace all allocations of netlink message with the new helper. Signed-off-by: Peter Krempa --- src/util/virnetdev.c | 18 +++------------ src/util/virnetdevbridge.c | 10 +++------ src/util/virnetdevip.c | 15 ++++--------- src/util/virnetdevvportprofile.c | 6 +---- src/util/virnetlink.c | 38 ++++++++++++++------------------ src/util/virnetlink.h | 4 ++++ 6 files changed, 32 insertions(+), 59 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 2b4c8b6280..d0c76ce26c 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -1596,11 +1596,7 @@ virNetDevSetVfConfig(const char *ifname, int vf, if (!macaddr && vlanid < 0) return -1; - nl_msg =3D nlmsg_alloc_simple(RTM_SETLINK, NLM_F_REQUEST); - if (!nl_msg) { - virReportOOMError(); - return rc; - } + nl_msg =3D virNetlinkMsgNew(RTM_SETLINK, NLM_F_REQUEST); if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) < 0) goto buffer_too_small; @@ -3132,11 +3128,7 @@ virNetDevGetFamilyId(const char *family_name, unsigned int recvbuflen; int ret =3D -1; - if (!(nl_msg =3D nlmsg_alloc_simple(GENL_ID_CTRL, - NLM_F_REQUEST | NLM_F_ACK))) { - virReportOOMError(); - goto cleanup; - } + nl_msg =3D virNetlinkMsgNew(GENL_ID_CTRL, NLM_F_REQUEST | NLM_F_ACK); if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0) goto cleanup; @@ -3220,11 +3212,7 @@ virNetDevSwitchdevFeature(const char *ifname, if ((rv =3D virNetDevGetFamilyId(DEVLINK_GENL_NAME, &family_id)) <=3D = 0) return rv; - if (!(nl_msg =3D nlmsg_alloc_simple(family_id, - NLM_F_REQUEST | NLM_F_ACK))) { - virReportOOMError(); - goto cleanup; - } + nl_msg =3D virNetlinkMsgNew(family_id, NLM_F_REQUEST | NLM_F_ACK); if (nlmsg_append(nl_msg, &gmsgh, sizeof(gmsgh), NLMSG_ALIGNTO) < 0) goto cleanup; diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index d475e4c43d..7b5ea4fe1d 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -1036,13 +1036,9 @@ virNetDevBridgeFDBAddDel(const virMacAddr *mac, cons= t char *ifname, if (!(ndm.ndm_state & (NUD_PERMANENT | NUD_REACHABLE))) ndm.ndm_state |=3D NUD_PERMANENT; - nl_msg =3D nlmsg_alloc_simple(isAdd ? RTM_NEWNEIGH : RTM_DELNEIGH, - NLM_F_REQUEST | - (isAdd ? (NLM_F_CREATE | NLM_F_EXCL) : 0)); - if (!nl_msg) { - virReportOOMError(); - return -1; - } + nl_msg =3D virNetlinkMsgNew(isAdd ? RTM_NEWNEIGH : RTM_DELNEIGH, + NLM_F_REQUEST | + (isAdd ? (NLM_F_CREATE | NLM_F_EXCL) : 0)); if (nlmsg_append(nl_msg, &ndm, sizeof(ndm), NLMSG_ALIGNTO) < 0) goto buffer_too_small; diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c index 4eb8ef76d1..83da7bc46d 100644 --- a/src/util/virnetdevip.c +++ b/src/util/virnetdevip.c @@ -107,11 +107,8 @@ virNetDevCreateNetlinkAddressMessage(int messageType, if ((ifindex =3D if_nametoindex(ifname)) =3D=3D 0) return NULL; - if (!(nlmsg =3D nlmsg_alloc_simple(messageType, - NLM_F_REQUEST | NLM_F_CREATE | NLM_F_= EXCL))) { - virReportOOMError(); - return NULL; - } + nlmsg =3D virNetlinkMsgNew(messageType, + NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); memset(&ifa, 0, sizeof(ifa)); @@ -323,12 +320,8 @@ virNetDevIPRouteAdd(const char *ifname, if ((ifindex =3D if_nametoindex(ifname)) =3D=3D 0) return -1; - if (!(nlmsg =3D nlmsg_alloc_simple(RTM_NEWROUTE, - NLM_F_REQUEST | NLM_F_CREATE | - NLM_F_EXCL))) { - virReportOOMError(); - return -1; - } + nlmsg =3D virNetlinkMsgNew(RTM_NEWROUTE, + NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); memset(&rtmsg, 0, sizeof(rtmsg)); diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index 5d6c055b32..c0fc04c699 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -689,11 +689,7 @@ virNetDevVPortProfileOpSetLink(const char *ifname, int= ifindex, ? virUUIDFormat(hostUUID, hostUUIDStr) : "(unspecified)")); - nl_msg =3D nlmsg_alloc_simple(RTM_SETLINK, NLM_F_REQUEST); - if (!nl_msg) { - virReportOOMError(); - return rc; - } + nl_msg =3D virNetlinkMsgNew(RTM_SETLINK, NLM_F_REQUEST); if (nlmsg_append(nl_msg, &ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO) < 0) goto buffer_too_small; diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index 9bd7339054..a06195bd00 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -133,6 +133,18 @@ static virNetlinkHandle *placeholder_nlhandle; /* Function definitions */ +struct nl_msg * +virNetlinkMsgNew(int nlmsgtype, + int nlmsgflags) +{ + struct nl_msg *ret; + + if (!(ret =3D nlmsg_alloc_simple(nlmsgtype, nlmsgflags))) + abort(); + + return ret; +} + /** * virNetlinkStartup: * @@ -511,11 +523,7 @@ virNetlinkDumpLink(const char *ifname, int ifindex, ifinfo.ifi_index =3D ifindex; - nl_msg =3D nlmsg_alloc_simple(RTM_GETLINK, NLM_F_REQUEST); - if (!nl_msg) { - virReportOOMError(); - return -1; - } + nl_msg =3D virNetlinkMsgNew(RTM_GETLINK, NLM_F_REQUEST); NETLINK_MSG_APPEND(nl_msg, sizeof(ifinfo), &ifinfo); @@ -595,12 +603,8 @@ virNetlinkNewLink(const char *ifname, return -1; } - nl_msg =3D nlmsg_alloc_simple(RTM_NEWLINK, - NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); - if (!nl_msg) { - virReportOOMError(); - return -1; - } + nl_msg =3D virNetlinkMsgNew(RTM_NEWLINK, + NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL); NETLINK_MSG_APPEND(nl_msg, sizeof(ifinfo), &ifinfo); @@ -684,11 +688,7 @@ virNetlinkDelLink(const char *ifname, virNetlinkTalkFa= llback fallback) unsigned int resp_len =3D 0; int error =3D 0; - nl_msg =3D nlmsg_alloc_simple(RTM_DELLINK, NLM_F_REQUEST); - if (!nl_msg) { - virReportOOMError(); - return -1; - } + nl_msg =3D virNetlinkMsgNew(RTM_DELLINK, NLM_F_REQUEST); NETLINK_MSG_APPEND(nl_msg, sizeof(ifinfo), &ifinfo); @@ -738,11 +738,7 @@ virNetlinkGetNeighbor(void **nlData, uint32_t src_pid,= uint32_t dst_pid) unsigned int resp_len =3D 0; int error =3D 0; - nl_msg =3D nlmsg_alloc_simple(RTM_GETNEIGH, NLM_F_DUMP | NLM_F_REQUEST= ); - if (!nl_msg) { - virReportOOMError(); - return -1; - } + nl_msg =3D virNetlinkMsgNew(RTM_GETNEIGH, NLM_F_DUMP | NLM_F_REQUEST); NETLINK_MSG_APPEND(nl_msg, sizeof(ndinfo), &ndinfo); diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h index cab685feea..e05c62e635 100644 --- a/src/util/virnetlink.h +++ b/src/util/virnetlink.h @@ -29,6 +29,10 @@ typedef struct nl_msg virNetlinkMsg; G_DEFINE_AUTOPTR_CLEANUP_FUNC(virNetlinkMsg, nlmsg_free); +struct nl_msg * +virNetlinkMsgNew(int nlmsgtype, + int nlmsgflags); + #else struct nl_msg; --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183616; cv=none; d=zohomail.com; s=zohoarc; b=BaGzEFbBWeNKD93oDVufV0C+But/cS/Ie0bECgfbTWS7rPF/aQL8RO7WuOVzuLfX1vGtqGIQofrOHVStyaq1UP7pEX3l1LqNQvGjJGxI+gc8/eJuuMbpcTrG//bP+Qv9DlieXNlaTLs0QGf7D3FePJy0Pqevm8yxr25cgffWqno= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183616; 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=D3m619v+RxMB8hmKNdHj9s9T8o7xBEAYxxH4WPmkr6c=; b=FSadGE8Y4wifg4PQcOtHjNlNHtxCa45uy+ZP0yoD04k/0iKb0lshAZiY/IHi2wMmObPsfqDi6Lal2MuxskYRMabWVm/NuOMQ4IQa76JvRimmqeTH4iT+rrWKiJMajY7lsf1rW1mBYbrj9qSVgjtxSsyc6Ks15X6NrAYKgXl5qUc= 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) 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 1614183616426347.2691509386133; Wed, 24 Feb 2021 08:20:16 -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-353-nYzKZs-uMyaIt00WKAP7Hw-1; Wed, 24 Feb 2021 11:17:58 -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 773851030BD0; Wed, 24 Feb 2021 16:17:51 +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 4A1D9100239A; Wed, 24 Feb 2021 16:17:51 +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 0E01C18077CE; Wed, 24 Feb 2021 16:17:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHh7q015638 for ; Wed, 24 Feb 2021 11:17:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 372AE60CDE; Wed, 24 Feb 2021 16:17:43 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CE0760862 for ; Wed, 24 Feb 2021 16:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183615; 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=D3m619v+RxMB8hmKNdHj9s9T8o7xBEAYxxH4WPmkr6c=; b=NpML/plc6dmBEhmksBpveDArIAPjtEgxJpaSrv4GVIQnkpHpU+wvtcY+SRZebL0F5zhCg4 kU6aFl0RskOTv61q0ls8KbTKDDosCzGR6EFibH+/Cgl4sTmRat1pxSINa2WxSRvXbNlnOv rD7WOeT0iy/iwl/h4gywbCUEwd9toLk= X-MC-Unique: nYzKZs-uMyaIt00WKAP7Hw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/33] util: xml: Add virXMLBufferCreate wrapper Date: Wed, 24 Feb 2021 17:16:53 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'xmlBufferCreate' returns NULL only on allocation failure. Add a wrapper which will call 'abort()' in such case in a centralised spot. It doesn't make much sense to continue execution from here. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 5 +---- src/conf/network_conf.c | 5 +---- src/libvirt_private.syms | 1 + src/util/virxml.c | 19 +++++++++++++------ src/util/virxml.h | 3 +++ src/vmx/vmx.c | 5 ++--- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 46620d38ed..7a3374b5be 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -28692,10 +28692,7 @@ virDomainDefFormatInternalSetRootName(virDomainDef= Ptr def, * Thankfully, libxml maps what looks like globals into * thread-local uses, so we are thread-safe. */ xmlIndentTreeOutput =3D 1; - if (!(xmlbuf =3D xmlBufferCreate())) { - virReportOOMError(); - return -1; - } + xmlbuf =3D virXMLBufferCreate(); if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata, virBufferGetIndent(buf) / 2, 1) < 0) { diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index f32710b781..69d99a60e0 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -2513,10 +2513,7 @@ virNetworkDefFormatBuf(virBufferPtr buf, * Thankfully, libxml maps what looks like globals into * thread-local uses, so we are thread-safe. */ xmlIndentTreeOutput =3D 1; - if (!(xmlbuf =3D xmlBufferCreate())) { - virReportOOMError(); - return -1; - } + xmlbuf =3D virXMLBufferCreate(); if (xmlNodeDump(xmlbuf, def->metadata->doc, def->metadata, virBufferGetIndent(buf) / 2, 1) < 0) { diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 6b7261b987..dd54550b60 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3529,6 +3529,7 @@ virVsockSetGuestCid; # util/virxml.h virParseScaledValue; +virXMLBufferCreate; virXMLCheckIllegalChars; virXMLExtractNamespaceXML; virXMLFormatElement; diff --git a/src/util/virxml.c b/src/util/virxml.c index 0354251941..3fed2b2a6e 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -941,12 +941,7 @@ char * virXMLNodeToString(xmlDocPtr doc, xmlNodePtr node) { - g_autoptr(xmlBuffer) xmlbuf =3D NULL; - - if (!(xmlbuf =3D xmlBufferCreate())) { - virReportOOMError(); - return NULL; - } + g_autoptr(xmlBuffer) xmlbuf =3D virXMLBufferCreate(); if (xmlNodeDump(xmlbuf, doc, node, 0, 1) =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1467,3 +1462,15 @@ virParseScaledValue(const char *xpath, *val =3D bytes; return 1; } + + +xmlBufferPtr +virXMLBufferCreate(void) +{ + xmlBufferPtr ret; + + if (!(ret =3D xmlBufferCreate())) + abort(); + + return ret; +} diff --git a/src/util/virxml.h b/src/util/virxml.h index e696dd25f5..24a2234506 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -286,3 +286,6 @@ int virParseScaledValue(const char *xpath, unsigned long long scale, unsigned long long max, bool required); + +xmlBufferPtr +virXMLBufferCreate(void); diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index db535ba260..e6c0900a65 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -771,7 +771,7 @@ virVMXConvertToUTF8(const char *encoding, const char *s= tring) char *result =3D NULL; xmlCharEncodingHandlerPtr handler; g_autoptr(xmlBuffer) input =3D NULL; - g_autoptr(xmlBuffer) utf8 =3D NULL; + g_autoptr(xmlBuffer) utf8 =3D virXMLBufferCreate(); handler =3D xmlFindCharEncodingHandler(encoding); @@ -781,8 +781,7 @@ virVMXConvertToUTF8(const char *encoding, const char *s= tring) return NULL; } - if (!(input =3D xmlBufferCreateStatic((char *)string, strlen(string)))= || - !(utf8 =3D xmlBufferCreate())) { + if (!(input =3D xmlBufferCreateStatic((char *)string, strlen(string)))= ) { virReportOOMError(); goto cleanup; } --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183550; cv=none; d=zohomail.com; s=zohoarc; b=djC2WbDXUOMhVsgs+98+cQTx26owZQdGMncMVgJXOhZ4IJEqelJdxGladqjLtiqKiGQvdpuCaERfgc5phw1GgztNXc4Ay1Hg6zOSnN9P0p0rU0bwENH+RUyX5Mlkx7PRId09YzcKJp9YgzuBfHrqwrLDfRChK1OR/cgAbc0W7s0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183550; 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=xSWvsr403y0QMfkKzfbmKHXVzixyU6uZ/NG4NGpX4V4=; b=kqs5hn0y9gyp9qiQOsYo3sJg3pYLIUkvMaHY7h3GM6yGQlW+x2Mro7F76CGiwizgKRVkx5ZQ5RGsmvdLst35+jqQ8BQE1SFSqAU/eBVKkGsUHRXsoaondpFjDMznwc4S8NeSceZj6WnHeP+bM2GwGwM0mzGDLA5rn845FGyUziw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 161418355022693.415843107559; Wed, 24 Feb 2021 08:19:10 -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-368-9VkSPW_2MyOL3TioZLIrXQ-1; Wed, 24 Feb 2021 11:17:54 -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 ADE0080402C; Wed, 24 Feb 2021 16:17:45 +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 822E819D9F; Wed, 24 Feb 2021 16:17:45 +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 41276180881C; Wed, 24 Feb 2021 16:17:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHict015656 for ; Wed, 24 Feb 2021 11:17:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5E501646DC; Wed, 24 Feb 2021 16:17:44 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id AECE560CDE for ; Wed, 24 Feb 2021 16:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183549; 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=xSWvsr403y0QMfkKzfbmKHXVzixyU6uZ/NG4NGpX4V4=; b=UArbyf0xM8hIM4leBBh5UnFta7B+7Ne0XrSHs2xNK+dBcjfADjVkiZKfKcuzzluCZOssGA QJNFZoNKMILBX9yAzeDwcihowpSm70yIDgIxda1z8t9ix5AmgZX12pztx78iVCaukzUyeu mZYzE76qNJDDETz2LcNbZM6A+WuSYhI= X-MC-Unique: 9VkSPW_2MyOL3TioZLIrXQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/33] util: xml: Add wrapper for 'xmlNewNode' Date: Wed, 24 Feb 2021 17:16:54 +0100 Message-Id: <096ac08a5755dc3c80b47cb5e89a3c03e06254ed.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add a wrapper that will handle the out of memory condition by abort() and also prevents callers from having to typecast the argument. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 7 ++----- src/libvirt_private.syms | 1 + src/util/virxml.c | 13 +++++++++++++ src/util/virxml.h | 4 ++++ src/vbox/vbox_snapshot_conf.c | 34 +++++++++------------------------- tools/virsh-domain.c | 5 +---- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7a3374b5be..c0881608af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30456,11 +30456,8 @@ virDomainDefSetMetadata(virDomainDefPtr def, return -1; /* create the root node if needed */ - if (!def->metadata && - !(def->metadata =3D xmlNewNode(NULL, (unsigned char *)"met= adata"))) { - virReportOOMError(); - return -1; - } + if (!def->metadata) + def->metadata =3D virXMLNewNode(NULL, "metadata"); if (!(new =3D xmlCopyNode(doc->children, 1))) { virReportOOMError(); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index dd54550b60..48f66daab8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3533,6 +3533,7 @@ virXMLBufferCreate; virXMLCheckIllegalChars; virXMLExtractNamespaceXML; virXMLFormatElement; +virXMLNewNode; virXMLNodeContentString; virXMLNodeNameEqual; virXMLNodeSanitizeNamespaces; diff --git a/src/util/virxml.c b/src/util/virxml.c index 3fed2b2a6e..ebe479f5d3 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1474,3 +1474,16 @@ virXMLBufferCreate(void) return ret; } + + +xmlNodePtr +virXMLNewNode(xmlNsPtr ns, + const char *name) +{ + xmlNodePtr ret; + + if (!(ret =3D xmlNewNode(ns, BAD_CAST name))) + abort(); + + return ret; +} diff --git a/src/util/virxml.h b/src/util/virxml.h index 24a2234506..d32f77b867 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -289,3 +289,7 @@ int virParseScaledValue(const char *xpath, xmlBufferPtr virXMLBufferCreate(void); + +xmlNodePtr +virXMLNewNode(xmlNsPtr ns, + const char *name); diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index f1cae3039a..5792d3175e 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -328,7 +328,7 @@ virVBoxSnapshotConfCreateHardDiskNode(virVBoxSnapshotCo= nfHardDiskPtr hardDisk) int result =3D -1; size_t i =3D 0; char *uuid =3D NULL; - xmlNodePtr ret =3D xmlNewNode(NULL, BAD_CAST "HardDisk"); + xmlNodePtr ret =3D virXMLNewNode(NULL, "HardDisk"); uuid =3D g_strdup_printf("{%s}", hardDisk->uuid); if (xmlNewProp(ret, BAD_CAST "uuid", BAD_CAST uuid) =3D=3D NULL) @@ -404,7 +404,7 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, /* node description */ if (snapshot->description !=3D NULL) { - descriptionNode =3D xmlNewNode(NULL, BAD_CAST "Description"); + descriptionNode =3D virXMLNewNode(NULL, "Description"); xmlNodeSetContent(descriptionNode, BAD_CAST snapshot->description); xmlAddChild(node, descriptionNode); } @@ -433,10 +433,10 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, xmlAddChild(node, storageControllerNode); if (snapshot->nchildren > 0) { - snapshotsNode =3D xmlNewNode(NULL, BAD_CAST "Snapshots"); + snapshotsNode =3D virXMLNewNode(NULL, "Snapshots"); xmlAddChild(node, snapshotsNode); for (i =3D 0; i < snapshot->nchildren; i++) { - xmlNodePtr child =3D xmlNewNode(NULL, BAD_CAST "Snapshot"); + xmlNodePtr child =3D virXMLNewNode(NULL, "Snapshot"); xmlAddChild(snapshotsNode, child); if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->chil= dren[i]) < 0) goto cleanup; @@ -1001,11 +1001,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfM= achinePtr machine, goto cleanup; } - cur =3D xmlNewNode(NULL, BAD_CAST "VirtualBox"); - if (!cur) { - virReportOOMError(); - goto cleanup; - } + cur =3D virXMLNewNode(NULL, "VirtualBox"); if (!xmlNewProp(cur, BAD_CAST "version", BAD_CAST "1.12-linux")) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1038,11 +1034,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfM= achinePtr machine, goto cleanup; } - machineNode =3D xmlNewNode(NULL, BAD_CAST "Machine"); - if (!machineNode) { - virReportOOMError(); - goto cleanup; - } + machineNode =3D virXMLNewNode(NULL, "Machine"); if (!xmlNewProp(machineNode, BAD_CAST "uuid", BAD_CAST machine->uuid))= { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1101,11 +1093,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfM= achinePtr machine, } xmlAddChild(xmlDocGetRootElement(xml), machineNode); - mediaRegistryNode =3D xmlNewNode(NULL, BAD_CAST "MediaRegistry"); - if (!mediaRegistryNode) { - virReportOOMError(); - goto cleanup; - } + mediaRegistryNode =3D virXMLNewNode(NULL, "MediaRegistry"); xmlAddChild(machineNode, mediaRegistryNode); for (i =3D 0; i < machine->mediaRegistry->notherMedia; i++) { @@ -1121,11 +1109,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfM= achinePtr machine, } xmlAddChild(mediaRegistryNode, cur); } - hardDisksNode =3D xmlNewNode(NULL, BAD_CAST "HardDisks"); - if (!hardDisksNode) { - virReportOOMError(); - goto cleanup; - } + hardDisksNode =3D virXMLNewNode(NULL, "HardDisks"); for (i =3D 0; i < machine->mediaRegistry->ndisks; i++) { xmlNodePtr child =3D virVBoxSnapshotConfCreateHardDiskNode(machine= ->mediaRegistry->disks[i]); if (child !=3D NULL) @@ -1172,7 +1156,7 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMa= chinePtr machine, xmlAddChild(machineNode, cur); if (machine->snapshot !=3D NULL) { - snapshotNode =3D xmlNewNode(NULL, BAD_CAST "Snapshot"); + snapshotNode =3D virXMLNewNode(NULL, "Snapshot"); xmlAddChild(machineNode, snapshotNode); if (virVBoxSnapshotConfSerializeSnapshot(snapshotNode, machine->sn= apshot) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index df33467646..16e0c45f80 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -12566,10 +12566,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, if (new_source) { /* create new source subelement */ - if (!(source =3D xmlNewNode(NULL, BAD_CAST "source"))) { - vshError(NULL, _("Failed to allocate new source node")); - goto cleanup; - } + source =3D virXMLNewNode(NULL, "source"); if (source_block) xmlNewProp(source, BAD_CAST "dev", BAD_CAST new_source); --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183486; cv=none; d=zohomail.com; s=zohoarc; b=Y33ON0a8DJkok9Sy5LqC3ptheXEsak3EXRH+XDtecQanZpVls6w6yuOqLGLj0D8YClGtvSBK6RUnx8hzk5hQw8BJxXMdDEgSUz3ONVDuqhAitKxldmVDC+IiG4oIryt5KVCEfYvGSc6Sk0rF/jahneikv//twDm9xDoYGZPftA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183486; 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=Q3OvWhXXHVDUUdhNqerIZissFzawip/yR/4xWQZGFsk=; b=hPHxeVEYKDkCKRPKgCg4cuORkH/AYSiWKMNQMOTzVtm768aNhDy8qmHDKmmPAD1uSretN527ieDabqOPezw5vawqUVC0q9aZM975SbSYBZTHKpMZMUgghlHYrwcmHlE0ca0zIIe/0Kn6nM4R/dLEhSiqCU1aFa62mm+o5EH7qBI= 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) 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 1614183486150520.4623449461652; Wed, 24 Feb 2021 08:18:06 -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-73-lKCPy4RVMuu6zzMT4B4BDQ-1; Wed, 24 Feb 2021 11:18:02 -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 73E3D100CCC3; Wed, 24 Feb 2021 16:17:54 +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 51C5060CDE; Wed, 24 Feb 2021 16:17:54 +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 116CB5808E; Wed, 24 Feb 2021 16:17:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHjdB015667 for ; Wed, 24 Feb 2021 11:17:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id BDCF960D79; Wed, 24 Feb 2021 16:17:45 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2043E60CDE for ; Wed, 24 Feb 2021 16:17:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183485; 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=Q3OvWhXXHVDUUdhNqerIZissFzawip/yR/4xWQZGFsk=; b=VKpDroqZCFzV2N7IjOqpLhc3ZpiT33ZzLjzTG7nRXMluuZbjI4R9R/QILnoRQQFwc5xwMw AQaGyvt/RWeZX3ScZvmlmM+MsrPxXGIgd255LMav5fID9X2+yD80qUCYbk1/RWy+OFluG3 NqpXzfHkNnb8CXVBRHA6bbBPq5Hc0pk= X-MC-Unique: lKCPy4RVMuu6zzMT4B4BDQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/33] Don't report OOM error on xmlCopyNode failure Date: Wed, 24 Feb 2021 17:16:55 +0100 Message-Id: <526bb207189d67f239580834b73582305ebf5ebd.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Out of memory isn't the only reason the function can fail. Add a message stating that copying of a XML node failed. Signed-off-by: Peter Krempa --- src/conf/domain_conf.c | 3 ++- src/test/test_driver.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c0881608af..f1fd5320a5 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -30460,7 +30460,8 @@ virDomainDefSetMetadata(virDomainDefPtr def, def->metadata =3D virXMLNewNode(NULL, "metadata"); if (!(new =3D xmlCopyNode(doc->children, 1))) { - virReportOOMError(); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to copy XML node")); return -1; } } diff --git a/src/test/test_driver.c b/src/test/test_driver.c index bca1297d1d..71ab04aa1a 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -224,7 +224,8 @@ testDomainDefNamespaceParse(xmlXPathContextPtr ctxt, for (i =3D 0; i < n; i++) { xmlNodePtr newnode =3D xmlCopyNode(nodes[i], 1); if (!newnode) { - virReportOOMError(); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to copy XML node")); goto error; } @@ -787,7 +788,8 @@ testParseXMLDocFromFile(xmlNodePtr node, const char *fi= le, const char *type) ret =3D xmlCopyNode(xmlDocGetRootElement(doc), 1); if (!ret) { - virReportOOMError(); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to copy XML node")); goto error; } xmlReplaceNode(node, ret); --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183488; cv=none; d=zohomail.com; s=zohoarc; b=cuA+oMS3ottHJXcfNd02one9HyMelFvbbplRbqU5BWg+PuVXSmO8eyNUrxjiI3iJEgJsBnofqXTxkAw3kHa/4zlcPGcNsedFIxsnisEK1kGDrSXdxzdyGM257C7XRdLi7lTbtv4RZeiiH6OkBprI6RuLJ2pYNzYy8eiDuWkMwUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183488; 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=PT9nMxraawgJlRgOKK6zL+0js5Vc83stckn406PGNVs=; b=S2PZ4CxfiAWujYCsK5ApJJl/ndcDlD3VtqX0E8+lC/hxwSqXe4r8gAoc70hULLSAUEkN5l5gWH2K+2f0QPZJDmRfuM0CyN2VsClxwfof8vXqucHfErkpWWe0+3EnPB/NDb/AmriUae66TKNe7aclAn3eQ2V8TmnRxpjMiZeSWkc= 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) 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 161418348835551.736231503250906; Wed, 24 Feb 2021 08:18:08 -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-587-fr9ImW5DMAK-Q777-G2zTg-1; Wed, 24 Feb 2021 11:18:03 -0500 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 B2F7750742; Wed, 24 Feb 2021 16:17:57 +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 8F6085D6A8; Wed, 24 Feb 2021 16:17:57 +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 5320718077D2; Wed, 24 Feb 2021 16:17:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHkes015687 for ; Wed, 24 Feb 2021 11:17:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id DBF4B646DC; Wed, 24 Feb 2021 16:17:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C34260CDE for ; Wed, 24 Feb 2021 16:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183487; 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=PT9nMxraawgJlRgOKK6zL+0js5Vc83stckn406PGNVs=; b=iyvrjEyGwOI1e0UKZZv92QRCkgsq9Ln9H0BG9coW/nSud7qDdLwu6KMNsp4ai/4mklTdbK iRaExQz3g7Fm2ZRjrpcWDW0pNyOcVFHfkQJiM/FD7HRTSEv2I1wyS3TYzVti3czr9LYMWN JGqGSCGAAfOqJeMcrHkUkMqamElTsIM= X-MC-Unique: fr9ImW5DMAK-Q777-G2zTg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 21/33] virXMLXPathContextNew: abort() on allocation failure Date: Wed, 24 Feb 2021 17:16:56 +0100 Message-Id: <701ebf8fc0a75d108c710aa3530bc60d09191b5b.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/util/virxml.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index ebe479f5d3..62bbafacd6 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -51,10 +51,8 @@ virXMLXPathContextNew(xmlDocPtr xml) { xmlXPathContextPtr ctxt; - if (!(ctxt =3D xmlXPathNewContext(xml))) { - virReportOOMError(); - return NULL; - } + if (!(ctxt =3D xmlXPathNewContext(xml))) + abort(); return ctxt; } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183488; cv=none; d=zohomail.com; s=zohoarc; b=DH5qdv4McBnoIUV1eFvx2K8Np7JRKbNdgL8MGOl3s+bTESioQXQEVv8n/4f8Xl/nNTUq6EoSbHn0Or3nOuI+9l7jrpGbhO4CuIw9Goyd5y9oyO5U0ToiK1L+lRPDXEdiYZJhO8UXVslZgdpBffG5yGnIyAvoQmK9crEkSRjErwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183488; 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=8QKkfEBEJdh5coAL68zKyU6PHHP+xhVxtVKURncR9a8=; b=d+CBJPDUX2adBJNM1qpt6WCJUY1x0IA2f5pg6Ay+DqDFOWLjuKuVGw7lQBcKLTBGMvbRMlZWgwPLfm9Gvv2BiJy80mKKdGpcoIfZS+SldG6i0gaMqgJZf72xF7Src1Ky3vqS3UI4+Exu6X0rm9KMti0vk9fUdwwJVAe3CO0Sv/4= 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) 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 1614183488358773.3752084913175; Wed, 24 Feb 2021 08:18:08 -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-592-fCFdd49ROyOf65XEzNw8fg-1; Wed, 24 Feb 2021 11:17:59 -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 CDAF3107ACE3; Wed, 24 Feb 2021 16:17:52 +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 A9CF12C01F; Wed, 24 Feb 2021 16:17:52 +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 664025808A; Wed, 24 Feb 2021 16:17:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHo7q015749 for ; Wed, 24 Feb 2021 11:17:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id D33FE646DC; Wed, 24 Feb 2021 16:17:50 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37AC460D79 for ; Wed, 24 Feb 2021 16:17:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183487; 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=8QKkfEBEJdh5coAL68zKyU6PHHP+xhVxtVKURncR9a8=; b=cD0sWea4SFvZEhEIrztqrUpIQQc0bi+Dfypw+JNsnr4FOFhqddFVIDdhDYS8A8moncfk7/ dCU9We7gXOc24AJ5MTIkbqNMOfybmegRKVQFa8q2J+rw3+gjydAmDgmG0RO3eZOAXJfBXJ H8geHCuff3FsB6Hpe4H/f61hDSEI7oY= X-MC-Unique: fCFdd49ROyOf65XEzNw8fg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 22/33] virXMLParseHelper: abort() on allocation failure Date: Wed, 24 Feb 2021 17:16:57 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/util/virxml.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/virxml.c b/src/util/virxml.c index 62bbafacd6..060b7530fc 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -789,10 +789,8 @@ virXMLParseHelper(int domcode, /* Set up a parser context so we can catch the details of XML errors. = */ pctxt =3D xmlNewParserCtxt(); - if (!pctxt || !pctxt->sax) { - virReportOOMError(); - goto error; - } + if (!pctxt || !pctxt->sax) + abort(); private.domcode =3D domcode; pctxt->_private =3D &private; --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183492; cv=none; d=zohomail.com; s=zohoarc; b=nBuJvULoB4/gGIo3rqR+oCGA/dFOP6qYglLVFDDK4toq5VVaI59GyJzYg8yYINMrlt0ciukdNlWkYj9b+r6C5ZoGPlyd9SkXyXwZN6TP2rGk66oeSGCnSNJmm/dzSfh/PZ8TX0MT3qnp38AENIonuhR6y/eg3lWKXwt1WGNqb/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183492; 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=jNKjHwk566afh4kGdBBfQbEa8onPlA1q57SBkogRCh0=; b=RTwZX1yfnrhKA8lQ4zFDOGDMKRd77aj3IxvUuP1oYtVVhn9w9pz9ICJ5C+GaHl94c6ee3HUUqCCWA4861OxLCQwItfFLJ1k59mVO2/Ttnrjom1fpV9JfaL4+kFSqpjOvCFSGLBWGQ41W+evskQwL4jxlJ+5Tkmfwcha30So3cwg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183492365236.38154145128271; Wed, 24 Feb 2021 08:18:12 -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-275-eRmu8to-NWKkSweDBuwaCA-1; Wed, 24 Feb 2021 11:18:03 -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 CF3FB801977; Wed, 24 Feb 2021 16:17:55 +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 AA17E50A8D; Wed, 24 Feb 2021 16:17:55 +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 65D3158091; Wed, 24 Feb 2021 16:17:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHpKq015765 for ; Wed, 24 Feb 2021 11:17:51 -0500 Received: by smtp.corp.redhat.com (Postfix) id DEDCA646DC; Wed, 24 Feb 2021 16:17:51 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AF6A60D79 for ; Wed, 24 Feb 2021 16:17:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183489; 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=jNKjHwk566afh4kGdBBfQbEa8onPlA1q57SBkogRCh0=; b=EAGrnUxs+wzlihYSCSwv1kBqOF8ow5U4ZCIV8OS2oNttc7qAEzfFB5jNshSTJ2IUhr0P06 1mTzD4tsgfuD5+njOA4CUnF7DVD7tKYTl3oM8CdLY5BU6lTLfNUIYUj/dkAb5dHoMTJoal EgYlbIz6BKBASno5WENbGYgiZEtWLvs= X-MC-Unique: eRmu8to-NWKkSweDBuwaCA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 23/33] util: virprocess: abort() on CPU_ALLOC failure Date: Wed, 24 Feb 2021 17:16:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa --- src/util/virprocess.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 41c5678537..69d64e9466 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -462,10 +462,8 @@ int virProcessSetAffinity(pid_t pid, virBitmapPtr map,= bool quiet) masklen =3D CPU_ALLOC_SIZE(numcpus); mask =3D CPU_ALLOC(numcpus); - if (!mask) { - virReportOOMError(); - return -1; - } + if (!mask) + abort(); CPU_ZERO_S(masklen, mask); for (i =3D 0; i < virBitmapSize(map); i++) { @@ -509,10 +507,8 @@ virProcessGetAffinity(pid_t pid) masklen =3D CPU_ALLOC_SIZE(ncpus); mask =3D CPU_ALLOC(ncpus); - if (!mask) { - virReportOOMError(); - return NULL; - } + if (!mask) + abort(); CPU_ZERO_S(masklen, mask); --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183550; cv=none; d=zohomail.com; s=zohoarc; b=mmNvGH+84FjyRIy5ITF9HCIBuj298i1pC7tumFWn2QxK2pAqmOOVOPxu1AbXqjT5f2XLH3+jvjfEde+8u7836Mw5jMXEBoirGX0ju1lmB2oy0purCNAFxC8uVkJizE53kvGmhY0/OCJBWJNhvAxfxP2VRLzyR8woOAhjtFyPAHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183550; 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=4TJwGl7Boa1Aesk6A+wex8MBpFHwVLdPs+CXtphXldA=; b=LaG8XXMLRvgRIAi4GYmkS1YLFkXsej9yRLigQH3+SpWhpKUmDxqNmF980VRQWzvUNKJR+QczSVDk8V/5NNPDQUWZh5CeijuMG/EMoDixH1t2X1WlXV0/WtNcuJGIflhaBbzdJWvuI/4/WK2XnhldzOaNTyMiwqOGHAS/G8Ohdf4= 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) header.from= 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 1614183550074454.44056259306467; Wed, 24 Feb 2021 08:19:10 -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-154-J2nNQ3NuMjuq8c_mAebcbg-1; Wed, 24 Feb 2021 11:18:04 -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 ED9B6801986; Wed, 24 Feb 2021 16:17:58 +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 C25DA19727; Wed, 24 Feb 2021 16:17:58 +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 89C5F18077D4; Wed, 24 Feb 2021 16:17:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHqRn015784 for ; Wed, 24 Feb 2021 11:17:52 -0500 Received: by smtp.corp.redhat.com (Postfix) id EDD2760CDE; Wed, 24 Feb 2021 16:17:52 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 530F4646DC for ; Wed, 24 Feb 2021 16:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183549; 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=4TJwGl7Boa1Aesk6A+wex8MBpFHwVLdPs+CXtphXldA=; b=g3KsUYeN84Mu36e1BhMLnRB6ygEshttlRFAwRZ3DVcTirHeSrWZJxPVTr1Rlj5w9f3VO9g SkEO31qN5HqvvUWGv56GU+L6iPTgQDp72fcXpjaaAMC5tj5zeL9K9Rph4Mjk9toZoT5ffz L9NlVuNW4oouwyD/Ut/24RXlEw5f1wg= X-MC-Unique: J2nNQ3NuMjuq8c_mAebcbg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 24/33] virURIFormat: abort() on failure Date: Wed, 24 Feb 2021 17:16:59 +0100 Message-Id: <9b9592726573b3d19c7cf7f775d75ef2db3f2b33.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If the argument of 'xmlSaveUri' is non-NULL the function returns NULL on OOM failure only. Thus we can directly abort rather than try to do the impossible recovery. Signed-off-by: Peter Krempa --- src/util/viruri.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/util/viruri.c b/src/util/viruri.c index 0aafd49d6d..1e8808ddc6 100644 --- a/src/util/viruri.c +++ b/src/util/viruri.c @@ -238,11 +238,9 @@ virURIFormat(virURIPtr uri) if (!xmluri.server && !xmluri.port) xmluri.port =3D -1; - ret =3D (char *)xmlSaveUri(&xmluri); - if (!ret) { - virReportOOMError(); - return NULL; - } + /* xmlSaveUri can fail only on OOM condition if argument is non-NULL */ + if (!(ret =3D (char *)xmlSaveUri(&xmluri))) + abort(); return ret; } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183544; cv=none; d=zohomail.com; s=zohoarc; b=RibPkJ/jDvXU8dxoNMou+C4fITo5STtL9LPbqmeW7oj8v3c3tKffstxIlJwJN3nSPYfSIYP4w1se2xYLb9exWp7xNF4nLqJE/MmQcQHY2oSfgsPYFFjhlRQdMBB6o7qfHTqsJy7/1Q0IcbAzxjQWgMpRFKv8Q1CSZCSA21UOMjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183544; 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=SgFDK1w/Bb6hbA8OE0D8sbK6Qzrr7ltGKb1cnYWKkyU=; b=YGoAadZjxj996B/1XqIXzVXABVJpE1TS6pb5jbYVOiwceGqogYMsNFLu2Y2HKubm6ZHcfkhZE0fqK/a6jcSQ/55WegK4GxGLrAHDSe/8C8dY1NjXwIXM5GajgVHzP5d/xbhkprKaYaHI+DgStE+Y8Vs31Hc1fd1yHMMKln4oKjY= 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) 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 1614183544074940.0076311263002; Wed, 24 Feb 2021 08:19: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-359-bUv7ki0ANAC571tX83eNJA-1; Wed, 24 Feb 2021 11:18:08 -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 0BE0B100CCC7; Wed, 24 Feb 2021 16:18:02 +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 CD4281972B; Wed, 24 Feb 2021 16:18:01 +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 8A7AB58079; Wed, 24 Feb 2021 16:18:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHsRZ015810 for ; Wed, 24 Feb 2021 11:17:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0B27D6B8E5; Wed, 24 Feb 2021 16:17:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64BA660D79 for ; Wed, 24 Feb 2021 16:17:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183543; 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=SgFDK1w/Bb6hbA8OE0D8sbK6Qzrr7ltGKb1cnYWKkyU=; b=ckOyyBCby9ev0j5HMjyptxuvXi6/UQWq6838anINq4exM0cbGgNmmBccV3+nB6T04JefZ6 QHZ6EmQeuEbQg5s9wIqmahBujKgcZirzavwqD/3HQFr68PCA4avdenDwThtNIa6LIXArVG o8/ZVyHVp7Rhiai6xKy8phngEYr4L0U= X-MC-Unique: bUv7ki0ANAC571tX83eNJA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 25/33] util: iohelper: Don't handle OOM from posix_memalign Date: Wed, 24 Feb 2021 17:17:00 +0100 Message-Id: <8d54dd1ef010ed1637e5153683843085e10a3a6f.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Similarly to other allocation calls abort() on failure. Signed-off-by: Peter Krempa --- src/util/iohelper.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index 49d939d290..b8810d16d3 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -27,6 +27,7 @@ #include #include +#include #include "virthread.h" #include "virfile.h" @@ -57,10 +58,8 @@ runIO(const char *path, int fd, int oflags) off_t end =3D 0; #if WITH_POSIX_MEMALIGN - if (posix_memalign(&base, alignMask + 1, buflen)) { - virReportOOMError(); - goto cleanup; - } + if (posix_memalign(&base, alignMask + 1, buflen)) + abort(); buf =3D base; #else buf =3D g_new0(char, buflen + alignMask); --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183556; cv=none; d=zohomail.com; s=zohoarc; b=S1gk2MqamAxplRaVIl+pHKVjP5ULKnSoi3JRZYgp6Mq1i1NFq04QlR+V8UcUtUT/R3iR6Chq2XA0Kjie6gCEYtQtPN1KERFg5mx8ZTAoTrmKJm6mYkJXFi3xANfnKmbXQeZHz+tdVkXDSOXz9Uk199NdKESJ50SxA0+ApFJDg8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183556; 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=+UVwHo7iGOMCDbtAC5UUjXmxSjA2hgKRVIfEygZIYkg=; b=TkLoKpxnB6TiqCqqKEvMUlw0HaH0IlLOWwLAFaqT8NuuZ2pC3czk/wYuKpd2dFke2rFQo/fttvGgVSF6n8FUz/KhuEI5i+705b/1XO678Xm5dPnQ9ecmpdEXQMYk/EkABZw9ocGMGznHCg3xNuI1WtoMpaUfQCcNe3t/RFqRd3M= 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) 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 1614183556060675.5921872531818; Wed, 24 Feb 2021 08:19:16 -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-597-neq1DEecM2SkfyIGP7Fdvg-1; Wed, 24 Feb 2021 11:18:12 -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 0A0DD801977; Wed, 24 Feb 2021 16:18: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 D5BF35D9E3; Wed, 24 Feb 2021 16:18:04 +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 9450218077D7; Wed, 24 Feb 2021 16:18:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHtl5015818 for ; Wed, 24 Feb 2021 11:17:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2540860CDE; Wed, 24 Feb 2021 16:17:55 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7783660D79 for ; Wed, 24 Feb 2021 16:17:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183555; 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=+UVwHo7iGOMCDbtAC5UUjXmxSjA2hgKRVIfEygZIYkg=; b=KdP1QnN75I3uKWLPyXK2lJK1lJyhp2KmOa+spVHR0cQLWSjgLX9aqY2u9KAiWOLzr6lOU5 8qW1PSvDi1wM6H0Dr4miVN66NAkE8ezOzMebJm4fdnuhPyz1sOJYFU2VWG9aYq4OwMXM9U guxsPGfeGsGuSUMXENv1hRMPfxh2WM8= X-MC-Unique: neq1DEecM2SkfyIGP7Fdvg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 26/33] hyperv: abort() failure of wsmc_fault_new() Date: Wed, 24 Feb 2021 17:17:01 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function just allocates a helper object. Reporting errors would be pointless when we encounter OOM situation. Signed-off-by: Peter Krempa --- src/hyperv/hyperv_wmi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 8bb6f591f1..2a898cdf03 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -92,12 +92,8 @@ hypervVerifyResponse(WsManClient *client, WsXmlDocH resp= onse, } if (wsmc_check_for_fault(response)) { - fault =3D wsmc_fault_new(); - - if (fault =3D=3D NULL) { - virReportOOMError(); - return -1; - } + if (!(fault =3D wsmc_fault_new())) + abort(); wsmc_get_fault_data(response, fault); --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183548; cv=none; d=zohomail.com; s=zohoarc; b=NnLxNoJtyJi8iixcUtr/URKmVpMmgNxHpnNJhdCHbf+mG6v064XBSZctqKz1A7JAAti7R7E912v2fBbBnRn7OtisWPrZ7l8lg+AZomOewU5ooXMuTWZBPccVzLRDbMkEk80ximdIp5xRYxCE5rSNMbs5NYCaoq5gxllOr4GM6f4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183548; 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=uoVBwdazVFYgpkxT56g7ut9wZ92D5K0e1Y8HV1ud4g4=; b=jt52f52MQ023e+hU0ypM8xNDOQTrU5cU4gd7X8oRCDGuj2AXPHwZh3rxdPRseFMI5+2a5S4zNIjwQZBLa/aIRbBGjMjslIFs1b6XLm7Vz11Spyxgc+4CPz1ynYKTg5OIrtI5C3Y/mg6TtSHovr9TXzyEGiqUKzKIXU9nx9gRmyo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183548481774.3402250071974; Wed, 24 Feb 2021 08:19:08 -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-156-u2dTsIJBNSKHIGBS2lepsw-1; Wed, 24 Feb 2021 11:18:03 -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 CE2D2100CCCA; Wed, 24 Feb 2021 16:17:57 +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 A37A719C71; Wed, 24 Feb 2021 16:17:57 +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 6768B58092; Wed, 24 Feb 2021 16:17:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHu8U015846 for ; Wed, 24 Feb 2021 11:17:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 59AFE60D79; Wed, 24 Feb 2021 16:17:56 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EB1160CDE for ; Wed, 24 Feb 2021 16:17:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183547; 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=uoVBwdazVFYgpkxT56g7ut9wZ92D5K0e1Y8HV1ud4g4=; b=Ij0GkvajDBgBXKzLRa7Z5A6Mzt6xweHcT3e9Rab1whR/wXY682TJ8tLgtusankqrYGq4Gc Iaz5IIjF5RPkGcx863MdaHe4qQ1yQKSRha8Gf54Bdtwh9vdSQzTJKYL5DWzGfBayBHY4MZ 6kCtSSFZfLlgMJIAfev2Nv8RHgzVIdE= X-MC-Unique: u2dTsIJBNSKHIGBS2lepsw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 27/33] vbox: abort() on allocation failure in UTF8<->UTF16 conversion Date: Wed, 24 Feb 2021 17:17:02 +0100 Message-Id: <97ec15aa66a369a59a6ea5b30210210f6c175bbb.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Trying to report an error on OOM is pointless since error handling allocates memory. Signed-off-by: Peter Krempa --- src/vbox/vbox_common.c | 20 -------------------- src/vbox/vbox_common.h | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 138403b034..ce9bfbf827 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -5465,17 +5465,9 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, } VBOX_UTF8_TO_UTF16(def->parent.name, &name); - if (!name) { - virReportOOMError(); - goto cleanup; - } if (def->parent.description) { VBOX_UTF8_TO_UTF16(def->parent.description, &description); - if (!description) { - virReportOOMError(); - goto cleanup; - } } rc =3D gVBoxAPI.UIConsole.TakeSnapshot(console, name, description, &pr= ogress); @@ -6475,10 +6467,6 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr sna= pshot, goto cleanup; } VBOX_UTF16_TO_UTF8(nameUtf16, &name); - if (!name) { - virReportOOMError(); - goto cleanup; - } ret =3D virGetDomainSnapshot(dom, name); @@ -6533,10 +6521,6 @@ vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned= int flags) } VBOX_UTF16_TO_UTF8(nameUtf16, &name); - if (!name) { - virReportOOMError(); - goto cleanup; - } ret =3D virGetDomainSnapshot(dom, name); @@ -6593,10 +6577,6 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnap= shotPtr snapshot, } VBOX_UTF16_TO_UTF8(nameUtf16, &name); - if (!name) { - virReportOOMError(); - goto cleanup; - } ret =3D STREQ(snapshot->name, name); diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 8b1fb2ac30..1fb922aaf0 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -391,8 +391,19 @@ typedef nsISupports IKeyboard; } \ } while (0) -#define VBOX_UTF16_TO_UTF8(arg1, arg2) gVBoxAPI.UPFN.Utf16ToUtf8(data->pF= uncs, arg1, arg2) -#define VBOX_UTF8_TO_UTF16(arg1, arg2) gVBoxAPI.UPFN.Utf8ToUtf16(data->pF= uncs, arg1, arg2) +#define VBOX_UTF16_TO_UTF8(arg1, arg2) \ + do { \ + gVBoxAPI.UPFN.Utf16ToUtf8(data->pFuncs, arg1, arg2); \ + if (!*(arg2)) \ + abort(); \ + } while (0) + +#define VBOX_UTF8_TO_UTF16(arg1, arg2) \ + do { \ + gVBoxAPI.UPFN.Utf8ToUtf16(data->pFuncs, arg1, arg2); \ + if (!*(arg2)) \ + abort(); \ + } while (0) #define VBOX_ADDREF(arg) gVBoxAPI.nsUISupports.AddRef((void= *)(arg)) --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183606; cv=none; d=zohomail.com; s=zohoarc; b=dlNlI3X49LPg2uYZ40MkpLS2ZA2DH5XoPmJqBwvRYbGSlZE0BEh4rhHnR8bzdUh65xOD7gMBnNz4hU6UIjHV4OL4dZhKNfo0NMVJpci/Jhvr0OnIpJZAOOCG7tFhHAcpRf2HavqGP9ghQ3dxYzygtbSZ7OmiBtGV1AE4/lJEKzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183606; 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=s1MIIuuK7N2RPWXki7IiXu9xi+7E7IeiS/xZZykzbUM=; b=hQMrYDxd0pVx0mK+1eEJVdRhfvXOXv9Q6TQlvD4UL1ItB/m1Wpp3mr2uduLakr2oye7+oj2HD9YIicTCNmBAKBT6jEDXbPB2P9FZDyscyWFgxQTLInGlRTh/vyqjWsF1E7VhiJ7eosqBMyKOK/UDDhOZb91ByPymkTv8cTjc2ls= 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) 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 1614183606968834.4711091616042; Wed, 24 Feb 2021 08:20:06 -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-277-wuENajZOM0-38FWgwnVbtA-1; Wed, 24 Feb 2021 11:18:15 -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 377AC100CCC4; Wed, 24 Feb 2021 16:18:08 +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 0F5BA10023AB; Wed, 24 Feb 2021 16:18:08 +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 C6FC818089C9; Wed, 24 Feb 2021 16:18:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGHxhG015901 for ; Wed, 24 Feb 2021 11:17:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 55A6760862; Wed, 24 Feb 2021 16:17:59 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB4546E505 for ; Wed, 24 Feb 2021 16:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183606; 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=s1MIIuuK7N2RPWXki7IiXu9xi+7E7IeiS/xZZykzbUM=; b=Lj0TxpHWXk+EcG62mVVpaiKjrQeNuqPO19UtadYuOP5UxkLToUkWITNP28tv8CTkn1cK87 zQRFX/lWdIaVer5cyE3fETNCKRlp9bwWcz0Qk7RrIxrsPFO41+4pdsY3SBEto+7cTocaIX 5safpQIWWnKecaWyCWylwEmviuzwim4= X-MC-Unique: wuENajZOM0-38FWgwnVbtA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/33] libxl: abort() on failure of libxl_cpu_bitmap_alloc() Date: Wed, 24 Feb 2021 17:17:03 +0100 Message-Id: <9309e3d2bd248ff13a37188c8fb8e498debff93b.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Attempting to report error in case when we ran out of memory is pointless. Signed-off-by: Peter Krempa --- src/libxl/libxl_conf.c | 6 ++---- src/libxl/libxl_driver.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index f8db118996..f2bcd77a29 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -854,10 +854,8 @@ libxlMakeVnumaList(virDomainDefPtr def, goto cleanup; libxl_bitmap_init(&vcpu_bitmap); - if (libxl_cpu_bitmap_alloc(ctx, &vcpu_bitmap, b_info->max_vcpus)) { - virReportOOMError(); - goto cleanup; - } + if (libxl_cpu_bitmap_alloc(ctx, &vcpu_bitmap, b_info->max_vcpus)) + abort(); do { libxl_bitmap_set(&vcpu_bitmap, cpu); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 75a8d46af0..434959d694 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4931,10 +4931,9 @@ libxlDomainGetNumaParameters(virDomainPtr dom, if (numnodes <=3D 0) goto cleanup; - if (libxl_node_bitmap_alloc(cfg->ctx, &nodemap, 0)) { - virReportOOMError(); - goto cleanup; - } + if (libxl_node_bitmap_alloc(cfg->ctx, &nodemap, 0)) + abort(); + nodes =3D virBitmapNew(numnodes); rc =3D libxl_domain_get_nodeaffinity(cfg->ctx, --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183501; cv=none; d=zohomail.com; s=zohoarc; b=O1n451MgzUpwtyMVr+MoTS51ie8FiF+QGsylEnW4ZcFP8oATL/pw7CXVLYvZXhkt3BR8l3LlLVCYGzIA46ETtZqeFPOL3ljeMhUh+nXg+yT2R1MZXwhKaw+7Kvim+3l3T0iElJdXKfiWnAj9VTFMZaI+dI5WwS0138yYcd+hEN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183501; 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=rXRa+urYaT7c99vcriBXD7zrfS5L0p+q/HJVZm2fDLg=; b=Qn3I39orehpWKqTducqEijINsk+q+ivBhxlSvdoZQFPZlFePcH26yHd2491u+0ZKl79i5JPbrpuYdr97OK98ZLUAx6UgiyXz4JGlVdMmFQrZEXDZ4y5OKenX7I+mVqm9s0ikSpeF5FMTSL1ATYA74TQ2LSN54CWI3R44LKu/5nQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183501556534.0978292308699; Wed, 24 Feb 2021 08:18:21 -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-536-Jbj0zxGhNgao_UotFTOSVg-1; Wed, 24 Feb 2021 11:18:17 -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 AFFA050753; Wed, 24 Feb 2021 16:18:09 +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 84CC22C01F; Wed, 24 Feb 2021 16:18:09 +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 217AC1800420; Wed, 24 Feb 2021 16:18:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGI2lL015972 for ; Wed, 24 Feb 2021 11:18:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2C136646DC; Wed, 24 Feb 2021 16:18:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8145360D79 for ; Wed, 24 Feb 2021 16:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183500; 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=rXRa+urYaT7c99vcriBXD7zrfS5L0p+q/HJVZm2fDLg=; b=RkNUkMfGHP1O7NElBhetk8sF4OSDCtB76M6ULLyy2eWHTeBYKFuNtYT8SZar7ZJLKKy4HA W/lXQWEgbJztzKPg7idTkeNaIQgAosP3RGOB7T8KuKKxC6L0SHQoOXGYQ/OpETl9hLUTCk QRtu4xmtEcrnHFafx8BomEzdeZfjmC0= X-MC-Unique: Jbj0zxGhNgao_UotFTOSVg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 29/33] virVBoxSnapshotConfSaveVboxFile: abort() on failure to allocate xmlDoc and comment Date: Wed, 24 Feb 2021 17:17:04 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 'xmlNewDoc' and 'xmlNewDocComment' return NULL only on allocation failure. Attempting to raise an error is pointless. Signed-off-by: Peter Krempa --- src/vbox/vbox_snapshot_conf.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 5792d3175e..4f12d2ebfa 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -996,10 +996,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfMac= hinePtr machine, goto cleanup; } xml =3D xmlNewDoc(BAD_CAST "1.0"); - if (!xml) { - virReportOOMError(); - goto cleanup; - } + if (!xml) + abort(); cur =3D virXMLNewNode(NULL, "VirtualBox"); @@ -1023,10 +1021,8 @@ virVBoxSnapshotConfSaveVboxFile(virVBoxSnapshotConfM= achinePtr machine, "OVERWRITTEN AND LOST.\n" "Changes to this xml configuration should be ma= de using Virtualbox\n" "or other application using the libvirt API"); - if (!cur) { - virReportOOMError(); - goto cleanup; - } + if (!cur) + abort(); if (!xmlAddPrevSibling(xmlDocGetRootElement(xml), cur)) { virReportError(VIR_ERR_XML_ERROR, "%s", --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183503; cv=none; d=zohomail.com; s=zohoarc; b=cnSRdXeSWdC3qgfWSpJ4+T1cJL/2YNFjedZYxR8TO+lRPN+FMhkjRXDZKaelPlvpxRTbLAui5R3ai7zAkbxc9l7IlNKPITORr4kkCfSiAji2qE9gxvw7OVsp7t45/UQAkA6MKEeQ8PwNtQgxdgl8NVOPtlSoropz2WLjQtgqnjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183503; 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=H28IyeS7SMu08OVvqYrTbHc1btYcYQt5ED24NR/cmM0=; b=PJFr9fhFEVl1QJdqhpP9fZyoJIP248nbt+yX0vdlrUHA3geSWGxpEoJ13EAqbnTiGrCIJU2iAe6Mp6/qBdYu+BoMW49w3/MHp6KnlPsU3eem2kb7NeXePbKTTQhRzk0RLCNlPdaMREARs0WNBYGgY3Smi8dXlEv8ehUhEYDu6ls= 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) 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 16141835035385.738302831443548; Wed, 24 Feb 2021 08:18:23 -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-429-b6Cd_vRDNmeKPg0FNYpFyg-1; Wed, 24 Feb 2021 11:18:17 -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 DA26E100CCD6; Wed, 24 Feb 2021 16:18:09 +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 B49B72C168; Wed, 24 Feb 2021 16:18:09 +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 7B0AB58098; Wed, 24 Feb 2021 16:18:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGI4x8016033 for ; Wed, 24 Feb 2021 11:18:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id EC77E6E515; Wed, 24 Feb 2021 16:18:04 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 59B4D646DC for ; Wed, 24 Feb 2021 16:18:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183502; 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=H28IyeS7SMu08OVvqYrTbHc1btYcYQt5ED24NR/cmM0=; b=VcN0xrKshzpqJeg1qRj8WjjSD2mO3q4obIVx2alhAXa1vNNxK9wtlPI4vhpBZeRgNg7q6o df/olXuQl5bM8kULg69Q2Zz2JdZs7NWwH2DOqkKOnv4iou0FaESbiRmLxQVUlV3FW7aK7F K5tMdpW1bngMmXVcCSBwwP9QHvGjk0o= X-MC-Unique: b6Cd_vRDNmeKPg0FNYpFyg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 30/33] util: json: Report non-OOM error on yajl failure Date: Wed, 24 Feb 2021 17:17:05 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The yajl library returns a wide range of error codes so reporting OOM on any failure is wrong. In case the error was really based by memory issue the error reporting will probably cause an abort anyways. Change the error message so that we know that it happened in JSON at least. Signed-off-by: Peter Krempa --- src/util/virjson.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index e74b9fca4f..f2a6024db6 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1943,12 +1943,14 @@ virJSONValueToBuffer(virJSONValuePtr object, yajl_gen_config(g, yajl_gen_validate_utf8, 1); if (virJSONValueToStringOne(object, g) < 0) { - virReportOOMError(); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to convert virJSONValue to yajl data")); goto cleanup; } if (yajl_gen_get_buf(g, &str, &len) !=3D yajl_gen_status_ok) { - virReportOOMError(); + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to format JSON")); goto cleanup; } --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183544; cv=none; d=zohomail.com; s=zohoarc; b=HOcrlOE8VwHgy9xv8DD+WGz46ZH5gbO15jC2zAah4xN0ERfuGIOuGpf23To3j9ZC1DFNIVRmAMt0AjVfbwT3qQC0pjMDXpM1Z6WPWrcGl5A5EY2wClLZtgHASUSgSY06+TZVpEOh3frgbX6ydsRuNnw05oMTySqRUaclEVD+k9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183544; 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=0jkHwOpE0PXKaM8TkzRmrj/qhKZ3fESEzXu9Es+YUgs=; b=kAQuhGF62S1PQHKH8nhQgQfTGaJ7PUAwc9ZIJHsBodQaHPjHDDrNDGSrdWUizPFp6C8asbXOii62x2J3PVO3GMURi+f0CmO2Emgaf7GJ/ZCA07dVsYgWdh9j22WAqhpxnj9AuhxhAxiCEhu1Drrg1YczP97zkQnyh+wGcd2PsR8= 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) 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 1614183544919285.616941497865; Wed, 24 Feb 2021 08:19: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-378-js15b8l1M0mLFGNwcvZIzw-1; Wed, 24 Feb 2021 11:18:41 -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 BF3875074B; Wed, 24 Feb 2021 16:18:35 +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 9CB0C5D9E2; Wed, 24 Feb 2021 16:18:35 +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 5C6E618077DE; Wed, 24 Feb 2021 16:18:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGIC3r016194 for ; Wed, 24 Feb 2021 11:18:12 -0500 Received: by smtp.corp.redhat.com (Postfix) id 42CD8646DC; Wed, 24 Feb 2021 16:18:12 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91BC16EF46 for ; Wed, 24 Feb 2021 16:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183543; 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=0jkHwOpE0PXKaM8TkzRmrj/qhKZ3fESEzXu9Es+YUgs=; b=JtMDPY4+C/6dp4XZXt++56oA3aiI8AyJQ1PUp7zeOerp/sqVnh0QvF3FgBdRu3xVLk4Gjv fXHDMz1Oo2jP/CKRqx/CA9oUGHoG/GGiGWcwwlojgrkRhim95NwW+17ifxVHoqb6JpWTZ1 rRGC3Juhjlav1z+0WYyzY11hOL4zFsQ= X-MC-Unique: js15b8l1M0mLFGNwcvZIzw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 31/33] storage: Don't report OOM error on failure of glfs_new Date: Wed, 24 Feb 2021 17:17:06 +0100 Message-Id: <2bbe86cb59cc5e053b96f3077e90aa9e63b5602c.1614182583.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" OOM isn't the only failure glfs_new can encounter. Report an error which might give more insight. libgfapi seems to be setting errno but reporting a system error migt be misleading. Signed-off-by: Peter Krempa --- src/storage/storage_backend_gluster.c | 3 ++- src/storage_file/storage_file_backend_gluster.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 8de0cb8a6b..e673922df6 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -114,7 +114,8 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) /* Actually connect to glfs */ if (!(ret->vol =3D glfs_new(ret->volname))) { - virReportOOMError(); + virReportError(VIR_ERR_OPERATION_FAILED, + _("failed to create glfs object for '%s'"), ret->vo= lname); goto error; } diff --git a/src/storage_file/storage_file_backend_gluster.c b/src/storage_= file/storage_file_backend_gluster.c index 9b3b783274..8c7a583886 100644 --- a/src/storage_file/storage_file_backend_gluster.c +++ b/src/storage_file/storage_file_backend_gluster.c @@ -120,7 +120,8 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr sr= c) (unsigned int)drv->uid, (unsigned int)drv->gid); if (!(priv->vol =3D glfs_new(src->volume))) { - virReportOOMError(); + virReportError(VIR_ERR_OPERATION_FAILED, + _("failed to create glfs object for '%s'"), src->vo= lume); goto error; } --=20 2.29.2 From nobody Wed May 8 02:33:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1614183525; cv=none; d=zohomail.com; s=zohoarc; b=CchrX6jc0njNmbQXvgQhWEfgiqXRWomu3dJpsyzGMSX3HaHspvPP5eUoFW5Ijl64Euvuhe+hl5AWuENhR4AhHENYrYzLJ/2zARWkzkvHXwJI6HWibuLh2x6BXHKVmA94FFftLPUyOVVvrdgZxJTzry8pH7k8D3b5ou6Jgfe9+LM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183525; 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=IduAvMGMBKejlwSV9yunVawySfebq6bf0uKzaZEx0aE=; b=GdGTruF+plCqyBix2n3/Iml6OUQy80YjopvryBUrgcETjOFbpRGJc9rt4dVTw1VWEW18cextmbDGCToP6p6CS9zfUhNTOn44o+apQv2ArRJhzVbVKVB1ORQpFqU19UZWvNYop+bmY4ALxNHH+DljpqBmMMZHJoa3yeOfkEAvuKY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614183525194856.9396752673385; Wed, 24 Feb 2021 08:18:45 -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-392-MR7QBXvYMCu914dn0s3C_g-1; Wed, 24 Feb 2021 11:18:41 -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 DE9AB18E6FC3; Wed, 24 Feb 2021 16:18:35 +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 BBC0059443; Wed, 24 Feb 2021 16:18:35 +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 8149758087; Wed, 24 Feb 2021 16:18:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGIFHU016277 for ; Wed, 24 Feb 2021 11:18:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 601D2646DC; Wed, 24 Feb 2021 16:18:15 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7701176E0E for ; Wed, 24 Feb 2021 16:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183524; 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=IduAvMGMBKejlwSV9yunVawySfebq6bf0uKzaZEx0aE=; b=BbCnCVJqYqkKC/X0xqjgONNfY2K9xvfEBQ8ltdN8QpICp+5ICOagmuQ+DdTd+t3NaQcJiO nssntcuE7DJnZfjptKcFHfj9M1k6yJUKhAG9h4L+fd7Pnfe+b1Loiz9K67elwaGAf1n5Hq yyFMq4t2NKVrteTQIS9vD/XHPxk55OM= X-MC-Unique: MR7QBXvYMCu914dn0s3C_g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 32/33] virVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic Date: Wed, 24 Feb 2021 17:17:07 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.11 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function has also non-OOM failure case when the passed string has 0 length, so reporting OOM error is not correct. Signed-off-by: Peter Krempa --- src/vmx/vmx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index e6c0900a65..73bf7c4f3d 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -781,12 +781,8 @@ virVMXConvertToUTF8(const char *encoding, const char *= string) return NULL; } - if (!(input =3D xmlBufferCreateStatic((char *)string, strlen(string)))= ) { - virReportOOMError(); - goto cleanup; - } - - if (xmlCharEncInFunc(handler, utf8, input) < 0) { + if (!(input =3D xmlBufferCreateStatic((char *)string, strlen(string)))= || + xmlCharEncInFunc(handler, utf8, input) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not convert from %s to UTF-8 encoding"), e= ncoding); goto cleanup; --=20 2.29.2 From nobody Wed May 8 02:33:35 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=1614183526; cv=none; d=zohomail.com; s=zohoarc; b=l1CgKjuZsSDF+pE6Y6v/Gp3KhFjfgrUSKXmQ19Tq0TmO2J8AEKBDLM6Rw3BVut2W+1diTQe1+NqrGqqaBE7B2K1qpDC/6whnHMO3tFMPYlMsHbZeHra5g8FA3JfaZkXXRCXlm2hEy5p3yJMTXcRgUI0z5Kx25N2n7Ay8JqAZa1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614183526; 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=z0BoWR2nLHk522mlW2qfrTB7k6bLFPqD38cQfD7oM7Q=; b=L/NjkI5A7UTVq+KsIbKHGYTbUyAOYrzU1a3ho55UlSSP5nBLKGQQRnfdZohqxrurI15sX+ABfX+TfR7J5ej9cuepdSU1UW4wAqK1kV61g2Cx9mVi5z3qclRtraOyP70yeVTyOsqNecMMx9LfhH17AKv0UtZAKi+ea1n8RsPwMjI= 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) 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 1614183526448165.84503010434855; Wed, 24 Feb 2021 08:18:46 -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-189-e4AOtCdqNp67pTKdbFV8_g-1; Wed, 24 Feb 2021 11:18:42 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C43285074C; Wed, 24 Feb 2021 16:18:35 +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 9CD745C72F; Wed, 24 Feb 2021 16:18:35 +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 5ADA418077DD; Wed, 24 Feb 2021 16:18:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11OGIGUJ016295 for ; Wed, 24 Feb 2021 11:18:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6E58560CDE; Wed, 24 Feb 2021 16:18:16 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id C362F6E515 for ; Wed, 24 Feb 2021 16:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614183525; 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=z0BoWR2nLHk522mlW2qfrTB7k6bLFPqD38cQfD7oM7Q=; b=JYK2UVHAFWHiD5c032cuByq1TyFdjAwvpwB/wTj2nhqZyo7m6JrPFIJ9P6d5oMkxyRqzBh h9kt9EU5KE71d+J3IRQtVJs2MTvGzLepian7fDvI6XsB3fJJD/K3AyAGiB+wJqu/yaXPY3 cDggvQll0QwNKSCKIymyQQtoSEtxKSU= X-MC-Unique: e4AOtCdqNp67pTKdbFV8_g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 33/33] util: virerror: Remove virReportOOMError Date: Wed, 24 Feb 2021 17:17:08 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.16 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 X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Trying to report an OOM error is pointless since our infrastructure to report error needs to allocate memory to report the error. In addition our code mistakenly reported OOM errors even in cases where a function could fail for another reason, which would make issues harder to debug. Remove the virReportOOMError and backend so that programmers are forced to think about what can happen. In case when there's another failure possible a specific error should be reported and otherwise a direct abort() is better since the logger would abort on g_new anyways. This patch also removes the syntas-check which forces use of virReportOOMError instead of using VIR_ERR_NO_MEMORY with other functions. This allows possible future use when we'd end up in a situation where trying to recover from an OOM would make sense, such as when attempting to allocate a massive buffer. Signed-off-by: Peter Krempa Reviewed-by: Laine Stump --- build-aux/syntax-check.mk | 8 -------- src/libvirt_private.syms | 1 - src/util/virerror.c | 22 ---------------------- src/util/virerror.h | 8 -------- 4 files changed, 39 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index e51877648a..e1ccb74986 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -490,11 +490,6 @@ sc_prohibit_gettext_noop: halt=3D'use N_, not gettext_noop' \ $(_sc_search_regexp) -sc_prohibit_VIR_ERR_NO_MEMORY: - @prohibit=3D'\' \ - halt=3D'use virReportOOMError, not VIR_ERR_NO_MEMORY' \ - $(_sc_search_regexp) - sc_prohibit_PATH_MAX: @prohibit=3D'\' \ halt=3D'dynamically allocate paths, do not use PATH_MAX' \ @@ -1895,9 +1890,6 @@ exclude_file_name_regexp--sc_libvirt_unmarked_diagnos= tics =3D \ exclude_file_name_regexp--sc_po_check =3D ^(docs/|src/rpc/gendispatch\.pl$= $|tests/commandtest.c$$) -exclude_file_name_regexp--sc_prohibit_VIR_ERR_NO_MEMORY =3D \ - ^(build-aux/syntax-check\.mk|include/libvirt/virterror\.h|src/remote/rem= ote_daemon_dispatch\.c|src/util/virerror\.c|docs/internals/oomtesting\.html= \.in)$$ - exclude_file_name_regexp--sc_prohibit_PATH_MAX =3D \ ^build-aux/syntax-check\.mk$$ diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 48f66daab8..7eb37ed797 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2116,7 +2116,6 @@ virLastErrorPrefixMessage; virRaiseErrorFull; virRaiseErrorObject; virReportErrorHelper; -virReportOOMErrorFull; virReportSystemErrorFull; virSetError; virSetErrorLogPriorityFunc; diff --git a/src/util/virerror.c b/src/util/virerror.c index 708081414a..a503cdefdc 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1358,28 +1358,6 @@ void virReportSystemErrorFull(int domcode, errno =3D save_errno; } -/** - * virReportOOMErrorFull: - * @domcode: the virErrorDomain indicating where it's coming from - * @filename: filename where error was raised - * @funcname: function name where error was raised - * @linenr: line number where error was raised - * - * Convenience internal routine called when an out of memory error is - * detected - */ -void virReportOOMErrorFull(int domcode, - const char *filename, - const char *funcname, - size_t linenr) -{ - const char *virerr; - - virerr =3D virErrorMsg(VIR_ERR_NO_MEMORY, NULL); - virRaiseErrorFull(filename, funcname, linenr, - domcode, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR, - virerr, NULL, NULL, -1, -1, virerr, NULL); -} /** * virSetErrorLogPriorityFunc: diff --git a/src/util/virerror.h b/src/util/virerror.h index 9d3e40d65a..da7d7c0afe 100644 --- a/src/util/virerror.h +++ b/src/util/virerror.h @@ -174,14 +174,6 @@ void virReportSystemErrorFull(int domcode, "Unexpected enum value %d for %s", \ value, sizeof((typname)1) !=3D 0 ? #typname : #ty= pname); -void virReportOOMErrorFull(int domcode, - const char *filename, - const char *funcname, - size_t linenr); - -#define virReportOOMError() \ - virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__) - #define virReportError(code, ...) \ virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \ __FUNCTION__, __LINE__, __VA_ARGS__) --=20 2.29.2