From nobody Tue May 13 11:15:23 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 153263916952911.089447365213573; Thu, 26 Jul 2018 14:06:09 -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 AC3DEC04AC43; Thu, 26 Jul 2018 21:06:07 +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 713553001A7C; Thu, 26 Jul 2018 21:06:07 +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 1A9951800B85; Thu, 26 Jul 2018 21:06:07 +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 w6QL5Gpp024825 for ; Thu, 26 Jul 2018 17:05:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4191C16D23; Thu, 26 Jul 2018 21:05:16 +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 355B119490 for ; Thu, 26 Jul 2018 21:05:12 +0000 (UTC) Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 0A1008762C for ; Thu, 26 Jul 2018 21:05:12 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id y4-v6so1882624pgp.9 for ; Thu, 26 Jul 2018 14:05:12 -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.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:10 -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=A8QqSlcm3hy+uslezMQbZtM+kiYbZm/rWuXEuOCb2/4=; b=EPXjbcfd5bqU5PkWiPtsiZjllDJvMO0Dcn4IiPXRvnAeq2xg+eIFLo69SV4pW8r9AM Vr8+kJUiC4TyQ/Ice1h0UnYjdQV69i9hY8spxj+XldhKDAPjTIPm1WwC0Dc9LwHkMPVO PUArr/WArLipqLxlqHh1VIzG30j5y51E9oTkc0+jtSjucwXTcchryBomJeepR0i9F3ng IxXYiL9TvVuw9D/t87swRpGRHR8Z0XcZsp6xRlW6mndLFwh4SAMKO61u0geAsMwf+rTN 95TmBHYru+3NTi5gvCMonv3WwMUjObgjSfLf6cv09QgymNqSdxbb4/UJvhsjAxPeSDN3 gfSA== 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=A8QqSlcm3hy+uslezMQbZtM+kiYbZm/rWuXEuOCb2/4=; b=d7Hp9neeOwCnwzGzg5VQDftdQvLqZx6vsfmi8o2btByk3zhE+m9Acw/yvkVKgJW0nb aE+NdOPcCE4z0jlBuG2Ttivel7Gs4BfCr3V+yS6WDDGf8wYpqS7+igrKA3EeBGkQmL4f KvpgdtI8C/Odd8a3JIAc/bqN0N0BqDATOzkwlnzvgk7sl5ctgilNT5P81sJOm7XVc40s 8LeBPQPvVS5DukUaA4ZNEGVD0pt6vMYVaiUKFc7ziR0hU02LILtQuGHDGGCBE6n0Fm8p NJjcMcUUeAzxnCVkT04/1AAnvY184LZ/R5yj3yVSMl5hcZ/SQqXf0cDY7OUtqYHnDsRS H4sg== X-Gm-Message-State: AOUpUlGDEm0I0LvoKlH3m37yM4UChVtwX1uIy6ohq9nZzdTTGqe75TXK +GuO0OAzV857+H5FG95Z/jMPb5JD X-Google-Smtp-Source: AAOMgpdY8YE63xAVk0IAKvcreR2OoOva43nRf1PDb8oyBUm2O8iPtXYnS1j9vSvLbLQqTKQGwzpu+A== X-Received: by 2002:a62:45d2:: with SMTP id n79-v6mr3643334pfi.137.1532639111240; Thu, 26 Jul 2018 14:05:11 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:18 +0530 Message-Id: <1532447562-24010-18-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:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jul 2018 21:05:12 +0000 (UTC) for IP:'209.85.215.182' DOMAIN:'mail-pg1-f182.google.com' HELO:'mail-pg1-f182.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.37 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.215.182 mail-pg1-f182.google.com 209.85.215.182 mail-pg1-f182.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 17/41] 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.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.31]); Thu, 26 Jul 2018 21:06:08 +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 | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/util/virhook.c b/src/util/virhook.c index facd74a..4673655 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,17 @@ virHookCheck(int no, const char *driver) } =20 if (!virFileExists(path)) { - ret =3D 0; VIR_DEBUG("No hook script %s", path); - } else if (!virFileIsExecutable(path)) { - ret =3D 0; + return 0; + } + + if (!virFileIsExecutable(path)) { VIR_WARN("Non-executable hook script %s", path); - } else { - ret =3D 1; - VIR_DEBUG("Found hook script %s", path); + return 0; } =20 - VIR_FREE(path); - return ret; + VIR_DEBUG("Found hook script %s", path); + return 1; } =20 /* @@ -233,7 +231,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 +316,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