From nobody Sun Feb 8 18:30:05 2026 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 1532174977169577.5634934658144; Sat, 21 Jul 2018 05:09:37 -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 DCC7A5F728; Sat, 21 Jul 2018 12:09: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 878B9608F2; Sat, 21 Jul 2018 12:09:34 +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 012E14EE0F; Sat, 21 Jul 2018 12:09:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6LC8Gwn016397 for ; Sat, 21 Jul 2018 08:08:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id B45A4C4A64; Sat, 21 Jul 2018 12:08:16 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB41CCC112 for ; Sat, 21 Jul 2018 12:08:16 +0000 (UTC) Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (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 C3495307C946 for ; Sat, 21 Jul 2018 12:08:05 +0000 (UTC) Received: by mail-pg1-f170.google.com with SMTP id e6-v6so8969000pgv.2 for ; Sat, 21 Jul 2018 05:08:05 -0700 (PDT) Received: from centos.localdomain ([42.106.1.69]) by smtp.gmail.com with ESMTPSA id s16-v6sm5861694pfm.114.2018.07.21.05.08.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 05:08:04 -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=SscAtlEfcPdzxvglFSeVF6kgcJj+ZEM1gHFKxb2XuCk=; b=Rs+WkyLtwe/U/jw+I+R4TrCqt4URD1hPGgGx87atxToM+cLXdwkdFZeGytwBmWOmxX snlQJvgHRnGLTkppWE7s56s6S51bCLSUEjLy/XpnzeDF921+cDdXY9ol5eFpEfOskEsu /6+I7gw67yude01a3Oprs95dzhCbw6TfTWsfcv5hvmf237vqrVwcPik/15wexPBc3uAN bjS55u17bC7pb4c019ZzW4Mzo1o4bSqwf0f9vUqW308JpW7kOJFZxd/hkNvk/w5btxbG grh2cXVoxgk79UELSwGohoXhHkmKOjzyjuAScy1fXI6tOyLOg2GyVEWHzK88dkE9ddGH jvtA== 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=SscAtlEfcPdzxvglFSeVF6kgcJj+ZEM1gHFKxb2XuCk=; b=Kg3xRL9P2wW7sZbDMJjVL3+LqX4bd/QZJVkWXYBcyQcoepxFI7rUjmfFlx0K05JASp IfCggD9gXFMX61IGl3Y3AasDmMONCuoSAeXDQg4O0X1w+pmqv8KEdm9+JY0uFHD+hWKm w8Oud6wL/0fxVwk0Lca3RChlux1ypVCQ1zfd5LeCitymORxzFC+Bey/OTrFKWMrACFif Wup0y5wClFg9pySTjCKtMh218lDtzM9GXcVJApTYd8AoP4W5aJbcZv1MGaShAtdhEQLY cl3lOVjpuWscxiqmHcwl+mTIJW+8anM7v3ScpZl2uewt75kRvEnkhJ+whIT360WV2wYX L0jg== X-Gm-Message-State: AOUpUlFmwqFmhYB0B4ajXdvwePAZ8YbWtNywX2BMyxbp0MIkc8vj40Dd MyB/yht6lVSUfZMYP4WbNN68IaTt X-Google-Smtp-Source: AAOMgpcwtk1LdLbVXd0xPxxthPE4AkzJNUcUPEU3kig8mfcQl2OtMllPQ/7sPNWHQ5ZdgPFtGwoVhQ== X-Received: by 2002:a62:3ece:: with SMTP id y75-v6mr5885649pfj.7.1532174885074; Sat, 21 Jul 2018 05:08:05 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 21 Jul 2018 17:36:49 +0530 Message-Id: <1532174832-21644-18-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532174832-21644-1-git-send-email-skrtbhtngr@gmail.com> References: <1532174832-21644-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.46]); Sat, 21 Jul 2018 12:08:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 21 Jul 2018 12:08:05 +0000 (UTC) for IP:'209.85.215.170' DOMAIN:'mail-pg1-f170.google.com' HELO:'mail-pg1-f170.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (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.215.170 mail-pg1-f170.google.com 209.85.215.170 mail-pg1-f170.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 17/40] util: hook: 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.39]); Sat, 21 Jul 2018 12:09:36 +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 Reviewed-by: Erik Skultety --- src/util/virhook.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/util/virhook.c b/src/util/virhook.c index facd74a..51f0eb5 100644 --- a/src/util/virhook.c +++ b/src/util/virhook.c @@ -122,8 +122,7 @@ static int virHooksFound =3D -1; static int virHookCheck(int no, const char *driver) { - char *path; - int ret; + VIR_AUTOFREE(char *) path =3D NULL; =20 if (driver =3D=3D NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -139,18 +138,15 @@ virHookCheck(int no, const char *driver) } =20 if (!virFileExists(path)) { - ret =3D 0; VIR_DEBUG("No hook script %s", path); + return 0; } else if (!virFileIsExecutable(path)) { - ret =3D 0; VIR_WARN("Non-executable hook script %s", path); + return 0; } else { - ret =3D 1; VIR_DEBUG("Found hook script %s", path); + return 1; } - - VIR_FREE(path); - return ret; } =20 /* @@ -233,7 +229,7 @@ virHookCall(int driver, char **output) { int ret; - char *path; + VIR_AUTOFREE(char *) path =3D NULL; virCommandPtr cmd; const char *drvstr; const char *opstr; @@ -318,7 +314,5 @@ virHookCall(int driver, =20 virCommandFree(cmd); =20 - VIR_FREE(path); - return ret; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list