From nobody Tue May 13 11:17:06 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 1532639198942890.2419994337698; Thu, 26 Jul 2018 14:06:38 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C3972883C6; Thu, 26 Jul 2018 21:06:21 +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 859AB601A4; Thu, 26 Jul 2018 21:06:21 +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 1F3163F7FF; Thu, 26 Jul 2018 21:06:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL6J9A025570 for ; Thu, 26 Jul 2018 17:06:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 472F73001A68; Thu, 26 Jul 2018 21:06:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A9733001A65 for ; Thu, 26 Jul 2018 21:05:56 +0000 (UTC) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (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 84E7681E05 for ; Thu, 26 Jul 2018 21:05:55 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id v13-v6so1878997pgr.10 for ; Thu, 26 Jul 2018 14:05:55 -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.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:54 -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=bu3WlZVpwZjXmqZ7bXv8JSLKC8wBq6zpY1ur9UImcOE=; b=NlarmDZm6Vcf/ynTw24jWHfjeeLp/LWYO2iDNGCSYAKwn3MLKjxzFMMucuTWgT/yio NxxxkbtxPmja12XAcINjFVzDxyXh/v8gyNDYe4HdyOAKoj6SnbOhuTFee0646nzm7ejp Q3//zBGZAKl9HZZQVE+0XfnID2IOFOx8nE3dYtHrBJgQ6VnJBNCoMA8J7GSOmLbhuIeD lhHKfww0dcZvF7fGpq/c/4jVgpcMYe5G6Y3AnpwZZmRIkw2O3FmYiE8iLgj3KCDduUfq qvlk54BsuZ+Vx0GZ1V+DDrfJH40Z6Vl/hy7Kn/MQm6cUteXYfV8XdymyxmTnphzAYmP6 ra2g== 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=bu3WlZVpwZjXmqZ7bXv8JSLKC8wBq6zpY1ur9UImcOE=; b=FIZ9A5u4pW/UR2C/94XCXFo52rPr1hxfUT0td5ddbWQzuYP/VXGvbqta97iv8ofB2b vu8O3IP6t3Lwu58lZaiXLFyO+xG25K49ctyuV+Cmn8PzdfSnhVBb1KlNZBVXX7tWhe/B ddea41DrrX57lH26ltrBD4QV0qVwOzQp+i13Mwo5Y6rXkak4zdFZtX6DRY2ODQYf2PD6 y6S9509Ld2toxfQ8JfbdXV5D41mJd7fLu9tceZCUEpYVCrYqUXdu9dZ/2+h1nc9peP53 fxYCc5Cr41vyxQeQL2uJ9ET6KO5Z61BAGXhshT8v4th/vYnT7qMnHwXvLu3cCX80vGUT PPew== X-Gm-Message-State: AOUpUlFDEsGvOu/4AsTFuyWb/z+pfRAfkphbvUHLoX7Xfs0ZZ06Iksqp 8IELszMgWiErzbIsn0elhgFQ8xxh X-Google-Smtp-Source: AAOMgpd11T/bydSJjO8EyD0eUdlokhlWWRiYkos8g9qP263sPg3kc/n5itD9PQtl0Jpu5Zb4MwL7ag== X-Received: by 2002:a65:62cd:: with SMTP id m13-v6mr3357926pgv.280.1532639154738; Thu, 26 Jul 2018 14:05:54 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:40 +0530 Message-Id: <1532447562-24010-40-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.25]); Thu, 26 Jul 2018 21:05:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 26 Jul 2018 21:05:55 +0000 (UTC) for IP:'209.85.215.196' DOMAIN:'mail-pg1-f196.google.com' HELO:'mail-pg1-f196.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.389 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.215.196 mail-pg1-f196.google.com 209.85.215.196 mail-pg1-f196.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 39/41] util: kmod: 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.79 on 10.5.11.11 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:06:37 +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/virkmod.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/util/virkmod.c b/src/util/virkmod.c index d981cd4..9d0375b 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -28,8 +28,7 @@ static int doModprobe(const char *opts, const char *module, char **outbuf, char **err= buf) { - int ret =3D -1; - virCommandPtr cmd =3D NULL; + VIR_AUTOPTR(virCommand) cmd =3D NULL; =20 cmd =3D virCommandNew(MODPROBE); if (opts) @@ -42,32 +41,23 @@ doModprobe(const char *opts, const char *module, char *= *outbuf, char **errbuf) virCommandSetErrorBuffer(cmd, errbuf); =20 if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - virCommandFree(cmd); - return ret; + return 0; } =20 static int doRmmod(const char *module, char **errbuf) { - int ret =3D -1; - virCommandPtr cmd =3D NULL; + VIR_AUTOPTR(virCommand) cmd =3D NULL; =20 cmd =3D virCommandNewArgList(RMMOD, module, NULL); virCommandSetErrorBuffer(cmd, errbuf); =20 if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - - cleanup: - virCommandFree(cmd); - return ret; + return 0; } =20 /** --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list