From nobody Mon Dec 15 01:38:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532639131884418.35036386898776; Thu, 26 Jul 2018 14:05:31 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id DA4F828214; Thu, 26 Jul 2018 21:05:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9860260910; Thu, 26 Jul 2018 21:05:29 +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 440D818037FD; Thu, 26 Jul 2018 21:05:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL59s4024783 for ; Thu, 26 Jul 2018 17:05:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF25360C8F; Thu, 26 Jul 2018 21:05:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B50E660C80 for ; Thu, 26 Jul 2018 21:05:09 +0000 (UTC) Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C60A1279B for ; Thu, 26 Jul 2018 21:05:08 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id j26-v6so967471pfi.10 for ; Thu, 26 Jul 2018 14:05:08 -0700 (PDT) Received: from centos.localdomain ([42.106.3.93]) by smtp.gmail.com with ESMTPSA id z10-v6sm3279182pfh.83.2018.07.26.14.05.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=aJpbopE0VruhbIcHy40PuopspIICI4X4Z3WOsG8kqxk=; b=JGgZ9/6whzgDL9SUfENX0Ro0ovGdgtH4Yac27M4mYGLDfpgCGOEJRUZwyL2XYbPTp4 iqmc7G7EUiCmXqBX56L+KzqtUva/vq898AuFWrWs5Z+hwjvCqjj4r30gND3a6v3sqDM6 fC5BH8gXwYwemb28i/ic2zitMae3BE8nnGfA3109XD5goB+yJAc92jzuoiQmoTdbUBo/ IbVM0VzlJXJYnjeeO78s/EFvCPDqBbrqpIS4ns9Wche1rLIGiKX3hwtKDeVyaZ/PJ/0G y/61DLrmru4SohE1TakNC0VdGmIrFG0OnSb7DQGZVmKfij2vsS7837Q4j5M69kr1cAtY 6evw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=aJpbopE0VruhbIcHy40PuopspIICI4X4Z3WOsG8kqxk=; b=l8DCHQzhQs9h60U353EAFZDqcZMGO+Kdn03IZwk/F5JvcV4k55WqArqi9Yd+uTBfVr wngyOL7UneDlTOjH67V/Ts7etZ7rNF85Ynl520trX2WrHmkZcpOzbzCmcf+KtXrRbLcS kkiIxbXZSSfFOJprW1f9nY1j4/WT1qDkHhXIFSB7PqzSBLZ+r/LieriAe3IAtEwoHPuU 2oDVSFLU4iU0cEMOpWO14mjjhNXGkRge7V69gJadxjuVUdPD5bh9PsiLOx7OeSGz/KiQ w8jhG1x78FezWtHFROcvAuABcqzgzqBLqRzGkIhvlyObofuxzsOQiQOVBb4rcwKOOUJI s80Q== X-Gm-Message-State: AOUpUlEpu9SYWM5SOGHfZh7YIt9mNF817TbOTht7SDPpfg83XwoLrFLX g/LVGgKxf0ZoQ3d2TLJa2HYff1om X-Google-Smtp-Source: AAOMgpeyl3/SdVxpPLJ+KvBG1znvGri/mk00cmP2zQgRaMK8C0xzYoFTwAJ9eBIW9eTpMvCpFDmwdw== X-Received: by 2002:a63:6d8b:: with SMTP id i133-v6mr3406897pgc.215.1532639107278; Thu, 26 Jul 2018 14:05:07 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:16 +0530 Message-Id: <1532447562-24010-16-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> References: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jul 2018 21:05:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jul 2018 21:05:08 +0000 (UTC) for IP:'209.85.210.178' DOMAIN:'mail-pf1-f178.google.com' HELO:'mail-pf1-f178.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.39 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.210.178 mail-pf1-f178.google.com 209.85.210.178 mail-pf1-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 15/41] util: firewall: use VIR_AUTOFREE instead of VIR_FREE for scalar types 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 26 Jul 2018 21:05:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- src/util/virfirewall.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index dfd792f..b4a4d06 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -511,7 +511,7 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firewal= l, virFirewallRulePtr rule, const char *fmt, ...) { - char *arg; + VIR_AUTOFREE(char *) arg =3D NULL; va_list list; =20 VIR_FIREWALL_RULE_RETURN_IF_ERROR(firewall, rule); @@ -525,13 +525,11 @@ void virFirewallRuleAddArgFormat(virFirewallPtr firew= all, =20 va_end(list); =20 - VIR_FREE(arg); return; =20 no_memory: firewall->err =3D ENOMEM; va_end(list); - VIR_FREE(arg); } =20 =20 @@ -678,7 +676,7 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule, virCommandPtr cmd =3D NULL; int status; int ret =3D -1; - char *error =3D NULL; + VIR_AUTOFREE(char *) error =3D NULL; =20 if (!bin) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -702,11 +700,10 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule, if (ignoreErrors) { VIR_DEBUG("Ignoring error running command"); } else { - char *args =3D virCommandToString(cmd); + VIR_AUTOFREE(char *) args =3D virCommandToString(cmd); virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to apply firewall rules %s: %s"), NULLSTR(args), NULLSTR(error)); - VIR_FREE(args); VIR_FREE(*output); goto cleanup; } @@ -714,7 +711,6 @@ virFirewallApplyRuleDirect(virFirewallRulePtr rule, =20 ret =3D 0; cleanup: - VIR_FREE(error); virCommandFree(cmd); return ret; } @@ -807,12 +803,11 @@ virFirewallApplyRule(virFirewallPtr firewall, virFirewallRulePtr rule, bool ignoreErrors) { - char *output =3D NULL; + VIR_AUTOFREE(char *) output =3D NULL; + VIR_AUTOFREE(char *) str =3D virFirewallRuleToString(rule); char **lines =3D NULL; int ret =3D -1; - char *str =3D virFirewallRuleToString(rule); VIR_INFO("Applying rule '%s'", NULLSTR(str)); - VIR_FREE(str); =20 if (rule->ignoreErrors) ignoreErrors =3D rule->ignoreErrors; @@ -857,7 +852,6 @@ virFirewallApplyRule(virFirewallPtr firewall, ret =3D 0; cleanup: virStringListFree(lines); - VIR_FREE(output); return ret; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list