From nobody Tue May 13 18:29:07 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 1530481496631910.2247186380814; Sun, 1 Jul 2018 14:44:56 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A0DFB3082A40; Sun, 1 Jul 2018 21:44: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 6FA2730C43B2; Sun, 1 Jul 2018 21:44: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 22DAE3D3BE; Sun, 1 Jul 2018 21:44: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 w61LiTV4009103 for ; Sun, 1 Jul 2018 17:44:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E265608F6; Sun, 1 Jul 2018 21:44:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04002608F8 for ; Sun, 1 Jul 2018 21:44:28 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) (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 25B094E4C5 for ; Sun, 1 Jul 2018 21:44:18 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id t6-v6so6948473plo.7 for ; Sun, 01 Jul 2018 14:44:18 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:17 -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=tOY/lSEpCM4I6q908+WiXmkAdwpCKC8sP3NS/2fkyt0=; b=UH3A1NhsFrN1RvioSwpjwHKHa0QlQwar0II7avrYFmOXHELUbw6+8EPxIw+HJKWOU0 BIQWHpW5+AATZWyZGfOtb52/EC09Wv24HGVnjwlrRJJu7XHwBGD9x0xR/7qqT736zf2f 9YYyqTpl0XXD06y4wPTz1p0Y5Hc6K6i8ZKk9xrjVHyKxiMU/TgeSIfHGPj9LtRrGG0HN 7cF+8dI7AUHSmX3P8igPhjKqaz88CSLsf2qy53jWrkdiAUuPFQZmBOR0GCSP9ZYhTfEX UEVv3cpPx/mYFtOL2X4mVV5VcLHP/aQ3lTSnjLg0uLhk1qrsKwH2GVgOIlrydS0rXESl SD2A== 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=tOY/lSEpCM4I6q908+WiXmkAdwpCKC8sP3NS/2fkyt0=; b=uXzaRFDcrZIH86FN85sp09SzfAqr/kgsGnViw8thysviHRMjAi5QZpr8ftp9HPBrr3 n3+3BXuW+c5FkKLHOiGIMaJayiIL0YNU0pCIAaRPJSXYF+moraiFKEtkWaues8Pi+QqG Nz4Phm1PbGW1h1ydCuKeKEy8HjrIRGsQ7c5EbNeb/5P0+7w8Tvn0feWZC03weneJ+Bx+ P9P5tqrHhsJmXjIdsMylHtivZEjYURHSfCNFkqiQjoz5n5e6iDOSu9dtUvJ/gozwYVg3 7bQK5k8lvH5ps6zPU8Pl42sfmkXXDJi0OiPgVq6iUZR7ChcRQ/aMixpfCUZgPp5owXg6 eL/A== X-Gm-Message-State: APt69E2tH/xHPM3Vw2vgGsN7IBJIfHHbFjPoQ+mBhIS78iDlhcxl8CgT zb9mF1Mg14q216VS/nd9VnQTXQnj X-Google-Smtp-Source: ADUXVKIlLOI9QQdzWtkG2BvEf3pMvAcvL6c+BiMVwQf3WX83xas6eULQJoYdWTTwZUrdt4HoNR7tVA== X-Received: by 2002:a17:902:a9ca:: with SMTP id b10-v6mr23379825plr.275.1530481457456; Sun, 01 Jul 2018 14:44:17 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:15 +0530 Message-Id: <1530349239-22049-12-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.38]); Sun, 01 Jul 2018 21:44:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:44:18 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.160.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 11/35] util: command: use VIR_AUTOPTR for aggregate 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.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sun, 01 Jul 2018 21:44:56 +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_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/vircommand.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index d328431..6edb4d5 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -823,10 +823,9 @@ int virRun(const char *const*argv, int *status) { int ret; - virCommandPtr cmd =3D virCommandNewArgs(argv); + VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgs(argv); =20 ret =3D virCommandRun(cmd, status); - virCommandFree(cmd); return ret; } =20 @@ -2960,7 +2959,7 @@ virCommandRunRegex(virCommandPtr cmd, int totgroups =3D 0, ngroup =3D 0, maxvars =3D 0; char **groups; VIR_AUTOFREE(char *) outbuf =3D NULL; - char **lines =3D NULL; + VIR_AUTOPTR(virString) lines =3D NULL; int ret =3D -1; =20 /* Compile all regular expressions */ @@ -3039,7 +3038,6 @@ virCommandRunRegex(virCommandPtr cmd, =20 ret =3D 0; cleanup: - virStringListFree(lines); if (groups) { for (j =3D 0; j < totgroups; j++) VIR_FREE(groups[j]); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list