From nobody Tue May 13 11:15: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 1532639192436440.3719505038763; Thu, 26 Jul 2018 14:06:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63C6181224; Thu, 26 Jul 2018 21:06:26 +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 258612010CD0; Thu, 26 Jul 2018 21:06:26 +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 AF9CB1800B87; Thu, 26 Jul 2018 21:06:25 +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 w6QL6JXl025569 for ; Thu, 26 Jul 2018 17:06:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 431D73083333; Thu, 26 Jul 2018 21:06:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 323A73001A6B for ; Thu, 26 Jul 2018 21:05:54 +0000 (UTC) Received: from mail-pl0-f65.google.com (mail-pl0-f65.google.com [209.85.160.65]) (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 4265B81122 for ; Thu, 26 Jul 2018 21:05:53 +0000 (UTC) Received: by mail-pl0-f65.google.com with SMTP id 31-v6so1345905plc.4 for ; Thu, 26 Jul 2018 14:05:53 -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.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:51 -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=Br7UW90Uos+o59tSbv4gWXGC/JT8Ag4zjzdJrCidCT4=; b=thPBYNScMHunIjZ/16J+a7BIbchoiTeLCTMp7yC4qeMQAqmt+TElQKSOL0zS9GZM2E 8AqncSBV2B+/42Ul8XmnaJwv0TvM7JcpuYGg9gEhNrlKOVn7DkM1cN1Jcy7YVNYsiTB/ iCrjT2nsaUbPcrXuwnD6bPSYnFQIKxoUex67RibwvotWc6cHRd0GhmvStUn/9HJ41W/d uuuj/1qrNrremKBA3bYAQp44XqBT1uisP72IuxQDWmL4Vhv9s4JmGzDrsm1wXmURagZw GDf1BRd2zRyaM8fzfgmTCz2ySS+kvAU6tKZXEhQeiIKxrlxBYcRUhw3ouDL+zyq5zyX/ VyLA== 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=Br7UW90Uos+o59tSbv4gWXGC/JT8Ag4zjzdJrCidCT4=; b=J80QVthbGH0IQGny805K2+nPU/TnnqkEJ7plgQwqNX51XafEof4nFQJXrV4NweikGp OhKvYgseovGB3NcZ+lMq6CxankihYq15BzwguvuQGVOXnGSGvHiwGQcqA9csjofc8adu 0N8egFDKLf+KfZVBJ7VO+2ELN1kx0TMuDOBpKftTZ9aXd21WLP3k2+zSuiaNFaNRLokZ T0woCo5HMiML01Uz9ynxdBf9Tz+ZNDuCNoli3WmzjhIUnmo/BUdiloPBtpzgrjDcStCD +Q5jAjyXKPdAOKskceyKocYVmDH+nN6QpIDj/9zV91EsaJOZ+D5fN34TF4TLQ14EfxFM GxUg== X-Gm-Message-State: AOUpUlH5eyaARSHFIeZpgA2LA/uaHThPOhLPArMNCc8ZHLGZhpdMxTW5 3+EZ1LejCkZ3RW2aLxTkgH555wvF X-Google-Smtp-Source: AAOMgpdGKJv0Ap0Bq8PXCTPVTh9TPvHT6LuFyhreNodNj4tV31vsgsiuSZix1YaUNcV6M82EH3Dj1w== X-Received: by 2002:a17:902:42c3:: with SMTP id h61-v6mr3331366pld.319.1532639152457; Thu, 26 Jul 2018 14:05:52 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:39 +0530 Message-Id: <1532447562-24010-39-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.28]); Thu, 26 Jul 2018 21:05:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 26 Jul 2018 21:05:53 +0000 (UTC) for IP:'209.85.160.65' DOMAIN:'mail-pl0-f65.google.com' HELO:'mail-pl0-f65.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.160.65 mail-pl0-f65.google.com 209.85.160.65 mail-pl0-f65.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 38/41] util: kmod: 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.25 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:06:31 +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/virkmod.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/util/virkmod.c b/src/util/virkmod.c index 219fad6..d981cd4 100644 --- a/src/util/virkmod.c +++ b/src/util/virkmod.c @@ -155,13 +155,12 @@ virKModUnload(const char *module) bool virKModIsBlacklisted(const char *module) { - bool retval =3D false; size_t i; - char *drvblklst =3D NULL; - char *outbuf =3D NULL; + VIR_AUTOFREE(char *) drvblklst =3D NULL; + VIR_AUTOFREE(char *) outbuf =3D NULL; =20 if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0) - goto cleanup; + return false; =20 /* modprobe will convert all '-' into '_', so we need to as well */ for (i =3D 0; i < drvblklst[i]; i++) @@ -169,13 +168,10 @@ virKModIsBlacklisted(const char *module) drvblklst[i] =3D '_'; =20 if (doModprobe("-c", NULL, &outbuf, NULL) < 0) - goto cleanup; + return false; =20 if (strstr(outbuf, drvblklst)) - retval =3D true; + return true; =20 - cleanup: - VIR_FREE(drvblklst); - VIR_FREE(outbuf); - return retval; + return false; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list