From nobody Tue May 7 13:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1577977273; cv=none; d=zohomail.com; s=zohoarc; b=ADqxCxz2blwchp1W7qm4nIVk6DfVvCBMpDeW9BM/SxSSGIaM2Z0zEbv6ovNI/5rF75PqKoXhjMK2SIheovtjCbJ6wcm7616PL10lLny0sUxKVNQ7BZvCYkPu7Tn+POAG7tgPafbIMi1EqxVTdT+qdMNVz62nmLx5u6XaalyRiXo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977273; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IzdFXTur4G/m4Zs+7QZH+g6RT89gk36pP+q/A1pKfbs=; b=W2EYVzP5mm9JZbX95dVl4LyEAUWMFNqiL06IrGaYWViFq7TGgMhSprL2jrt0OUqm61kF7MlLGFvZA0Jsn4AWbb2VM1sfnfW+w0ghjEtRUjT5U6Xxa9rvEDdCBwNCcmIikMjYULOVQOgZyEwdVmG5qZUdMGiCRI1gHF/Z2FWM29I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1577977273516282.99175448031554; Thu, 2 Jan 2020 07:01:13 -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-370-gjND43r9MEWSon2gj40qaA-1; Thu, 02 Jan 2020 10:01:07 -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 D8877110E111; Thu, 2 Jan 2020 15:00:58 +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 AC9D064435; Thu, 2 Jan 2020 15:00: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 5CAEF81E34; Thu, 2 Jan 2020 15:00:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 002F0hhW005786 for ; Thu, 2 Jan 2020 10:00:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3044519C5B; Thu, 2 Jan 2020 15:00:43 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80ED119C4F; Thu, 2 Jan 2020 15:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977272; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IzdFXTur4G/m4Zs+7QZH+g6RT89gk36pP+q/A1pKfbs=; b=aDR7dyuJ704/GoX4iKyCcVXjnDL7+bhuV7UPMZy4Krs/EqhgawSRogccELHDIUvcc1mR1P QXIofcjYT7DYVGO1eHRZwvXYhKDvg/GS/l8bb40HEuDPOWs6Jzf21qGRpseekO3XIIs0jI CmCk/M19KpXGvtW1l7L0K9hGKRuhzTI= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 16:00:31 +0100 Message-Id: <20200102150035.1085486-2-fidencio@redhat.com> In-Reply-To: <20200102150035.1085486-1-fidencio@redhat.com> References: <20200102150035.1085486-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH v2 1/5] util: Don't set/check for ENOMEM as a firewall error X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: gjND43r9MEWSon2gj40qaA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As libvirt decided to take the path to not report OOM and simply abort when it happens, let's not set nor check for ENOMEM firewall's error and simplify the code whenever it's possible. Signed-off-by: Fabiano Fid=C3=AAncio --- src/util/virfirewall.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index ee72b579e4..6f7b5306e5 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -391,7 +391,6 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, return rule; =20 no_memory: - firewall->err =3D ENOMEM; virFirewallRuleFree(rule); return NULL; } @@ -492,10 +491,8 @@ void virFirewallRuleAddArg(virFirewallPtr firewall, =20 ADD_ARG(rule, arg); =20 - return; - no_memory: - firewall->err =3D ENOMEM; + return; } =20 =20 @@ -514,10 +511,8 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewa= ll, =20 ADD_ARG(rule, arg); =20 - return; - no_memory: - firewall->err =3D ENOMEM; + return; } =20 =20 @@ -532,10 +527,8 @@ void virFirewallRuleAddArgSet(virFirewallPtr firewall, args++; } =20 - return; - no_memory: - firewall->err =3D ENOMEM; + return; } =20 =20 @@ -553,12 +546,7 @@ void virFirewallRuleAddArgList(virFirewallPtr firewall, while ((str =3D va_arg(list, char *)) !=3D NULL) ADD_ARG(rule, str); =20 - va_end(list); - - return; - no_memory: - firewall->err =3D ENOMEM; va_end(list); } =20 @@ -591,15 +579,13 @@ void virFirewallStartTransaction(virFirewallPtr firew= all, =20 VIR_FIREWALL_RETURN_IF_ERROR(firewall); =20 - if (!(group =3D virFirewallGroupNew())) { - firewall->err =3D ENOMEM; + if (!(group =3D virFirewallGroupNew())) return; - } + group->actionFlags =3D flags; =20 if (VIR_EXPAND_N(firewall->groups, firewall->ngroups, 1) < 0) { - firewall->err =3D ENOMEM; virFirewallGroupFree(group); return; } @@ -747,10 +733,6 @@ virFirewallApplyRule(virFirewallPtr firewall, if (rule->queryCB(firewall, rule->layer, (const char *const *)line= s, rule->queryOpaque) < 0) return -1; =20 - if (firewall->err =3D=3D ENOMEM) { - virReportOOMError(); - return -1; - } if (firewall->err) { virReportSystemError(firewall->err, "%s", _("Unable to create rule")); @@ -818,7 +800,7 @@ virFirewallApply(virFirewallPtr firewall) _("Failed to initialize a valid firewall backend")); goto cleanup; } - if (!firewall || firewall->err =3D=3D ENOMEM) { + if (!firewall) { virReportOOMError(); goto cleanup; } --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 13:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1577977258; cv=none; d=zohomail.com; s=zohoarc; b=Ei0sCmUJHYZQqT3Ki3WUu3YS4Z/YKV86GtReyMOCQk7dXPWZgmu7w86L2TdqJ/m/qKT8f73F3aBHQ5J1UGdu27tdxh5jlaLUv/BTiHBUmo9oEHBlShTXxA/F0vEqCpUocAZV6tkgkW6CBvtw8lzBttlWjFIyc+VIuZ86a6c4iSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977258; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vu0CaNYgllCNzGLeDjin7NNp12a6R2tt+pYR2trLdiw=; b=c+Mi7VanTL9410RBf01hG7mhZLsXoCpPbbU7BYNimHirv95ouAjXUr5RBMAWvlB5fdVXn+kEyjBOlhjANyvoQ7Fz+pmFzl5Riw+3C/+P9TGELoVwtkhaK1R/sNiX2FwGrgn+emp7243H2btfQNNspIqiknxghDtuqJTp2cz23c8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1577977258077532.5180935506066; Thu, 2 Jan 2020 07:00:58 -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-391-hwvNm2LiMvaNJ2YMlLluIw-1; Thu, 02 Jan 2020 10:00:55 -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 71B23CF035; Thu, 2 Jan 2020 15:00:49 +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 0CF56108130C; Thu, 2 Jan 2020 15:00: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 A3B1981E2E; Thu, 2 Jan 2020 15:00:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 002F0iXg005799 for ; Thu, 2 Jan 2020 10:00:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3037719C5B; Thu, 2 Jan 2020 15:00:44 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 800B619C4F; Thu, 2 Jan 2020 15:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977257; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vu0CaNYgllCNzGLeDjin7NNp12a6R2tt+pYR2trLdiw=; b=JEvc5aAtx9giWrtbYEDLq+gE7B/9vrF7wnTqNytFBNqrcNe7c9dpWO7Do5cxTTJqO6fWAv R8kXISkRGJk46maqQbSpRjiAYGILp5WdymP7nYCE0+k1IDyFlLMuexnxroNGlyXyu5T1Ht Z7bRBClH/4hLO3u6Ml3CJ8l/3B+NlN0= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 16:00:32 +0100 Message-Id: <20200102150035.1085486-3-fidencio@redhat.com> In-Reply-To: <20200102150035.1085486-1-fidencio@redhat.com> References: <20200102150035.1085486-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH v2 2/5] util: Use g_auto/g_autofree in virFirewallAddRuleFullV() 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 X-MC-Unique: hwvNm2LiMvaNJ2YMlLluIw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Fabiano Fid=C3=AAncio --- src/util/virfirewall.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 6f7b5306e5..2177617ecf 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -257,6 +257,7 @@ virFirewallRuleFree(virFirewallRulePtr rule) VIR_FREE(rule); } =20 +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(virFirewallRulePtr, virFirewallRuleFree, N= ULL); =20 static void virFirewallGroupFree(virFirewallGroupPtr group) @@ -335,8 +336,8 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, va_list args) { virFirewallGroupPtr group; - virFirewallRulePtr rule; - char *str; + g_auto(virFirewallRulePtr) rule =3D NULL; + g_autofree char *str =3D NULL; =20 VIR_FIREWALL_RETURN_NULL_IF_ERROR(firewall); =20 @@ -348,7 +349,7 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, =20 =20 if (VIR_ALLOC(rule) < 0) - goto no_memory; + return NULL; =20 rule->layer =3D layer; rule->queryCB =3D cb; @@ -379,19 +380,18 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, if (VIR_APPEND_ELEMENT_COPY(group->rollback, group->nrollback, rule) < 0) - goto no_memory; + return NULL; } else { if (VIR_APPEND_ELEMENT_COPY(group->action, group->naction, rule) < 0) - goto no_memory; + return NULL; } =20 =20 - return rule; + return g_steal_pointer(&rule); =20 no_memory: - virFirewallRuleFree(rule); return NULL; } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 13:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1577977277; cv=none; d=zohomail.com; s=zohoarc; b=UosKjJO1ogAKxQwiODFYDAWZcHnRGmS4ULaHRhpUZXQcj5nW9+/rtVTN5LYIwKzDTYFoYD5Ib5mgST8GhunxI650KSJ9B2R71ah6eM78Pa2TVSi3oJtvuVzNxWTFjBkQJE+6XY2F5SqP01QMMmpgRqNDvQMUKkI3iIWfuaCdE1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977277; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fecbERUxOZ3ks5UsMdQYkojP69sTDxIn/gqrPXejwLU=; b=VppxfuwCbm/OJYsKi+eZbxCd5XCwbS5yS96ZWifN6BWCWkd9oyyA/f8t0hY2kLCYxBYvDv9iAEjayC9E/xCdBEsYjTl2+n4MI6OyPnOW2vqrG2C+XPcdNUGqC8e5xVwzLWYdfqiqK+wGQEdKRJydwvf17P98X5ZiBnV5GwSy9Sk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 157797727749022.675925999962942; Thu, 2 Jan 2020 07:01: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-319-P5SDV0kDMN-qREJ9cMRA0w-1; Thu, 02 Jan 2020 10:01:13 -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 A603C100634; Thu, 2 Jan 2020 15:01:04 +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 68A7060BF4; Thu, 2 Jan 2020 15:01: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 EB11418034EA; Thu, 2 Jan 2020 15:01:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 002F0j5S005809 for ; Thu, 2 Jan 2020 10:00:45 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2CB9919C5B; Thu, 2 Jan 2020 15:00:45 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E53519C4F; Thu, 2 Jan 2020 15:00:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977276; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fecbERUxOZ3ks5UsMdQYkojP69sTDxIn/gqrPXejwLU=; b=bqtHAbACn0gydTyp3vbFq3PWm0tHIyRw+8zc5vjVebEtviCCsOYtPb4SeBkwPNRMvRj/t3 IN9l3cuHnV7TNfm64e4AQaherSMq9Dk2qYrwj9tuLqiFYQr/yzNTTKPoZtVTzUWboDUwPs M1y8pAEIrAAINat6b9+sdYEtPKMFubw= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 16:00:33 +0100 Message-Id: <20200102150035.1085486-4-fidencio@redhat.com> In-Reply-To: <20200102150035.1085486-1-fidencio@redhat.com> References: <20200102150035.1085486-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH v2 3/5] util: Use g_auto in virFirewallStartTransaction() X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: P5SDV0kDMN-qREJ9cMRA0w-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: Fabiano Fid=C3=AAncio --- src/util/virfirewall.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 2177617ecf..564e2fe0be 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -278,6 +278,7 @@ virFirewallGroupFree(virFirewallGroupPtr group) VIR_FREE(group); } =20 +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(virFirewallGroupPtr, virFirewallGroupFree,= NULL); =20 /** * virFirewallFree: @@ -575,7 +576,7 @@ size_t virFirewallRuleGetArgCount(virFirewallRulePtr ru= le) void virFirewallStartTransaction(virFirewallPtr firewall, unsigned int flags) { - virFirewallGroupPtr group; + g_auto(virFirewallGroupPtr) group =3D NULL; =20 VIR_FIREWALL_RETURN_IF_ERROR(firewall); =20 @@ -586,10 +587,9 @@ void virFirewallStartTransaction(virFirewallPtr firewa= ll, =20 if (VIR_EXPAND_N(firewall->groups, firewall->ngroups, 1) < 0) { - virFirewallGroupFree(group); return; } - firewall->groups[firewall->ngroups - 1] =3D group; + firewall->groups[firewall->ngroups - 1] =3D g_steal_pointer(&group); firewall->currentGroup =3D firewall->ngroups - 1; } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 13:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1577977266; cv=none; d=zohomail.com; s=zohoarc; b=ihIgJHt0dnQ4/0/rLOJ5v+bspoqo7A9XL2MrI4EHEmgx9f0SNFtpJTQZ4yB/wbE3OqTzQlDiGRZbaxmvsfx6p0I28c/ZlQAIfGi2mxaqKO7n25qjT/fSKqEI74YAefzfkhsFSfuQrW8fgxvdaNvHwKDpn8selLTqMtRfk4xO/Ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977266; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XzeWGw3ztd7XPpjem1vHsguE2IN2in3UlOhd025zb9I=; b=jzsCckB06bYUEJzPEW8uPPHS9Azvv+QyKcAiRkL0mpYI/DzBVXwOM0E2VvK9/wDc9W/7y+Ogj07Cdfr29TfF2pemg37bsLZMHX/BNyhhGr9MHlLr48QGSQ90SaTQ0jJ6aTLerCIohnPL1obTpPgbKGiLXnqBnyasus2vM9w/fSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1577977266290932.4158335354941; Thu, 2 Jan 2020 07:01: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-357-rkCaNz4PMKS982NkmedBug-1; Thu, 02 Jan 2020 10:01:03 -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 74667109A91D; Thu, 2 Jan 2020 15:00: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 33F417E48D; Thu, 2 Jan 2020 15:00: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 C8AF381E32; Thu, 2 Jan 2020 15:00:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 002F0kG1005816 for ; Thu, 2 Jan 2020 10:00:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2944D19C5B; Thu, 2 Jan 2020 15:00:46 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B11019C4F; Thu, 2 Jan 2020 15:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977265; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=XzeWGw3ztd7XPpjem1vHsguE2IN2in3UlOhd025zb9I=; b=ACSofDUP5hCxk3WeuD+TXxYVnYvQzVZ/vpNJiGlOwNeYSO8pXCHNKfRZ64lGsitic7yh0Y 8AbPBRPLYR9RM0Lj4JtVwV0Fnf+gJm7bCJU4WZIUUielD/t3199SWkOExLyT17zzVOf9Pb fJ+cZ851FZgfD2LwcEYYFwfvVKmXJ1A= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 16:00:34 +0100 Message-Id: <20200102150035.1085486-5-fidencio@redhat.com> In-Reply-To: <20200102150035.1085486-1-fidencio@redhat.com> References: <20200102150035.1085486-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH v2 4/5] util: Adapt ADD_ARG() macro X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: rkCaNz4PMKS982NkmedBug-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) As VIR_RESIZE_N() macro already aborts in case of OOM, there's no reason to check for its output in the ADD_ARG() macro. By doing this, we can simply get rid of a all no_memory labels spread in the virfirewall.c file. Signed-off-by: Fabiano Fid=C3=AAncio --- src/util/virfirewall.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 564e2fe0be..7c8040880c 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -320,11 +320,9 @@ void virFirewallFree(virFirewallPtr firewall) =20 #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) =20 @@ -391,9 +389,6 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, =20 =20 return g_steal_pointer(&rule); - - no_memory: - return NULL; } =20 =20 @@ -491,9 +486,6 @@ void virFirewallRuleAddArg(virFirewallPtr firewall, VIR_FIREWALL_RULE_RETURN_IF_ERROR(firewall, rule); =20 ADD_ARG(rule, arg); - - no_memory: - return; } =20 =20 @@ -511,9 +503,6 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewal= l, va_end(list); =20 ADD_ARG(rule, arg); - - no_memory: - return; } =20 =20 @@ -527,9 +516,6 @@ void virFirewallRuleAddArgSet(virFirewallPtr firewall, ADD_ARG(rule, *args); args++; } - - no_memory: - return; } =20 =20 @@ -547,7 +533,6 @@ void virFirewallRuleAddArgList(virFirewallPtr firewall, while ((str =3D va_arg(list, char *)) !=3D NULL) ADD_ARG(rule, str); =20 - no_memory: va_end(list); } =20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 13:39:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1577977287; cv=none; d=zohomail.com; s=zohoarc; b=gBUSdl4TbSyqwKn3NVxdNePMqNUCL/1O220N9SVaEXh2EhsnWNctQkvfxijXZDzaOIflMoH7d/mOs1FCE9rMg+OFrEU7oB4e6+F+3nyZYEdsXPiLbCsq0U3xClL08b0hp1pLKYQGZ1h6jm9Q954QadaF7EQxc/twZ6VaKUw10YA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577977287; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LnO+bYWhM7gORuxEfakcj6DSed7RHDfarm+CjhaAkJA=; b=VFYM4iJ7+KGJR1LrAEUARXWDmMNHd1NgKuTdxGO59O2NgRy9xWHXmRHp+5YQv8qPKYUaLZvJMdaZFu6LooD111CY3DIGR/FP6XhER/TWccLgMIr70LI/4ya38Arhs0n1PNAE+SzyhLC0c4fvohaykQ7ox/ScLHpLcEgmR0PrPkw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1577977287188621.9129502090399; Thu, 2 Jan 2020 07:01:27 -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-208-C_FXe7i0O5-uxgURZRqiWA-1; Thu, 02 Jan 2020 10:01:22 -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 28E988E21CF; Thu, 2 Jan 2020 15:01:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFEAB7E48D; Thu, 2 Jan 2020 15:01: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 8D44F18034EE; Thu, 2 Jan 2020 15:01:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 002F0lZk005822 for ; Thu, 2 Jan 2020 10:00:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 28F0419C5B; Thu, 2 Jan 2020 15:00:47 +0000 (UTC) Received: from laerte.redhat.com (unknown [10.43.2.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 772F119C4F; Thu, 2 Jan 2020 15:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1577977285; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LnO+bYWhM7gORuxEfakcj6DSed7RHDfarm+CjhaAkJA=; b=THa4E6ryZImyiKULjg378oQ0ppkM+g1iMY+OMJhuZ06pU23O14R26BSkqzUnDHP95JVUry ITNueqcv5f4GW6IeVWrbJoxQFC9ruRxC6sxkiQRuGgahrr/lnMqDs5IYeDxL5s+NhujHUy zURsgUO8J8fivoq53Wrf846DTa3qKjs= From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= To: libvir-list@redhat.com Date: Thu, 2 Jan 2020 16:00:35 +0100 Message-Id: <20200102150035.1085486-6-fidencio@redhat.com> In-Reply-To: <20200102150035.1085486-1-fidencio@redhat.com> References: <20200102150035.1085486-1-fidencio@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Subject: [libvirt] [PATCH v2 5/5] docs: Remove mention to no_memory label X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: C_FXe7i0O5-uxgURZRqiWA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) no_memory labels have been entirely removed from libvirt code base. Knowing that, let's also remove any mention to the label from our hacking guide. Signed-off-by: Fabiano Fid=C3=AAncio --- docs/hacking.html.in | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/hacking.html.in b/docs/hacking.html.in index 74aba5d46b..90bd0ddc81 100644 --- a/docs/hacking.html.in +++ b/docs/hacking.html.in @@ -1491,7 +1491,6 @@ BAD:
       error: A path only taken upon return with an error code
     cleanup: A path taken upon return with success code + optional error
-  no_memory: A path only taken upon return with an OOM error code
       retry: If needing to jump upwards (e.g., retry on EINTR)
 
=20 --=20 2.24.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list