From nobody Thu May 2 08:22:26 2024 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 1528400112771988.1855175968517; Thu, 7 Jun 2018 12:35:12 -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 41B3DC04BD25; Thu, 7 Jun 2018 19:35:11 +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 12A063001A69; Thu, 7 Jun 2018 19:35:11 +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 B23C81800FC1; Thu, 7 Jun 2018 19:35:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZ6RY018879 for ; Thu, 7 Jun 2018 15:35:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2BB11001647; Thu, 7 Jun 2018 19:35:06 +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 D86E81001646 for ; Thu, 7 Jun 2018 19:35:05 +0000 (UTC) Received: from mail-pf0-f172.google.com (mail-pf0-f172.google.com [209.85.192.172]) (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 0CC2130C10E6 for ; Thu, 7 Jun 2018 19:34:54 +0000 (UTC) Received: by mail-pf0-f172.google.com with SMTP id y5-v6so4490072pfn.4 for ; Thu, 07 Jun 2018 12:34:54 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.34.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:34:52 -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=5rsqeDUw9zBlRzrg/IAbyv1MJVR4LCifzCnt2ns8OEQ=; b=sst1CKgJWQFPuaOpVwfo/YAKcI6Da0seyrzHrH4/L0K9nHiyI5ZOtgtLwhnikZ2jCH TNdld3z5T6SA23xP/UlpE/qCx8TxW4b8juBrGM5Ec0418wAX8uku4tujZ/VB23XEfx9L 0nRhzfeGS/XHMwVetON+aNf1vEeYTB/5BLfD9u0Ac75B/A85wI0Hx6YL4JxonXruXUfG uw49Ot+NEsl1u0CryH8mkExnCPon/rkS1A/LDHr0FT67PtyaEt7O4phAaixO2Or8JnxX Hi13qvP+aeHHhoVpcZvxeK9G81UQqzA9X1n0DGyQDNy1j6oD1QWUetLODLZhQguRDtsS zl8Q== 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=5rsqeDUw9zBlRzrg/IAbyv1MJVR4LCifzCnt2ns8OEQ=; b=gY2tOzkEr08CU4gZFQCJu2CVOrP101sOiELGc6rnj+QY1gPH+QCBunWFWdzzfFcLr3 3KPOrdr99BaIZeDZ/qOKPGfcNuC0JudpAzST2LTV/4wP0wi2AszMuI1m9qmbmH63OGjx vfSQZsK7fAF/M/VX5XVr9GQ58MNRhb5cIlyAArEbIdx2J31CeYNfIRpPcgKlbqS7EDCj NAOeES8Z925Oy5F1hI9+fpQmM+AhHDPhNSSzdgksXHlLe/Yt6s9ADU4eWHn/8q/BmWAj 1bWPu4tEcGcv4FfTRJtmg4tQQH3ABSh13cDPvT1vvgI4GTuimODEfFzOuwIPP2RdjBjN VCzQ== X-Gm-Message-State: APt69E18bLD/Fi6hpPfKrqATlR++9GXZ+esIVUpTgigM0C1gIZtB9Sue S0emhoqaMlztSkq7tTjFP5iWQPeg X-Google-Smtp-Source: ADUXVKJVrRBGpC+k3i7txecMhtVgAaV8appJjc+az2NtS47Lm7JstU9lByYzObkWsyEaOggXlwshzg== X-Received: by 2002:a62:62c2:: with SMTP id w185-v6mr2975090pfb.78.1528400093197; Thu, 07 Jun 2018 12:34:53 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:23 +0530 Message-Id: <1528400083-6788-2-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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]); Thu, 07 Jun 2018 19:34:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 07 Jun 2018 19:34:54 +0000 (UTC) for IP:'209.85.192.172' DOMAIN:'mail-pf0-f172.google.com' HELO:'mail-pf0-f172.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.172 mail-pf0-f172.google.com 209.85.192.172 mail-pf0-f172.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 01/21] add macros for implementing automatic cleanup functionality 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, 07 Jun 2018 19:35:11 +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" New macros are added to src/util/viralloc.h which help in adding GCC's cleanup attribute to variable declarations. --- src/util/viralloc.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 68 insertions(+) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 69d0f90..5804ca9 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -596,4 +596,72 @@ void virAllocTestInit(void); int virAllocTestCount(void); void virAllocTestOOM(int n, int m); void virAllocTestHook(void (*func)(int, void*), void *data); + +# define VIR_AUTOPTR_FUNC_NAME(type) virAutoPtr##type +# define VIR_AUTOCLEAR_FUNC_NAME(type) virAutoClear##type + +/** + * VIR_DEFINE_AUTOPTR_FUNC: + * @type: type of the variable to be freed automatically + * @func: cleanup function to be automatically called + * + * This macro defines a function for automatic freeing of + * resources allocated to a variable of type @type. This newly + * defined function works as a necessary wrapper around @func. + */ +# define VIR_DEFINE_AUTOPTR_FUNC(type, func) \ + static inline void VIR_AUTOPTR_FUNC_NAME(type)(type *_ptr) \ + { \ + (func)(*_ptr); \ + } \ + +/** + * VIR_DEFINE_AUTOCLEAR_FUNC: + * @type: type of the variable to be freed automatically + * @func: cleanup function to be automatically called + * + * This macro defines a function for automatic clearing of + * a variable of type @type. This newly defined function + * works as a necessary wrapper around @func. + */ +# define VIR_DEFINE_AUTOCLEAR_FUNC(type, func) \ + static inline void VIR_AUTOCLEAR_FUNC_NAME(type)(type *_ptr) \ + { \ + (func)(_ptr); \ + } \ + +/** + * VIR_AUTOFREE: + * @type: type of the variable to be freed automatically + * + * Macro to automatically free the memory allocated to + * the variable declared with it by calling virFree + * when the variable goes out of scope. + */ +# define VIR_AUTOFREE(type) __attribute__((cleanup(virFree))) type + +/** + * VIR_AUTOPTR: + * @type: type of the variable to be freed automatically + * + * Macro to automatically free the memory allocated to + * the variable declared with it by calling the function + * defined by VIR_DEFINE_AUTOPTR_FUNC when the variable + * goes out of scope. + */ +# define VIR_AUTOPTR(type) \ + __attribute__((cleanup(VIR_AUTOPTR_FUNC_NAME(type)))) type + +/** + * VIR_AUTOCLEAR: + * @type: type of the variable to be freed automatically + * + * Macro to automatically clear the variable declared + * with it by calling the function defined by + * VIR_DEFINE_AUTOCLEAR_FUNC when the variable goes out + * of scope. + */ +# define VIR_AUTOCLEAR(type) \ + __attribute__((cleanup(VIR_AUTOCLEAR_FUNC_NAME(type)))) type + #endif /* __VIR_MEMORY_H_ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400114854616.593848645538; Thu, 7 Jun 2018 12:35:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21B903683B; Thu, 7 Jun 2018 19:35:13 +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 D2379A1433; Thu, 7 Jun 2018 19:35:12 +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 762284CA80; Thu, 7 Jun 2018 19:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZAJV018895 for ; Thu, 7 Jun 2018 15:35:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 98036679C4; Thu, 7 Jun 2018 19:35:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F906679D0 for ; Thu, 7 Jun 2018 19:35:08 +0000 (UTC) Received: from mail-pg0-f46.google.com (mail-pg0-f46.google.com [74.125.83.46]) (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 1136183F42 for ; Thu, 7 Jun 2018 19:34:57 +0000 (UTC) Received: by mail-pg0-f46.google.com with SMTP id 15-v6so5230754pge.2 for ; Thu, 07 Jun 2018 12:34:57 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.34.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:34:55 -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=3qmEoRH7FJ1Vph2O+isaAbNFFoDo+bOUMmmv1thaLpU=; b=Zqg5QZEZ7c702eqj7r9E700MElIIFoU1EbcKnD6eZ6Eq7U9rfTTBkqyBJDTgzXlm3U fPDiIjgyYHH4JQUUSO5GvHKkwEP2frDVT8dg07Byu2oQkdQHD3NZbVO6BmFrIxiR/5/x 2rvQ+sW0z8QpsWeH/KWHPYdhCoh+QcqT2Oi+YAndq2FuqD2poITjn+9KsqaJTu4rtCnA B0Y0nTjk6IirOZtoAGNxFU1FY7wAEAF6DN6RAbqBCUhgjjRl2jOr5bqxdra3ZFSkcfjF stNdWMs/9GPIAe7KXG2G6sDRUvEQJKOW1iALO9L/mu1PWXawa/xo2hb/q7IqTY7bhj/G gbaw== 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=3qmEoRH7FJ1Vph2O+isaAbNFFoDo+bOUMmmv1thaLpU=; b=FfEyxXKcYEohE62s6QMf8ezsD/KhTA7i7FIJptkCgenw5HgFdGR26UHXmY5F8KJ/iB H5uCtkCYcUL+mDjgikvOd4IEL8ZJ8gAH/RT4LZC5UFCOE1gZU1yPAoi7vJHo3ZoHwYyU jDP1kyIy/mY7kO2DHNMshAOFrvBAx0Jz/f1NFQXTub2VmpZje2ZSaodsx58AlBFrbzzU W0ww1LR1pyrMMGMxK/3N6losAdGUJamPTKUXNTdC5ToT+A9jO2EF/NPFrlb3u6utQpt7 jdlR6/nC45ZNZbmIC0DFgQArfTt5CGIonSRmmsEonL8G0uwpFpbmuAOthiZdN53Mgwu6 SHig== X-Gm-Message-State: APt69E1uSy4D6Aa1pJ9sieAuJIaVu+VxV0ljIx8O6SnsA6xJlEbcc7D/ K7YyCyXvq6GOmrHF/NK1PzdjP62b X-Google-Smtp-Source: ADUXVKIc9oZ5pCgufl7xjA0PGcxgYRZWqGmWfBXK3LItPlynScGiUBI2zHOYZniuRM9SZF5l1WOueg== X-Received: by 2002:a62:4556:: with SMTP id s83-v6mr2968959pfa.73.1528400096198; Thu, 07 Jun 2018 12:34:56 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:24 +0530 Message-Id: <1528400083-6788-3-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.27]); Thu, 07 Jun 2018 19:34:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 07 Jun 2018 19:34:57 +0000 (UTC) for IP:'74.125.83.46' DOMAIN:'mail-pg0-f46.google.com' HELO:'mail-pg0-f46.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.46 mail-pg0-f46.google.com 74.125.83.46 mail-pg0-f46.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 02/21] util: arptable: 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 07 Jun 2018 19:35:13 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virarptable.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index c0e90dc..bf40267 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -71,9 +71,8 @@ virArpTableGet(void) { int num =3D 0; int msglen; - void *nlData =3D NULL; + VIR_AUTOFREE(void *) nlData =3D NULL; virArpTablePtr table =3D NULL; - char *ipstr =3D NULL; struct nlmsghdr* nh; struct rtattr * tb[NDA_MAX+1]; =20 @@ -89,6 +88,7 @@ virArpTableGet(void) VIR_WARNINGS_NO_CAST_ALIGN for (; NLMSG_OK(nh, msglen); nh =3D NLMSG_NEXT(nh, msglen)) { VIR_WARNINGS_RESET + VIR_AUTOFREE(char *) ipstr =3D NULL; struct ndmsg *r =3D NLMSG_DATA(nh); int len =3D nh->nlmsg_len; void *addr; @@ -108,7 +108,7 @@ virArpTableGet(void) continue; =20 if (nh->nlmsg_type =3D=3D NLMSG_DONE) - goto end_of_netlink_messages; + return table; =20 VIR_WARNINGS_NO_CAST_ALIGN parse_rtattr(tb, NDA_MAX, NDA_RTA(r), @@ -134,8 +134,6 @@ virArpTableGet(void) =20 if (VIR_STRDUP(table->t[num].ipaddr, ipstr) < 0) goto cleanup; - - VIR_FREE(ipstr); } =20 if (tb[NDA_LLADDR]) { @@ -154,14 +152,8 @@ virArpTableGet(void) } } =20 - end_of_netlink_messages: - VIR_FREE(nlData); - return table; - cleanup: virArpTableFree(table); - VIR_FREE(ipstr); - VIR_FREE(nlData); return NULL; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400118449984.4038217668727; Thu, 7 Jun 2018 12:35:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 185D0356F1; Thu, 7 Jun 2018 19:35:17 +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 CBFD3308BDB1; Thu, 7 Jun 2018 19:35:16 +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 6CAF14CA83; Thu, 7 Jun 2018 19:35:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZDBK018907 for ; Thu, 7 Jun 2018 15:35:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D7215D6A3; Thu, 7 Jun 2018 19:35:13 +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 909C45B680 for ; Thu, 7 Jun 2018 19:35:09 +0000 (UTC) Received: from mail-pf0-f175.google.com (mail-pf0-f175.google.com [209.85.192.175]) (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 4965281E01 for ; Thu, 7 Jun 2018 19:34:59 +0000 (UTC) Received: by mail-pf0-f175.google.com with SMTP id b74-v6so5400803pfl.5 for ; Thu, 07 Jun 2018 12:34:59 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.34.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:34:57 -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=G6my9eecfsICZ3VpfOCzXFAk5lImfrctXcaq4tJHJBQ=; b=Av4vnTlICctebMuIyKZVA+B8re9fyWzrctceuXAEmhsBuip6KUPq8ceMfBb/1LALAP mEvFpcn13dcnIb1Uj/q96aOq3oMCNCAbULiryx2fczUPSNT/kWrHUf05VKulISBSZ4te 1o/M1bhSqPVyKbILGiEHMTukrGZWNqjzaZoQOt3eMRuO9Pxip6tjRDiEYqStidT0uSNk q2evcQ0pzmlTfyovpS1lFYdH08WY4qT+8DQlqlru2kmQXCqMW/SOhqQolEjqnozjBMU9 jZFWeSPmUVbL9KpXe1hwCfvpC60faD81oXSEX0PyeDcdSQELe2QITASMGIjyoucF27QA nQUA== 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=G6my9eecfsICZ3VpfOCzXFAk5lImfrctXcaq4tJHJBQ=; b=fWaSUK6qgLItPn2Wpb+JIVBvTqbRivFpqwrHgTX5zQSz7wlsrloOAGeiwU5cUUkDff O3sTGSI2IWztVP4AvwwZeVfHf5qgzgp2xPNYfASTKegNt+M7BhjzDe2pMkknMYWFDSQg PWmtwtA6pWhk9SNDw6QpfYyOu0gSZDzWgC8z8kPgbNkkmfGHARA6YACmIMkh1YgFiHYk cnX9k0xVRFuuGB80bryXlMnjft37nI2tIwWFGmnpFFCGyi18ImfrU5p0EJvhGJY5soOR ore3jrTu1FreWNPJLGE3nVMAk8/myhfqQnF3BQuEtqUrPTkDZ2uMf7mRcLEDNlovp0fB Bi1g== X-Gm-Message-State: APt69E2/uWFqeefF8FdMf80ZSTdhUUDyToHH2FlUObfcxWswaQf82Vcy OuPcFeTtCRwXNictUkL5vLaYOMa6 X-Google-Smtp-Source: ADUXVKLMsDW8Dk0TYq+LBMnsyMRDr8xpDc4Ihbr7bAYxbzZ3XwGAafh7CS3PsB8Iiy4f1TQM3/e9Hg== X-Received: by 2002:a62:d712:: with SMTP id b18-v6mr2985526pfh.70.1528400098351; Thu, 07 Jun 2018 12:34:58 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:25 +0530 Message-Id: <1528400083-6788-4-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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, 07 Jun 2018 19:34:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 07 Jun 2018 19:34:59 +0000 (UTC) for IP:'209.85.192.175' DOMAIN:'mail-pf0-f175.google.com' HELO:'mail-pf0-f175.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.175 mail-pf0-f175.google.com 209.85.192.175 mail-pf0-f175.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 03/21] util: iohelper: 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 07 Jun 2018 19:35:17 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/iohelper.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/util/iohelper.c b/src/util/iohelper.c index bb8a8dd..f7794dc 100644 --- a/src/util/iohelper.c +++ b/src/util/iohelper.c @@ -46,7 +46,7 @@ static int runIO(const char *path, int fd, int oflags) { - void *base =3D NULL; /* Location to be freed */ + VIR_AUTOFREE(void *) base =3D NULL; /* Location to be freed */ char *buf =3D NULL; /* Aligned location within base */ size_t buflen =3D 1024*1024; intptr_t alignMask =3D 64*1024 - 1; @@ -174,8 +174,6 @@ runIO(const char *path, int fd, int oflags) virReportSystemError(errno, _("Unable to close %s"), path); ret =3D -1; } - - VIR_FREE(base); return ret; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400122870304.4724075616043; Thu, 7 Jun 2018 12:35:22 -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 C48C3308214E; Thu, 7 Jun 2018 19:35:20 +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 8095F600D1; Thu, 7 Jun 2018 19:35:20 +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 249B1180121C; Thu, 7 Jun 2018 19:35:20 +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 w57JZH2I018921 for ; Thu, 7 Jun 2018 15:35:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id DCD4D16E28; Thu, 7 Jun 2018 19:35:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D6C712B4AB for ; Thu, 7 Jun 2018 19:35:12 +0000 (UTC) Received: from mail-pg0-f41.google.com (mail-pg0-f41.google.com [74.125.83.41]) (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 765C7308FB99 for ; Thu, 7 Jun 2018 19:35:01 +0000 (UTC) Received: by mail-pg0-f41.google.com with SMTP id l2-v6so5225123pgc.7 for ; Thu, 07 Jun 2018 12:35:01 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.34.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:00 -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=p1JR9512Tj92DOqkjswnTBBf9J+pnVip6vEwYTbKaro=; b=CjXOPQI2KvPQxX3nRJt6DuUXJVZ/Yoq+suNqih2Y9MK7JnqTzpfIkEjFgoNUfOS0N9 zLo1FI7ZnRD/V9oL6TZVe4qb4gYoQ6CT/J/5jsvrYNDqAelDRD59m/FuoOZQArjzZLTF Xv9bmeMBkdc6SwSKQV9DN5wjzz7MsueJXukI0BH9g29WoxN5hFgiCOLdABF0mpwO9TbL JPKF0Ygx80v8Ap0ZeHhZhJTLpnn0dmPf5Lk05IQMsHeTJWTFMSn05oaFADcQwuVYZp1K xhPVxNWgMfDCOs9cnDPBaUO61AwAU1+sGlaLxveLqZaN0g6kN757ag6g3+9m5xx27ikx KZOA== 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=p1JR9512Tj92DOqkjswnTBBf9J+pnVip6vEwYTbKaro=; b=ocEWgOLIqK48IrMy3NsfXPs0RlfxvwOsf65lRCnU59w32XG449tXo6Fi0K+ngVbcOV +fYEuoHLZSl2/Ot/KZf2lfDalITLDwCFdeA1abCml2VhJHU2lzhDrg7L+kYt64jy2yRA JhTt5EC5dH3hucVsxyKiUwLHWXwasZIaaco8MiY2b0Tyvs4Rxw/ml0NkxpJQfHLJODB+ lZGR7MJUN9mHuaODkbU9+JY8OztIqpcgniiCBjboMfnE5tbvTmqe96JovREo/DGGympp TGih2ydy2W0KSLGyarnitXvp6NVy768ebIQ2eJKvE4LrUJ0+psGHYvnRMPj/UVCtnZ9d yLEQ== X-Gm-Message-State: APt69E3W1VlT6Q66TdGxvwJdbb8HBo7z2BSLmS1LsMVHRGAsquqx2xHO GlGE/aTEbfbC2wn9HtHLx1sk18iI X-Google-Smtp-Source: ADUXVKKztMRrGXCOAe9FTxzz0VbE/rzEebExeFAdxNvQ2V3oSNW4XTNKWXmd3uPsYQV+bdgdjx5TIA== X-Received: by 2002:a63:af50:: with SMTP id s16-v6mr2675905pgo.263.1528400100689; Thu, 07 Jun 2018 12:35:00 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:26 +0530 Message-Id: <1528400083-6788-5-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.43]); Thu, 07 Jun 2018 19:35:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 07 Jun 2018 19:35:01 +0000 (UTC) for IP:'74.125.83.41' DOMAIN:'mail-pg0-f41.google.com' HELO:'mail-pg0-f41.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.41 mail-pg0-f41.google.com 74.125.83.41 mail-pg0-f41.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 04/21] util: audit: 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 07 Jun 2018 19:35:21 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/viraudit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/util/viraudit.c b/src/util/viraudit.c index 0085dc3..a49d458 100644 --- a/src/util/viraudit.c +++ b/src/util/viraudit.c @@ -97,7 +97,7 @@ void virAuditSend(virLogSourcePtr source, virAuditRecordType type ATTRIBUTE_UNUSED, bool success, const char *fmt, ...) { - char *str =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; va_list args; =20 /* Duplicate later checks, to short circuit & avoid printf overhead @@ -144,7 +144,6 @@ void virAuditSend(virLogSourcePtr source, } } #endif - VIR_FREE(str); } =20 void virAuditClose(void) --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400128433493.85712394171946; Thu, 7 Jun 2018 12:35:28 -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 084993086275; Thu, 7 Jun 2018 19:35:27 +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 C7C6C2016A80; Thu, 7 Jun 2018 19:35: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 69C894CA89; Thu, 7 Jun 2018 19:35:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZJuP018931 for ; Thu, 7 Jun 2018 15:35:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 13AEE20155E5; Thu, 7 Jun 2018 19:35: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 08AED20155E2 for ; Thu, 7 Jun 2018 19:35:14 +0000 (UTC) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) (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 C9F258111C for ; Thu, 7 Jun 2018 19:35:03 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id b17-v6so5403279pfi.0 for ; Thu, 07 Jun 2018 12:35:03 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:02 -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=BWqKXnlvBAl+ZJecDmL9sJOAttHUf8nBgPST+4XkY3U=; b=oFLd5gXNxYOTRFdevGXKmzwGGjSlNpoB4HBtq+lS6KXwatsVrOU70V116AA+6veKpZ OdsXHigf3KFaQ5IiscBVeeZL0IDnEwjWNbiE4OJnEMhR7izJrhLu5z5Nz2plkVLi1jxe /MEGuwZdwTx47OapCCpZftataNnq3/XN/zJ/y4m03vNjOi/NleLVeUZmH6EUX43CBw/c DYQIS4J2983XV/L/bH4dkBzvwmtfBLd9tt7LeX5ieEQ4LgZ8SwBxG0X7KpQl9AHeR6xX Ulk0NGReCPxRSGm0zcESDMQMTtbGA/GDcev4Uq8kNUD189Wvyk9/MrEQPBfazBMbOBiE n0dg== 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=BWqKXnlvBAl+ZJecDmL9sJOAttHUf8nBgPST+4XkY3U=; b=Wu27OsWNI4vqUtKifHmmaT6mHFTcVdn1yL6yrEtg2XErc0DYmY7bwgd+D8VWEte6CB WeIt2MD5hyRQfNBrKD0BiQUL6nsTofBI/gY3iRjbTkwFS/jUssacLNDK5xZXdWgMUrkc K5pRQJ2fLpINdF6mq/mnX8i7Kf3cn3AW3WW5wjWjstejcWrsoVUDY8kTvEAh/+a2PtFW /yzrQKbeROeAKx9wshYuhLLeViNeCWgb+rgQFcV1aZqsuIFtHEE4TYw3e/68+cnBa3/4 4Dv2LEvzaZWlrZhV94JseDeF0q9tHR1gHubZwTVtA8/mfaYfWIXlD9V1rtaI7eREOLMc 0P/w== X-Gm-Message-State: APt69E1aJZ15aGoJbMiS3c/a43ssUw3u+vONqu7UHsuXDzdC6Dfc/Ks2 bpn/6rMUPyOzcQ1S1Jo9+I5LgCxK X-Google-Smtp-Source: ADUXVKLoN/iWTwb/Jq1pRxZdBewv3543CAT4rItoW0dsznZ8U+FqRGEtpDREhoZ2EMMm673pvMINAQ== X-Received: by 2002:a63:3759:: with SMTP id g25-v6mr2690478pgn.59.1528400102884; Thu, 07 Jun 2018 12:35:02 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:27 +0530 Message-Id: <1528400083-6788-6-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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, 07 Jun 2018 19:35:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 07 Jun 2018 19:35:04 +0000 (UTC) for IP:'209.85.192.195' DOMAIN:'mail-pf0-f195.google.com' HELO:'mail-pf0-f195.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.195 mail-pf0-f195.google.com 209.85.192.195 mail-pf0-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.28 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 05/21] util: fcp: 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.49]); Thu, 07 Jun 2018 19:35:27 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virfcp.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/util/virfcp.c b/src/util/virfcp.c index 7660ba7..b703744 100644 --- a/src/util/virfcp.c +++ b/src/util/virfcp.c @@ -40,16 +40,12 @@ bool virFCIsCapableRport(const char *rport) { - bool ret =3D false; - char *path =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; =20 if (virBuildPath(&path, SYSFS_FC_RPORT_PATH, rport) < 0) return false; =20 - ret =3D virFileExists(path); - VIR_FREE(path); - - return ret; + return virFileExists(path); } =20 int @@ -57,8 +53,8 @@ virFCReadRportValue(const char *rport, const char *entry, char **result) { - int ret =3D -1; - char *buf =3D NULL, *p =3D NULL; + VIR_AUTOFREE(char *) buf =3D NULL; + char *p =3D NULL; =20 if (virFileReadValueString(&buf, "%s/%s/%s", SYSFS_FC_RPORT_PATH, rport, entry) < 0) { @@ -69,13 +65,9 @@ virFCReadRportValue(const char *rport, *p =3D '\0'; =20 if (VIR_STRDUP(*result, buf) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - VIR_FREE(buf); - return ret; + return 0; } =20 #else --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400134556791.3546209068861; Thu, 7 Jun 2018 12:35:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 27F09308FBA0; Thu, 7 Jun 2018 19:35:33 +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 DC4C0A1433; Thu, 7 Jun 2018 19:35:32 +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 8C38E180BA84; Thu, 7 Jun 2018 19:35:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZJIj018936 for ; Thu, 7 Jun 2018 15:35:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4ABE820155E4; Thu, 7 Jun 2018 19:35:19 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4358B20155E2 for ; Thu, 7 Jun 2018 19:35:19 +0000 (UTC) Received: from mail-pf0-f179.google.com (mail-pf0-f179.google.com [209.85.192.179]) (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 4D6E180F90 for ; Thu, 7 Jun 2018 19:35:06 +0000 (UTC) Received: by mail-pf0-f179.google.com with SMTP id q1-v6so5390026pff.13 for ; Thu, 07 Jun 2018 12:35:06 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35: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=RoIyP4mMvVb64gdogSoWxPXJknyV7QZBvrBLEM/1is4=; b=a44QLC7AmzNtZuoV7lMIxWFRKswcGG3OJHuiKc3rW0NGDLU/DB7yIxG3ViGhsvbPQr E4Gv9bldsgBeKA6j6p8VItNg+5tLGvs/NfoFjUHvV92YHl8PoobRpApuGpFg4QpsHx+/ 4NGQLP7nE3s4pCulfG11f7Ugai5Uh3OgGJQz0XpYVGtXoYY6xHXFn5z628ebcw4HuyWq qCzBjcvOeGTuY3rPShminVBWFs48aVp9RSEOipS44jGuVMjCEsv18BuCFWKGnmKDIsN2 vzWtmBpue9dh2ycDnADroFe7m1nL7BJ3TRQJO5zXYV9S1grNGUKLDSiCzd/Rg3c1L20o w5IQ== 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=RoIyP4mMvVb64gdogSoWxPXJknyV7QZBvrBLEM/1is4=; b=OwgiWpXEtDspKCprpMyhUCSCS0V3GNTK69i7eQZsUgMiD1fJ9gKlkHpFq/voD/EUU/ a7cJvXiQPg9fdJsLE3PmnQYbsAy//JO/M5l4xNowRHCbxLaeDtJSyo2EvzKKS9ZP6POw qF1Kf7Vny9pvoPLmdU/ZJAQgjLM6/i2MkIEzBbo9m2dgB0SwC9UERLPYyEdCtG7AO94w wn1mzINuMCXW0iZuR4YFlaM/tmx58t4Q+SGjsK3w02NGrGfr0qZLX7OALfyyfRwoPhX1 CU36Ir5v5fTznPuIGIvTC1G/DcJBejxb2X4tSkMRJsui/LisW2ibupzzhNZzECK0tsGl 6iRA== X-Gm-Message-State: APt69E1oLCduJhmdyRz+cZsNKU8iovKBMmJh/l5Fz00Uj0HqTpC0/ILR 0uMC/nActVhVpUZkpulM5F/+y7CR X-Google-Smtp-Source: ADUXVKIErSRZJpTm56x16VnO6IPGCCUM1+P1AF/l8BpumvtAkPL4aLRQfK0w5dFF0U4B8+rOdF37bg== X-Received: by 2002:a62:9513:: with SMTP id p19-v6mr2931133pfd.239.1528400105156; Thu, 07 Jun 2018 12:35:05 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:28 +0530 Message-Id: <1528400083-6788-7-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.27]); Thu, 07 Jun 2018 19:35:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 07 Jun 2018 19:35:06 +0000 (UTC) for IP:'209.85.192.179' DOMAIN:'mail-pf0-f179.google.com' HELO:'mail-pf0-f179.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.179 mail-pf0-f179.google.com 209.85.192.179 mail-pf0-f179.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 06/21] util: eventpoll: 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 07 Jun 2018 19:35:33 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/vireventpoll.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index 81ecab4..13d278d 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -618,7 +618,7 @@ static void virEventPollCleanupHandles(void) */ int virEventPollRunOnce(void) { - struct pollfd *fds =3D NULL; + VIR_AUTOFREE(struct pollfd *) fds =3D NULL; int ret, timeout, nfds; =20 virMutexLock(&eventLoop.lock); @@ -645,7 +645,7 @@ int virEventPollRunOnce(void) goto retry; virReportSystemError(errno, "%s", _("Unable to poll on file handles")); - goto error_unlocked; + return -1; } EVENT_DEBUG("Poll got %d event(s)", ret); =20 @@ -662,13 +662,10 @@ int virEventPollRunOnce(void) =20 eventLoop.running =3D 0; virMutexUnlock(&eventLoop.lock); - VIR_FREE(fds); return 0; =20 error: virMutexUnlock(&eventLoop.lock); - error_unlocked: - VIR_FREE(fds); return -1; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400126619259.4690098657936; Thu, 7 Jun 2018 12:35:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 384A84E906; Thu, 7 Jun 2018 19:35:25 +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 F17E960BEC; Thu, 7 Jun 2018 19:35:24 +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 9AC854CA83; Thu, 7 Jun 2018 19:35:24 +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 w57JZMJJ018955 for ; Thu, 7 Jun 2018 15:35:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3E06C2B47D; Thu, 7 Jun 2018 19:35:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 361C62B464 for ; Thu, 7 Jun 2018 19:35:19 +0000 (UTC) Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) (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 B1E093086268 for ; Thu, 7 Jun 2018 19:35:08 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id e11-v6so5235304pgq.0 for ; Thu, 07 Jun 2018 12:35:08 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:07 -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=+8jrP802jTpvMGIx/oynDSTssH88+RnUpM6CervKKuY=; b=k2ttwlTo9lrI9L4Y46QlQx3ES2SdOpsX6qGNkLudvALVrj/YGjts13Tu26MLIqw0Hb XXZWfAZobuUk+Ut9sgUfl8HgUNg25mUHU8i/wqO7kggRNHP5la3vrmiuWDKbziW/14mH KCxtg2p3jYXw4tHlsPfaWug13yqQ/RHtFSuVvqqyVDjFOxK/IPRFmMFxX/1UEeLrpuoc e9HJWOmv6m3Wts7xqz8KJD9L5Rfv2A2Hq9UfhvaGgbMguYJModOpndLpoUDEtp0Vgrh/ NC8m2g+Ix0Co21wdgtkJkHoVL4OOZY/BQK501GFcuU2IgyVdMq6x5JEsWFV6q+5HMhmO R+BA== 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=+8jrP802jTpvMGIx/oynDSTssH88+RnUpM6CervKKuY=; b=DZwqI4DNU4I3KFW9KaAHqDctd08SNtrwKQMTpqC/h7B0oCw6XnyvFkFS5ol0Lp9xtm 6kaH6UZ4keSLQ10Fjrkm4VCL1WRC74eO89myVJuEk4j7EJ5FpjdYVNQ61vxRHmqAQbQq ljYBiSe+GPG78gXNzqAeZSB5uucdUBB/75JbLv5qh6MJjx0713BbmG3mzsW5abtogveg VAHVmK0E7EI8r0imu53/FA7UGtF+G9J5gw1ET7m7ZCATWkj7+J5RQvCMRpkTbCv9QhbZ YwNhzzGiP9zHX2ETeMXmjcHtWjeQSs++7aJ/8VsUamqn1PMPj36VFDk9CUvq06j1qXuh 5cpQ== X-Gm-Message-State: APt69E0TTA6OU78BhFnGJ8LUwEiIEfFu1IjOIcoIpxfz4ctl6hVlkOW+ l/LgZJbCZCBYiUJKBkI/754qeIzu X-Google-Smtp-Source: ADUXVKLTGaTVuiAqH/utSS84GprF6x6rNSr/UQuppHXV0ra9OTPvtYNe06Hprd5orIVfiPV/EvpL+g== X-Received: by 2002:a63:6ec8:: with SMTP id j191-v6mr2668413pgc.232.1528400107838; Thu, 07 Jun 2018 12:35:07 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:29 +0530 Message-Id: <1528400083-6788-8-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.49]); Thu, 07 Jun 2018 19:35:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 19:35:08 +0000 (UTC) for IP:'74.125.83.68' DOMAIN:'mail-pg0-f68.google.com' HELO:'mail-pg0-f68.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) 74.125.83.68 mail-pg0-f68.google.com 74.125.83.68 mail-pg0-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 07/21] util: filecache: 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 07 Jun 2018 19:35:25 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virfilecache.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/util/virfilecache.c b/src/util/virfilecache.c index 96ae96d..2927c68 100644 --- a/src/util/virfilecache.c +++ b/src/util/virfilecache.c @@ -100,18 +100,17 @@ static char * virFileCacheGetFileName(virFileCachePtr cache, const char *name) { - char *file =3D NULL; - char *namehash =3D NULL; + VIR_AUTOFREE(char *) namehash =3D NULL; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 if (virCryptoHashString(VIR_CRYPTO_HASH_SHA256, name, &namehash) < 0) - goto cleanup; + return NULL; =20 if (virFileMakePath(cache->dir) < 0) { virReportSystemError(errno, _("Unable to create directory '%s'"), cache->dir); - goto cleanup; + return NULL; } =20 virBufferAsprintf(&buf, "%s/%s", cache->dir, namehash); @@ -120,13 +119,9 @@ virFileCacheGetFileName(virFileCachePtr cache, virBufferAsprintf(&buf, ".%s", cache->suffix); =20 if (virBufferCheckError(&buf) < 0) - goto cleanup; - - file =3D virBufferContentAndReset(&buf); + return NULL; =20 - cleanup: - VIR_FREE(namehash); - return file; + return virBufferContentAndReset(&buf); } =20 =20 @@ -135,7 +130,7 @@ virFileCacheLoad(virFileCachePtr cache, const char *name, void **data) { - char *file =3D NULL; + VIR_AUTOFREE(char *) file =3D NULL; int ret =3D -1; void *loadData =3D NULL; =20 @@ -178,7 +173,6 @@ virFileCacheLoad(virFileCachePtr cache, =20 cleanup: virObjectUnref(loadData); - VIR_FREE(file); return ret; } =20 @@ -188,20 +182,15 @@ virFileCacheSave(virFileCachePtr cache, const char *name, void *data) { - char *file =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) file =3D NULL; =20 if (!(file =3D virFileCacheGetFileName(cache, name))) - return ret; + return -1; =20 if (cache->handlers.saveFile(data, file, cache->priv) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - VIR_FREE(file); - return ret; + return 0; } =20 =20 @@ -346,7 +335,7 @@ virFileCacheLookupByFunc(virFileCachePtr cache, const void *iterData) { void *data =3D NULL; - char *name =3D NULL; + VIR_AUTOFREE(char *) name =3D NULL; =20 virObjectLock(cache); =20 @@ -356,8 +345,6 @@ virFileCacheLookupByFunc(virFileCachePtr cache, virObjectRef(data); virObjectUnlock(cache); =20 - VIR_FREE(name); - return data; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400132549128.91760629670318; Thu, 7 Jun 2018 12:35:32 -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 8066B308626B; Thu, 7 Jun 2018 19:35:31 +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 40FA960BE1; Thu, 7 Jun 2018 19:35:31 +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 E11F0180121C; Thu, 7 Jun 2018 19:35:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZQN7018982 for ; Thu, 7 Jun 2018 15:35:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32101308BDAE; Thu, 7 Jun 2018 19:35:26 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 28DA1308BDAA for ; Thu, 7 Jun 2018 19:35:23 +0000 (UTC) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) (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 A91F83680F for ; Thu, 7 Jun 2018 19:35:12 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id c22-v6so4988079pfi.2 for ; Thu, 07 Jun 2018 12:35:12 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:09 -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=YnmKKJYA97MfRt65O2VvT4DWo7k3mcJAOFpVqB6PoGU=; b=cV8cSz00/uPwqFw48n8LF9edRxiJfxwQmWzaKsHxnh8RAGpQmyjwcqZVtcxFxViJk4 12ZscyyWGpym4VKqwv7MMFeCTAAaAIrfT9NbehrhpoSDPRbSyZDHPArV2mAKaMWIJdOq XPXTG+iRb8cLc+QGhzO238p/paL0SyvrXWxoTL76kZ17surbrwcZlR+POqb8TTaiNJik lBxlVlwVyx3amLCyM3q8KMkgJDG3198nsj9cu0I3Wh+f6z45ejUwnKfKY9JQlD5Xagp0 4L8PO1/Kf4Z9yOj1Xf1pn955ZhzU8OSFoKI9fZMWKRnUmL44sfVQSRlvbFcivapBGRXP XYVw== 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=YnmKKJYA97MfRt65O2VvT4DWo7k3mcJAOFpVqB6PoGU=; b=KqMGSxQcHjhiro3rNVo0cNGAoHVA8ttC44KwT5plEFeKIUX9sb3g9bcD37uKsJ1bCn 0EYqd+FLHZpCCanEleAUk+sxl/yaYIu1PJLeizqhJqDZJCSOmBz/HWoK5ww5t6SB/nas Br4jn7HYOiKWSM93C/X2w/XB8+rk7n44hEd0pcQp6cddisMEKB1ESTYg5uqomtFrGSke 9M3MgSdeRFq/ReMYCrXxOtq/q16g+f7tw83oTKDH/ngnBKW+//fJeJGXQiUHSk0znYoB eA/FMOAcRx8q/mej7PVhjx5SFzhg6kZeHy70Ps9F4wplKbOX8CjgfL4B18nmWt/6h4Ou jsbw== X-Gm-Message-State: APt69E3POykXZAj3XU0o/cXkA2rgN0NeSR8Ta7H78/ZW8K4OgyoCuGns RcFpGl0RLInjn2wKsp3+mPDNKcE3 X-Google-Smtp-Source: ADUXVKJLeVtxBJOYF6Wf46GrN8UF9WQi6MEL2oOaKqnUDMnE2+wFAXKLaW7r0S8O9wXWqKjM3am6Iw== X-Received: by 2002:a63:63c4:: with SMTP id x187-v6mr2665100pgb.9.1528400110257; Thu, 07 Jun 2018 12:35:10 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:30 +0530 Message-Id: <1528400083-6788-9-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.30]); Thu, 07 Jun 2018 19:35:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 07 Jun 2018 19:35:12 +0000 (UTC) for IP:'209.85.192.195' DOMAIN:'mail-pf0-f195.google.com' HELO:'mail-pf0-f195.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.195 mail-pf0-f195.google.com 209.85.192.195 mail-pf0-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 08/21] util: authconfig: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC 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.49]); Thu, 07 Jun 2018 19:35:32 +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" Using the VIR_DEFINE_AUTOPTR_FUNC macro defined in src/util/viralloc.h, define a new wrapper around an existing cleanup function which will be called when a variable declared with VIR_AUTOPTR macro goes out of scope. --- src/util/virauthconfig.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virauthconfig.h b/src/util/virauthconfig.h index ac0ceeb..375ccad 100644 --- a/src/util/virauthconfig.h +++ b/src/util/virauthconfig.h @@ -24,6 +24,7 @@ # define __VIR_AUTHCONFIG_H__ =20 # include "internal.h" +# include "viralloc.h" =20 typedef struct _virAuthConfig virAuthConfig; typedef virAuthConfig *virAuthConfigPtr; @@ -42,4 +43,6 @@ int virAuthConfigLookup(virAuthConfigPtr auth, const char *credname, const char **value); =20 +VIR_DEFINE_AUTOPTR_FUNC(virAuthConfigPtr, virAuthConfigFree) + #endif /* __VIR_AUTHCONFIG_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400141773542.1919004429737; Thu, 7 Jun 2018 12:35:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7EFEE81DE3; Thu, 7 Jun 2018 19:35:40 +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 44624679C9; Thu, 7 Jun 2018 19:35:40 +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 EE4154CA84; Thu, 7 Jun 2018 19:35:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZRa5018991 for ; Thu, 7 Jun 2018 15:35:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 55569600D1; Thu, 7 Jun 2018 19:35:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B412600C9 for ; Thu, 7 Jun 2018 19:35:24 +0000 (UTC) Received: from mail-pg0-f51.google.com (mail-pg0-f51.google.com [74.125.83.51]) (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 4A0FD30832E6 for ; Thu, 7 Jun 2018 19:35:13 +0000 (UTC) Received: by mail-pg0-f51.google.com with SMTP id r21-v6so4895870pgv.4 for ; Thu, 07 Jun 2018 12:35:13 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:11 -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=QUhQv1SDRIp7XQ2I4d+3c/XZ0LL3ZfVtR9XeirHcJBg=; b=OwHW8C+ewMPnE37OlO+qlYmKcbyqFp1w67nXeNiAtu+SPUT2U+zis2znB8tJYOQ4D7 dXwmj7hNRZ+olT92vIZGlFETtrx4H/DlVBNSFZlSV3tUFH17aalM+rxOox4OIYdQ6AKu FMsCarVZf0gMtL6+xmas4CUnuTRBdo8KWxbW8zk9xTPC6cLqLQpkrNldqRaf5+RXS1U9 Sg1vPeDnRxhS8oMHYbdjqcCwc1OTcsIJTcLa6O8GiozUh6Sv1LalbtMbVncq/iYL40Zv Ki49aieA/ju01DdRdAL4xE35qmYmELfF7rySYYxZyBCBQDtHQOI/p1WHqXpUYcW+DY1l TvEg== 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=QUhQv1SDRIp7XQ2I4d+3c/XZ0LL3ZfVtR9XeirHcJBg=; b=b2zkRBUsWafB+pCCoKzt3r/PKID1vT5LnuWhx5WOaDDAmePLj2mtaPcidNbEYJU8Rn GSl/rin1CTt7CaRh0pR5pb+sDUWdJyiOJYTJ9l4sWM7+/lXaDPDSUlzb8GYVTX5jAcPX T9ohTxpQ0aDFMqGNtHHxn3Fg2SOgCTdIx2idZvXrzS0Uzi6j96By5RTR1OLClF0kCd9d 5CM579iaLMHfY5s7b6QJdqvvU3AvjU+KkEGV47cikEUP1lz49mz//cDXpO6YX8U5nJDs o45t7dtpToSQ9U5y3YhyO0VhLN9LyBkbXamLj2y66Ebh7J8jhpII4Urwo6xJZfibwWr+ nteA== X-Gm-Message-State: APt69E0AiAvIP0l0L2cL8G5RzPFYUnw2UXXdU8xkiSeFeLWvq0JiLzM4 nCLeuql1HX1HMcIL3LKtkDlE3eyB X-Google-Smtp-Source: ADUXVKLOoT4POVxqdu/HSCSOUTyTRHKoSnpTEFiSiOOLknR56XbhHMBbDtvEu2tgM5xZV1dRuVrUtA== X-Received: by 2002:a63:2c94:: with SMTP id s142-v6mr2604868pgs.39.1528400112562; Thu, 07 Jun 2018 12:35:12 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:31 +0530 Message-Id: <1528400083-6788-10-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.44]); Thu, 07 Jun 2018 19:35:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 07 Jun 2018 19:35:13 +0000 (UTC) for IP:'74.125.83.51' DOMAIN:'mail-pg0-f51.google.com' HELO:'mail-pg0-f51.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.51 mail-pg0-f51.google.com 74.125.83.51 mail-pg0-f51.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 09/21] util: authconfig: remove redundant include directive 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 07 Jun 2018 19:35:41 +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" The include directive for viralloc.h is added in virauthconfig.h in the previous patch. --- src/util/virauthconfig.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 91c9c0c..3487cc2 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -25,7 +25,6 @@ #include "virauthconfig.h" =20 #include "virkeyfile.h" -#include "viralloc.h" #include "virlog.h" #include "virerror.h" #include "virstring.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400133881656.3936967118748; Thu, 7 Jun 2018 12:35:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFCB74E4C2; Thu, 7 Jun 2018 19:35:32 +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 7F8E52B3AF; Thu, 7 Jun 2018 19:35:32 +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 2CB7B1800FD9; Thu, 7 Jun 2018 19:35:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZTa2019007 for ; Thu, 7 Jun 2018 15:35:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD32D5D9CA; Thu, 7 Jun 2018 19:35:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B687B5D9C9 for ; Thu, 7 Jun 2018 19:35:26 +0000 (UTC) Received: from mail-pl0-f47.google.com (mail-pl0-f47.google.com [209.85.160.47]) (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 5FA4030820DC for ; Thu, 7 Jun 2018 19:35:15 +0000 (UTC) Received: by mail-pl0-f47.google.com with SMTP id a7-v6so4265209plp.3 for ; Thu, 07 Jun 2018 12:35:15 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:14 -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=pUQLnb1h10lRHFDW1PQWyXbI0Qo7ETfX8oOc0QbSXMM=; b=V9iuhY+s6vXkSbZ3vr3HvuexVEqaByev1BmF9HYmXI3gXHS3/5VL5IcrrVAGebsd3A K9DtvQUECjdawDMpS9GGwgjPU2WpCPK5R1p3GpiLBvMGXmhnwBAh4bG9yI/Br0zeWvwY ciWxvYLV76JGYVweD9hxu/uzZ93/21dLsyO71Go5AEm3VZxWmn7AD5xXwjstkkX+qFDc xLoLRZUAYluDOEf2+lMOKsFn76OT79Bo/T5L8dVOjbdqnkB66DSiAe8YMXIhKygx/l/7 G6CzkdcxLy8e/39hM6MBzB0Q0+7wNXY5gLxU05fSuwYwnb/I4nEX9lICPBSpqMz3ZTng TyYg== 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=pUQLnb1h10lRHFDW1PQWyXbI0Qo7ETfX8oOc0QbSXMM=; b=S6+hR+hlFu9wSQlRwbqL3rGzWiUniRIJBWUxnqw0bH9C3vRP0rJ5MgN1tv4EutqaU4 rsjbOmr+3rELKlhUWi20g+PzPWp8+xqci211mSjujQ5e1v0oqLuMlLq0nko3FW/Kub3K 402lYhxrfOh8S6zbQrz9WBcU9nNUhltMso2sLzEJq5F2Zlb1xo1PaSEksbZQ2jm5GxUC C08eAhdhWF8oHnNIcXghoXzpZlVOJE5jGehRQ/MeCJiBd4MWHMw2nuXKUL69gaEO/0sE Z21HXbYIjxAoub8e+8hTLi1eGofcrR+TwSnYJNBvm1cCqrujF7tb6Rnqnq05td9/JXyq 7F4g== X-Gm-Message-State: APt69E1M7BMja3hQK2omCWZLcYM7oW0K5yTOPEFwluhPhIGSCniMs4bR BEEKwb1hKSkQqGcG4lKq4VjLLABd X-Google-Smtp-Source: ADUXVKKfPkYa3+hFLIgVgbxGfKO2mnex1T0VhUykKwcuzCpWQCsiPxCowNiJO6iT0O+qF7GcENEPNg== X-Received: by 2002:a17:902:4b:: with SMTP id 69-v6mr3402811pla.178.1528400114599; Thu, 07 Jun 2018 12:35:14 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:32 +0530 Message-Id: <1528400083-6788-11-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.47]); Thu, 07 Jun 2018 19:35:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 07 Jun 2018 19:35:15 +0000 (UTC) for IP:'209.85.160.47' DOMAIN:'mail-pl0-f47.google.com' HELO:'mail-pl0-f47.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.160.47 mail-pl0-f47.google.com 209.85.160.47 mail-pl0-f47.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 10/21] util: authconfig: 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 07 Jun 2018 19:35:33 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virauthconfig.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 3487cc2..9977e71 100644 --- a/src/util/virauthconfig.c +++ b/src/util/virauthconfig.c @@ -105,10 +105,9 @@ int virAuthConfigLookup(virAuthConfigPtr auth, const char *credname, const char **value) { - char *authgroup =3D NULL; - char *credgroup =3D NULL; + VIR_AUTOFREE(char *) authgroup =3D NULL; + VIR_AUTOFREE(char *) credgroup =3D NULL; const char *authcred; - int ret =3D -1; =20 *value =3D NULL; =20 @@ -118,47 +117,38 @@ int virAuthConfigLookup(virAuthConfigPtr auth, hostname =3D "localhost"; =20 if (virAsprintf(&authgroup, "auth-%s-%s", service, hostname) < 0) - goto cleanup; + return -1; =20 if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { VIR_FREE(authgroup); if (virAsprintf(&authgroup, "auth-%s-%s", service, "default") < 0) - goto cleanup; + return -1; } =20 - if (!virKeyFileHasGroup(auth->keyfile, authgroup)) { - ret =3D 0; - goto cleanup; - } + if (!virKeyFileHasGroup(auth->keyfile, authgroup)) + return 0; =20 if (!(authcred =3D virKeyFileGetValueString(auth->keyfile, authgroup, = "credentials"))) { virReportError(VIR_ERR_CONF_SYNTAX, _("Missing item 'credentials' in group '%s' in '%s'= "), authgroup, auth->path); - goto cleanup; + return -1; } =20 if (virAsprintf(&credgroup, "credentials-%s", authcred) < 0) - goto cleanup; + return -1; =20 if (!virKeyFileHasGroup(auth->keyfile, credgroup)) { virReportError(VIR_ERR_CONF_SYNTAX, _("Missing group 'credentials-%s' referenced from g= roup '%s' in '%s'"), authcred, authgroup, auth->path); - goto cleanup; + return -1; } =20 - if (!virKeyFileHasValue(auth->keyfile, credgroup, credname)) { - ret =3D 0; - goto cleanup; - } + if (!virKeyFileHasValue(auth->keyfile, credgroup, credname)) + return 0; =20 *value =3D virKeyFileGetValueString(auth->keyfile, credgroup, credname= ); =20 - ret =3D 0; - - cleanup: - VIR_FREE(authgroup); - VIR_FREE(credgroup); - return ret; + return 0; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400143648620.0654810346037; Thu, 7 Jun 2018 12:35:43 -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 15CCD3082A39; Thu, 7 Jun 2018 19:35:42 +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 D372C2016A83; Thu, 7 Jun 2018 19:35:41 +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 8AEE8180BA80; Thu, 7 Jun 2018 19:35:41 +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 w57JZTTF019012 for ; Thu, 7 Jun 2018 15:35:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id E47BE26164; Thu, 7 Jun 2018 19:35:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE4D716E30 for ; Thu, 7 Jun 2018 19:35:29 +0000 (UTC) Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) (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 222D5356DB for ; Thu, 7 Jun 2018 19:35:19 +0000 (UTC) Received: by mail-pl0-f66.google.com with SMTP id 30-v6so6743134pld.13 for ; Thu, 07 Jun 2018 12:35:19 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:16 -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=9VjdVZhUcskRuns3cuCxlWYSmXYgyhVqvDHdho2T8MM=; b=heb9XzWeZC2GqbsffWG/E8w7pj5KLGx098fDWdq76KZfZ7YxpteUE7zAIV4aAl8V7W JyFWwkEGjUs69P7KfX1DgWuqan7nAn+H/0fyQszDCgbWse0BRD/LcSuSWElImZMrxqas zT36EZGhPxZRbktP5harUZ4tRPaPKrl5hUlnVYoWJpVdlhgSVMWcnAN/6g+CTqKUeQkJ 0cXe6AoU352CiO0Rc5GDGHYsuwKKcRScHgciE8LbetKxgwtUmLhRqL7SjfhKtWvzmq+A 45fXpU1pJVa8KLQc4iLOosdi6hKVPFB/gIGqT8AOObY6Cdgx5bUfX7/eDoQvsbjIApFn 8ucA== 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=9VjdVZhUcskRuns3cuCxlWYSmXYgyhVqvDHdho2T8MM=; b=Pb+JQtuoL769PIUNOU6nqLH7lTDXwM0xRjqjPNz5BfcS37auUEozXLNkD5+PylB04i ASWGl/kqo2n6kHhAtI414jGFzE/lqa2c/DMuVXx20UPQ2iaKUjCkz1wLGJeKhnaIAtZ/ G4e3xU+W01IXopNf0Cqa9cj2+0Dgu5myqxQAfmkhwAUrRtl3rqqmkNPp4/Nqx7pWYCWx PY4vPKaE7JYV52qtlTu1uBtD/LXtriFOyQJdM2acude1l0uABB73/LRr/UjzbFXCKz6e jrGFCi2jsFw25qSTZgXwgXv9FGOgqQOVeL2HDIpCTIgvGfxBe3FeHrRkpeCKVpFOcgbR Zwew== X-Gm-Message-State: APt69E1Zt5vWlE/8blHICMI0g5uMpuElilYUnpq5tW5/8QLzY02y8s3r /obpb7r1mwf7dODx2wNdowpgq1Xi X-Google-Smtp-Source: ADUXVKIoeAfajZQxWzL/e+dofJt/zV+giGL4GEVWwy8DXds5kYVHRWgD8+KP39pKNFuFG8Jtow6PMg== X-Received: by 2002:a17:902:329:: with SMTP id 38-v6mr3351404pld.328.1528400116968; Thu, 07 Jun 2018 12:35:16 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:33 +0530 Message-Id: <1528400083-6788-12-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.30]); Thu, 07 Jun 2018 19:35:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 07 Jun 2018 19:35:19 +0000 (UTC) for IP:'209.85.160.66' DOMAIN:'mail-pl0-f66.google.com' HELO:'mail-pl0-f66.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.160.66 mail-pl0-f66.google.com 209.85.160.66 mail-pl0-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 11/21] util: auth: remove redundant include directive 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.45]); Thu, 07 Jun 2018 19:35:42 +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" The include directive for viralloc.h is added in virauthconfig.h in a previous patch. --- src/util/virauth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index adb093e..c6a2ce7 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -26,7 +26,6 @@ =20 #include "virauth.h" #include "virutil.h" -#include "viralloc.h" #include "virlog.h" #include "datatypes.h" #include "virerror.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400151239747.1234022318897; Thu, 7 Jun 2018 12:35:51 -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 1FCD4356DF; Thu, 7 Jun 2018 19:35:50 +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 D73672016A81; Thu, 7 Jun 2018 19:35:49 +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 8BBBB4CA84; Thu, 7 Jun 2018 19:35:49 +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 w57JZYNp019042 for ; Thu, 7 Jun 2018 15:35:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 86CEB2B4C7; Thu, 7 Jun 2018 19:35:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 80E552B4BB for ; Thu, 7 Jun 2018 19:35:31 +0000 (UTC) Received: from mail-pl0-f45.google.com (mail-pl0-f45.google.com [209.85.160.45]) (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 F0B3B30820DF for ; Thu, 7 Jun 2018 19:35:20 +0000 (UTC) Received: by mail-pl0-f45.google.com with SMTP id g20-v6so6770672plq.1 for ; Thu, 07 Jun 2018 12:35:20 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:19 -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=4YCRiQLcPsKCmsafgiwcrZ5Bk85CguKq6P1JrNSDOQA=; b=Hj+D/uVfA3MBpTFAqMQ/cLwkckh3AXq8eSjDx2TVLHhdBTgiHvs6Ms4ePYt61HBUHM NI5IYLROphnmH1rL5uiBQJDSNCwzV8YYb1TXTldBiIav+JAY4/Iep4hVjL/J0b76iv21 bGd5gLXQD8CT2obHlgr1at8alIwWskolVjsRvwF3AiztSfbDyw6q5kFHCDsGdUSzR4NC ukGKZb2uaUOoIYSS8N1gMPxRDY3cuR+SVcnXy0nq+zTQPjDGc8/p/MvZeE6cMzjQ7l0b IiCallMrsncn0mk2rcIlxTXjhFtImw5qbz9KlUxUVIWO/rEcQfY/CqbcrckAkREMeayL 5eEQ== 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=4YCRiQLcPsKCmsafgiwcrZ5Bk85CguKq6P1JrNSDOQA=; b=jS6cjohLsFFgF9gsUR7LbmuUKvU+uMNVQ7o6pkODh3+TADhvT0QksZL84CQ9eHBWBt d3jFIbzwM+gEulB217/igAUdsFd/a00OXcL7KKyN56zb19SFH8z8uBPtXiOdxLa8/J/R 63ESDnqgW1SL6Xexu+GcbTN8ZwiFuqmnvd1djoTm8a4JEDawvtJgHm1Nu8SkCe2/3hdR XSUPSVmwxpseRD7EufZsHoX0ITRdgmlT23Q9h3X6MWSgRDCl8jymLP/u+/jtpFxm6ZAX fn7hGQu8JMHKMP5GTGqcp2ohguXSVuJoiIr0YiH2LI70mBBggKDh5YhRUVImxfAVs5g7 t7aw== X-Gm-Message-State: APt69E3aaVO78W1AVsw/3HZwmiTEfBkuP8L8hF0DFya9p2upW/htc4kR dK8RjMhlqSmGqmtNYDMkUDEO4ig1 X-Google-Smtp-Source: ADUXVKJQVIgjUN3iMrbonbYXXWkyE/P7k4npbemkzKxcRj3fn1R68pO4bBptdZUsUDRQbZzxoCmHGQ== X-Received: by 2002:a17:902:740a:: with SMTP id g10-v6mr3414549pll.246.1528400120021; Thu, 07 Jun 2018 12:35:20 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:34 +0530 Message-Id: <1528400083-6788-13-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.47]); Thu, 07 Jun 2018 19:35:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 07 Jun 2018 19:35:21 +0000 (UTC) for IP:'209.85.160.45' DOMAIN:'mail-pl0-f45.google.com' HELO:'mail-pl0-f45.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.160.45 mail-pl0-f45.google.com 209.85.160.45 mail-pl0-f45.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 12/21] util: auth: 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.30]); Thu, 07 Jun 2018 19:35:50 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virauth.c | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index c6a2ce7..d3a5cc7 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -41,10 +41,9 @@ int virAuthGetConfigFilePathURI(virURIPtr uri, char **path) { - int ret =3D -1; size_t i; const char *authenv =3D virGetEnvBlockSUID("LIBVIRT_AUTH_FILE"); - char *userdir =3D NULL; + VIR_AUTOFREE(char *) userdir =3D NULL; =20 *path =3D NULL; =20 @@ -53,7 +52,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri, if (authenv) { VIR_DEBUG("Using path from env '%s'", authenv); if (VIR_STRDUP(*path, authenv) < 0) - goto cleanup; + return -1; return 0; } =20 @@ -63,17 +62,17 @@ virAuthGetConfigFilePathURI(virURIPtr uri, uri->params[i].value) { VIR_DEBUG("Using path from URI '%s'", uri->params[i].value= ); if (VIR_STRDUP(*path, uri->params[i].value) < 0) - goto cleanup; + return -1; return 0; } } } =20 if (!(userdir =3D virGetUserConfigDirectory())) - goto cleanup; + return -1; =20 if (virAsprintf(path, "%s/auth.conf", userdir) < 0) - goto cleanup; + return -1; =20 VIR_DEBUG("Checking for readability of '%s'", *path); if (access(*path, R_OK) =3D=3D 0) @@ -82,7 +81,7 @@ virAuthGetConfigFilePathURI(virURIPtr uri, VIR_FREE(*path); =20 if (VIR_STRDUP(*path, SYSCONFDIR "/libvirt/auth.conf") < 0) - goto cleanup; + return -1; =20 VIR_DEBUG("Checking for readability of '%s'", *path); if (access(*path, R_OK) =3D=3D 0) @@ -91,13 +90,9 @@ virAuthGetConfigFilePathURI(virURIPtr uri, VIR_FREE(*path); =20 done: - ret =3D 0; - VIR_DEBUG("Using auth file '%s'", NULLSTR(*path)); - cleanup: - VIR_FREE(userdir); =20 - return ret; + return 0; } =20 =20 @@ -155,7 +150,7 @@ virAuthGetUsernamePath(const char *path, { unsigned int ncred; virConnectCredential cred; - char *prompt; + VIR_AUTOFREE(char *) prompt =3D NULL; char *ret =3D NULL; =20 if (virAuthGetCredential(servicename, hostname, "username", path, &ret= ) < 0) @@ -192,8 +187,6 @@ virAuthGetUsernamePath(const char *path, break; } =20 - VIR_FREE(prompt); - return cred.result; } =20 @@ -205,18 +198,13 @@ virAuthGetUsername(virConnectPtr conn, const char *defaultUsername, const char *hostname) { - char *ret; - char *path; + VIR_AUTOFREE(char *) path =3D NULL; =20 if (virAuthGetConfigFilePath(conn, &path) < 0) return NULL; =20 - ret =3D virAuthGetUsernamePath(path, auth, servicename, + return virAuthGetUsernamePath(path, auth, servicename, defaultUsername, hostname); - - VIR_FREE(path); - - return ret; } =20 =20 @@ -229,7 +217,7 @@ virAuthGetPasswordPath(const char *path, { unsigned int ncred; virConnectCredential cred; - char *prompt; + VIR_AUTOFREE(char *) prompt =3D NULL; char *ret =3D NULL; =20 if (virAuthGetCredential(servicename, hostname, "password", path, &ret= ) < 0) @@ -263,8 +251,6 @@ virAuthGetPasswordPath(const char *path, break; } =20 - VIR_FREE(prompt); - return cred.result; } =20 @@ -276,15 +262,10 @@ virAuthGetPassword(virConnectPtr conn, const char *username, const char *hostname) { - char *ret; - char *path; + VIR_AUTOFREE(char *) path =3D NULL; =20 if (virAuthGetConfigFilePath(conn, &path) < 0) return NULL; =20 - ret =3D virAuthGetPasswordPath(path, auth, servicename, username, host= name); - - VIR_FREE(path); - - return ret; + return virAuthGetPasswordPath(path, auth, servicename, username, hostn= ame); } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400151620177.47023724126075; Thu, 7 Jun 2018 12:35:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 853AC30832F2; Thu, 7 Jun 2018 19:35:50 +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 49DDF5D750; Thu, 7 Jun 2018 19:35:50 +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 EAF684CA8E; Thu, 7 Jun 2018 19:35:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZXuJ019037 for ; Thu, 7 Jun 2018 15:35:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0E44308BDAA; Thu, 7 Jun 2018 19:35:33 +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 C896F308BDA9 for ; Thu, 7 Jun 2018 19:35:33 +0000 (UTC) Received: from mail-pl0-f48.google.com (mail-pl0-f48.google.com [209.85.160.48]) (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 0F1D381E02 for ; Thu, 7 Jun 2018 19:35:23 +0000 (UTC) Received: by mail-pl0-f48.google.com with SMTP id t12-v6so6749340plo.7 for ; Thu, 07 Jun 2018 12:35:23 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:21 -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=mW458JRyMBk2ZPneYEefo/QnYUiZw2DleW+8AzIxjuw=; b=lRDHNF68ZBygyPf2GvXw9KCAscDqPKhYAWAaZ761jr4P3zJ7QPDsJ56PpYexhqdmHQ jPE6jTIUtPnOKZUxBGB0tOpaAq/htz33NLrBd3Xi0JGp0NiqW9Oeuxq+VQPt6EmZZMZn oWlEsxnjQasz+1y+3G3nuYCMSI97KXKf0FE0sSOrJSQuAhjZ2ABdMPQUCgiqdBBf3GaI IHQcUGFsly0PaS+Au+RWeh/zf2Zfh+l5BNmcX8IS0B+jtrrXeourRHRRut0fVgxBloON e02rnGQ3jktRZJd0Q1LCGf5mcbwQ2vAXizQ1N02d/OyjxcIZe+ZknH18O7mcrKNs6VrD Ot+Q== 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=mW458JRyMBk2ZPneYEefo/QnYUiZw2DleW+8AzIxjuw=; b=hBJpRpRbtM83WvSX42ssrzXIJgoOoaC3Lzui+R9i6VsVMlhxcITUOgPY+yCZ6SrjO1 sbb7op2Bc44hjEKIyGFXDVcC5WJbbV9e0vNluKQ2Q7rtDTt4G+PAa3eAEdV2z5t6qZ09 noO2w1MaewdY4hPFxFvwhY3gErC36uatO456GbINvHReoY8s6ck37ke1WUrCBpPBtXD3 PuNbXCKuGGh8wPRIwnArmJ1apc2kdkvFhd0WrVHdJWWpKAguPiUcif07/IvsbpzlDSWo /hUqUcxdTXyhbJRHK6dst3maibQlpvFVCwbP/XvlwlZ5ehWPOnTNJdHM8RhyGluzINAB Z29g== X-Gm-Message-State: APt69E0w/DbaYtpsRriz4TuBLxaq8+YIsZao7qlUi2X4BxiYKlfU8YXo y8ew5JbhW1R8AZys5pJFyy5vm3YY X-Google-Smtp-Source: ADUXVKIVR9UU39hvcbbqiulCIRomKyaJD0Frx7oY4nGMt0sB+KBBwzwyWyPrwTN68O8woxNl5F7Q2w== X-Received: by 2002:a17:902:2884:: with SMTP id f4-v6mr3359242plb.204.1528400122229; Thu, 07 Jun 2018 12:35:22 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:35 +0530 Message-Id: <1528400083-6788-14-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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, 07 Jun 2018 19:35:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 07 Jun 2018 19:35:23 +0000 (UTC) for IP:'209.85.160.48' DOMAIN:'mail-pl0-f48.google.com' HELO:'mail-pl0-f48.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.160.48 mail-pl0-f48.google.com 209.85.160.48 mail-pl0-f48.google.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 13/21] util: auth: 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 07 Jun 2018 19:35:51 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOPTR macro, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virauth.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index d3a5cc7..f000d45 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -111,8 +111,7 @@ virAuthGetCredential(const char *servicename, const char *path, char **value) { - int ret =3D -1; - virAuthConfigPtr config =3D NULL; + VIR_AUTOPTR(virAuthConfigPtr) config =3D NULL; const char *tmp; =20 *value =3D NULL; @@ -121,23 +120,19 @@ virAuthGetCredential(const char *servicename, return 0; =20 if (!(config =3D virAuthConfigNew(path))) - goto cleanup; + return -1; =20 if (virAuthConfigLookup(config, servicename, hostname, credname, &tmp) < 0) - goto cleanup; + return -1; =20 if (VIR_STRDUP(*value, tmp) < 0) - goto cleanup; - - ret =3D 0; + return -1; =20 - cleanup: - virAuthConfigFree(config); - return ret; + return 0; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400143243412.7999937742826; Thu, 7 Jun 2018 12:35:43 -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 D84873084035; Thu, 7 Jun 2018 19:35:41 +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 A42A12016A81; Thu, 7 Jun 2018 19:35:41 +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 602B74CA83; Thu, 7 Jun 2018 19:35:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZcD1019078 for ; Thu, 7 Jun 2018 15:35:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 32CBA1001647; Thu, 7 Jun 2018 19:35:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27E8F1001646 for ; Thu, 7 Jun 2018 19:35:36 +0000 (UTC) Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.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 81F4137E7B for ; Thu, 7 Jun 2018 19:35:25 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id e11-v6so5235644pgq.0 for ; Thu, 07 Jun 2018 12:35:25 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:23 -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=K6H1G5yHMVYBH1fy4U29aqrrGIyG5i6tDYAAIlVSkoo=; b=hpzS6SDWfDc5hQc+vkPIMn0l4Ic1Hzrsh5FddI+CZFEcT2fXnxiVK0KvEWssy4KKnj uPmprrB6NHTpdMrn+GuApaDobaf8AaVBkdbUtsEHAUryNpKzDeOVcaZC9aWG5ePbIo1f HjRtVbQc7DhG+o6dBbIVLBO8uVS4CqNp5SeCDL25MHYlG3reKLJcpVi40quYWiRzJL+Y qNBS8Qs69pDqMNv5O+qOrcArlkh9f6Dqh3+F8HjsrvUH40pLZdRUmUib5O1N8xvurl8G CeCXwH3VwjVeyeS4Tpq3Il5fpNGIlMQme1M5jbrNCuXx92eexcuEZw7iyFpHv1c5hFlA oFaA== 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=K6H1G5yHMVYBH1fy4U29aqrrGIyG5i6tDYAAIlVSkoo=; b=TyI0i+IWBHlaPgT2V4BKHuNaRWUWJRC5/BiGgycIa9xG6bZ4rKLHJ1l2jXoE8t8fyq b7k7A+PqQYntfRC4f9QXvvyQHpiOzk1Vqw1gZ0D8Shfd871z1t2KoYXtcbPLwbk60t1p EziNoZ4nVtmPccZvKiFtQfgscPj4sam8umYTCzjTYr3l1Ovmnd+4d2L1XW2GzzM4OUHA r0/WQdwRWeNNFwfxGDH2MWXG8++GoIRtiwgX/3//gQE/DUDj4fk+Ci2S6f2XHsX/v4L4 EaTUeZEVeEioPXLbBiMTO4GcLCrIPaUAUcj8c+9vIrIsvYDuNXMsJiPfSNngv1H+UQHX D3xQ== X-Gm-Message-State: APt69E3rZ2R68pr4MZgzRaaCBQzxTfckSqdcFhqveU5Gp1FM4WT3o8cl mHSHL0BHMUbE19/C7N4jX3rx4WWr X-Google-Smtp-Source: ADUXVKKHh2ZnpbYmwzXJhJTaPZAwXc8e0MTPbi2j8zVSxdf7SinC7Gcc5DM++aUvYh6thGtoTFogBw== X-Received: by 2002:a63:6ec8:: with SMTP id j191-v6mr2669054pgc.232.1528400124681; Thu, 07 Jun 2018 12:35:24 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:36 +0530 Message-Id: <1528400083-6788-15-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.29]); Thu, 07 Jun 2018 19:35:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 07 Jun 2018 19:35:25 +0000 (UTC) for IP:'74.125.83.67' DOMAIN:'mail-pg0-f67.google.com' HELO:'mail-pg0-f67.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) 74.125.83.67 mail-pg0-f67.google.com 74.125.83.67 mail-pg0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 14/21] util: json: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC 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.40]); Thu, 07 Jun 2018 19:35:42 +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" Using the VIR_DEFINE_AUTOPTR_FUNC macro defined in src/util/viralloc.h, define a new wrapper around an existing cleanup function which will be called when a variable declared with VIR_AUTOPTR macro goes out of scope. --- src/util/virjson.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virjson.h b/src/util/virjson.h index e4a82bd..593dcb7 100644 --- a/src/util/virjson.h +++ b/src/util/virjson.h @@ -26,6 +26,7 @@ =20 # include "internal.h" # include "virbitmap.h" +# include "viralloc.h" =20 # include =20 @@ -45,6 +46,8 @@ typedef virJSONValue *virJSONValuePtr; void virJSONValueFree(virJSONValuePtr value); void virJSONValueHashFree(void *opaque, const void *name); =20 +VIR_DEFINE_AUTOPTR_FUNC(virJSONValuePtr, virJSONValueFree) + virJSONType virJSONValueGetType(const virJSONValue *value); =20 int virJSONValueObjectCreate(virJSONValuePtr *obj, ...) --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:26 2024 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 1528400161679282.9736960489023; Thu, 7 Jun 2018 12:36:01 -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 EAFD7308FBA3; Thu, 7 Jun 2018 19:35:58 +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 A52186090E; Thu, 7 Jun 2018 19:35:58 +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 514BD1801218; Thu, 7 Jun 2018 19:35:58 +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 w57JZgBV019101 for ; Thu, 7 Jun 2018 15:35:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2FFAB9B019; Thu, 7 Jun 2018 19:35:42 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29AC29B018 for ; Thu, 7 Jun 2018 19:35:39 +0000 (UTC) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) (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 65E3FC04BE04 for ; Thu, 7 Jun 2018 19:35:28 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id j20-v6so5388669pff.10 for ; Thu, 07 Jun 2018 12:35:28 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:27 -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=8OFNYLgIZeBiV2tnSeG/gVtOExk6zLtqwFhwoiOp1rE=; b=SL9chRF8h0/8iquYm0NZCO7zbq+ykjUitGdbX2xhb9Vw3SMGzUERlEiO02C50q0hoY KDvsjCUfnxQLT+Ns9psOb5F5I3LymSqkLHOoh1Gg6oUv5ZKM4INCZNjqMvJ02HS/PqLI XCPJW0nIuvbp1s0s3PAFLaYMVtwPI08/ho7f7PHR4/8VuKmI3jHcWfunMmfIHIYpPbpD WkztoRfisZFJU+fBOC9PkPFUlqaY0QdSSWSHMdK6vJVP9rsOaENqLqSKcgXharcG4W44 TmsRQI4DID5neq5re/MMZGMsVt09JdcWpkwpvB9ZsHx8LjhRS1X4Cst5KWUocYXgazoM zJ2g== 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=8OFNYLgIZeBiV2tnSeG/gVtOExk6zLtqwFhwoiOp1rE=; b=oqzFhngyb+7L/g4UOUQ1rcFHYTWL+XDjVQifJu013jbKb/HY5/B0EVN91Ws9utuCLp GF97EWF0q5Sm+1Lr99ja9mtXE08kmUVReUE/wBh8k6U+7i1heSUtr8zAqgL3Zm5cyFCb a+DU5Dn5lgwWyf8bMc9GYuaKBHeq6MOTycd9X2CiAk/Ki+y/4f/3NQWAQQuFHt5U0wO8 vkSqYIrcs5aTtEGWIaY6H0Kvkvm/Mgf/eenNnPVyWRyQaxbSyjJcx5kw8Km69HZxAWP9 e0J5yRysV6kwQVCU8CjsTIYzRN/9McMMpPmkYl/QGBpSUuUZzI38pAipSUk1Lq8+jmaJ gcXg== X-Gm-Message-State: APt69E39vbBlkXuEa8/W5l6IPeqYYf0b0FoCbBdmZWWahupry1NvFwjW e2/JP0fq4WsEqFng6bvAo6NTIQ+Y X-Google-Smtp-Source: ADUXVKLQ/JTvoVHECDRlkrGgCxUvkWKOXd79ycTm4+uroV2Qtw2pkOKZcc/lNASr7nNciA/VduqzBg== X-Received: by 2002:a63:7409:: with SMTP id p9-v6mr2683113pgc.252.1528400127549; Thu, 07 Jun 2018 12:35:27 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:37 +0530 Message-Id: <1528400083-6788-16-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.31]); Thu, 07 Jun 2018 19:35:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 07 Jun 2018 19:35:28 +0000 (UTC) for IP:'209.85.192.195' DOMAIN:'mail-pf0-f195.google.com' HELO:'mail-pf0-f195.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.195 mail-pf0-f195.google.com 209.85.192.195 mail-pf0-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 15/21] util: json: remove redundant include directive 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.43]); Thu, 07 Jun 2018 19:36:01 +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" The include directive for viralloc.h is added in virjson.h in the previous patch. --- src/util/virjson.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 0559d40..92f3994 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -24,7 +24,6 @@ #include =20 #include "virjson.h" -#include "viralloc.h" #include "virerror.h" #include "virlog.h" #include "virstring.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:27 2024 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 1528400158013403.8282113850087; Thu, 7 Jun 2018 12:35:58 -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 B0BCF4E4C3; Thu, 7 Jun 2018 19:35:56 +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 5E6DE60927; Thu, 7 Jun 2018 19:35:56 +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 E01631801218; Thu, 7 Jun 2018 19:35:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZlf1019115 for ; Thu, 7 Jun 2018 15:35:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8DBE45D761; Thu, 7 Jun 2018 19:35:47 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8692D5B680 for ; Thu, 7 Jun 2018 19:35:42 +0000 (UTC) Received: from mail-pg0-f43.google.com (mail-pg0-f43.google.com [74.125.83.43]) (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 66DBB3082144 for ; Thu, 7 Jun 2018 19:35:31 +0000 (UTC) Received: by mail-pg0-f43.google.com with SMTP id p9-v6so5220485pgc.9 for ; Thu, 07 Jun 2018 12:35:31 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:30 -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=AQt4B54qTp0e6xJaHJk2Dh50SeV4Crd4xQNnJydMDK8=; b=bWk0CSH9zk/ZSyTRsXz1EMcoW/yvZAGmA0b2mc5ILPdPd1AeINYTFedFy5KqLX5e/t pgEBntU8IKC8WU5i1Bd3zqNuabdsUROcL7YAtr53qsj/VFECH8cDR729glYlZ9EMWCWt /8zw3irXyA4wIrM3lTSy4Dl9gKrzusr8sleYZa53qzbqISrUQOwNUCPr/NkjvonQQd0I 9h3XwA/+CNTmIr0HRhll9Iap6uBHvm6471DRDdLVeE0JF7aNd0P7rZ3/keO81FbriuuV 4YZr9l9i9AAvgjZEHJ/Uoe8fAwvGuLTe2JDWnztQaKcxw94rYkpsWGgSEOjBGGpBf3jl ypvg== 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=AQt4B54qTp0e6xJaHJk2Dh50SeV4Crd4xQNnJydMDK8=; b=VoCUu8GWsZpXusTKdDx8203g4WyC3eOMYGVgVkBJ7r/YtpgvRYo6L7U+V4q0s381/X WnpyswA4EoTNTnyX+xxFRfyOgF8ewUjj9ba2WVdOaONWiPqLRMk4vXPnzvIza0rVKbK/ UI4PYCLHdCLpOTEBH78H3bM0JQWz4Co23lp6PXnrpx0sGZsRQHUDlM2FfAv8DorzpjrR M2tzH6dLWnTmcQrLK5Ibg8pJXBBvsR5nc5yXNAWsOT7mUCDaEzmTGNOF7Z7z3kzD4tFW HjLsShgg0GxiwCnLmgufn5+tA/jbqn30T+XShE8Kr9GjuX5XiuJcjKS7ZGeKycR6/PEu nsUA== X-Gm-Message-State: APt69E2IHNc653vrfG+AVsBAU//WO8kKAOUAPSfjmn4G49Lqgi09b7yo PRxtfEMEx9ISC+PwAVLCIzMhQaqE X-Google-Smtp-Source: ADUXVKKScxZ4IFcp7iDLko7qCQeGXmK0VyYeth8zkA8UcdjOQgYng40JOtt/SWabsOCiQcwejck9sg== X-Received: by 2002:a65:62cd:: with SMTP id m13-v6mr2687955pgv.207.1528400130522; Thu, 07 Jun 2018 12:35:30 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:38 +0530 Message-Id: <1528400083-6788-17-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.42]); Thu, 07 Jun 2018 19:35:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 07 Jun 2018 19:35:31 +0000 (UTC) for IP:'74.125.83.43' DOMAIN:'mail-pg0-f43.google.com' HELO:'mail-pg0-f43.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.43 mail-pg0-f43.google.com 74.125.83.43 mail-pg0-f43.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 16/21] util: json: 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.38]); Thu, 07 Jun 2018 19:35:57 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virjson.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 92f3994..1391a3b 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -497,11 +497,10 @@ virJSONValuePtr virJSONValueNewNumberInt(int data) { virJSONValuePtr val =3D NULL; - char *str; + VIR_AUTOFREE(char *) str =3D NULL; if (virAsprintf(&str, "%i", data) < 0) return NULL; val =3D virJSONValueNewNumber(str); - VIR_FREE(str); return val; } =20 @@ -510,11 +509,10 @@ virJSONValuePtr virJSONValueNewNumberUint(unsigned int data) { virJSONValuePtr val =3D NULL; - char *str; + VIR_AUTOFREE(char *) str =3D NULL; if (virAsprintf(&str, "%u", data) < 0) return NULL; val =3D virJSONValueNewNumber(str); - VIR_FREE(str); return val; } =20 @@ -523,11 +521,10 @@ virJSONValuePtr virJSONValueNewNumberLong(long long data) { virJSONValuePtr val =3D NULL; - char *str; + VIR_AUTOFREE(char *) str =3D NULL; if (virAsprintf(&str, "%lld", data) < 0) return NULL; val =3D virJSONValueNewNumber(str); - VIR_FREE(str); return val; } =20 @@ -536,11 +533,10 @@ virJSONValuePtr virJSONValueNewNumberUlong(unsigned long long data) { virJSONValuePtr val =3D NULL; - char *str; + VIR_AUTOFREE(char *) str =3D NULL; if (virAsprintf(&str, "%llu", data) < 0) return NULL; val =3D virJSONValueNewNumber(str); - VIR_FREE(str); return val; } =20 @@ -549,11 +545,10 @@ virJSONValuePtr virJSONValueNewNumberDouble(double data) { virJSONValuePtr val =3D NULL; - char *str; + VIR_AUTOFREE(char *) str =3D NULL; if (virDoubleToStr(&str, data) < 0) return NULL; val =3D virJSONValueNewNumber(str); - VIR_FREE(str); return val; } =20 @@ -1171,10 +1166,9 @@ int virJSONValueGetArrayAsBitmap(const virJSONValue *val, virBitmapPtr *bitmap) { - int ret =3D -1; virJSONValuePtr elem; size_t i; - unsigned long long *elems =3D NULL; + VIR_AUTOFREE(unsigned long long *) elems =3D NULL; unsigned long long maxelem =3D 0; =20 *bitmap =3D NULL; @@ -1191,25 +1185,20 @@ virJSONValueGetArrayAsBitmap(const virJSONValue *va= l, =20 if (elem->type !=3D VIR_JSON_TYPE_NUMBER || virStrToLong_ullp(elem->data.number, NULL, 10, &elems[i]) < 0) - goto cleanup; + return -1; =20 if (elems[i] > maxelem) maxelem =3D elems[i]; } =20 if (!(*bitmap =3D virBitmapNewQuiet(maxelem + 1))) - goto cleanup; + return -1; =20 /* second pass sets the correct bits in the map */ for (i =3D 0; i < val->data.array.nvalues; i++) ignore_value(virBitmapSetBit(*bitmap, elems[i])); =20 - ret =3D 0; - - cleanup: - VIR_FREE(elems); - - return ret; + return 0; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:27 2024 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 1528400152087816.6166230027903; Thu, 7 Jun 2018 12:35:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F22EB81E04; Thu, 7 Jun 2018 19:35:50 +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 AED5F60C4E; Thu, 7 Jun 2018 19:35:50 +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 620F24CA91; Thu, 7 Jun 2018 19:35:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZmrB019120 for ; Thu, 7 Jun 2018 15:35:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3BBE15D750; Thu, 7 Jun 2018 19:35:48 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 345BF5B683 for ; Thu, 7 Jun 2018 19:35:47 +0000 (UTC) Received: from mail-pg0-f45.google.com (mail-pg0-f45.google.com [74.125.83.45]) (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 BD56E308626E for ; Thu, 7 Jun 2018 19:35:36 +0000 (UTC) Received: by mail-pg0-f45.google.com with SMTP id l65-v6so5224252pgl.8 for ; Thu, 07 Jun 2018 12:35:36 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:32 -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=FqZoJFujBMNhdqgOGJHCk+ELdPHk+aT56JOQTKLCnLI=; b=GjIiQPH4O1Gnstqhlf07mAhUwEw5pALjOgdKmmmg93j3TFRGfQxbxnUhcchcjmsaNk gYZ4TMqYjBnG7bkj6VEyF/9qILH+lKsCXytwsc/u4dHbTf6F6SpU/Jfg/CGOjG7PDLla 76/11Le1oHidGUuJ6HTlnh/OLTU3jkH3s9D0cDsoJH2DwW48XJe/zvaUmgabQAky8tYj jwBaeKfja/lR+0q6lWpVmFzSQ79pIrSNK4SE3dNQbvok4brjAb9OtJ3qLNZOkEakfJzz UWgBBYEzh+twIS96wyYVPmL9Ten+IIgxBetJu8MC0Q2b2DWHn12sjTta1LIEGJjYC4gQ KDUQ== 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=FqZoJFujBMNhdqgOGJHCk+ELdPHk+aT56JOQTKLCnLI=; b=BLB+ccEC5sznFh4vQeFebJk8rPvGgW3xLbrXy1sIen6JWlE9Fo7jOWGLZodjuu098y 9n/ZFIULtLcEQ7HTaBH77cMqlHmM0JN0p/3axN3Ew53N7WfQ5O8+AjbZ0JXLO6ofVx/I x5pW1e2k2l2NeX0fCD15qOYIlA+c6znWQfZ1fz1/FDHdPF0Gnk0g8v/psrzkpu+cmPrl RkPKQoibvz8d5UUPozDaWjDmkapKMihnJV7ELdrK94pemXTNCWVGjDe9k+aetZfaxJyX V7aOceUZ8mBaOCV7+wqVKJbviJVM/u+x3FWLaYB+2ikSeUDa8Z+VuAt3r6opcW376qlM h8iQ== X-Gm-Message-State: APt69E3m3ErLY/Y05cdASxpN5dVk1HVNPyIM1qaGfcLMXRNn8XbabxB6 NLON7U8fbondFp7g8WrYkMOcd0/9 X-Google-Smtp-Source: ADUXVKKk2STb9W+Ig4xHXGtb4NPJH28iFEZH/bfBTSFQKi5jY76R3YLMKPfNh6vew7DtYwuPJC/6cg== X-Received: by 2002:a63:6c03:: with SMTP id h3-v6mr2633804pgc.28.1528400132502; Thu, 07 Jun 2018 12:35:32 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:39 +0530 Message-Id: <1528400083-6788-18-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.49]); Thu, 07 Jun 2018 19:35:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 19:35:36 +0000 (UTC) for IP:'74.125.83.45' DOMAIN:'mail-pg0-f45.google.com' HELO:'mail-pg0-f45.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.45 mail-pg0-f45.google.com 74.125.83.45 mail-pg0-f45.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 17/21] util: json: 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 07 Jun 2018 19:35:51 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOPTR macro, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virjson.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 1391a3b..3b54d94 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -2033,16 +2033,12 @@ char * virJSONStringReformat(const char *jsonstr, bool pretty) { - virJSONValuePtr json; - char *ret; + VIR_AUTOPTR(virJSONValuePtr) json =3D NULL; =20 if (!(json =3D virJSONValueFromString(jsonstr))) return NULL; =20 - ret =3D virJSONValueToString(json, pretty); - - virJSONValueFree(json); - return ret; + return virJSONValueToString(json, pretty); } =20 =20 @@ -2131,7 +2127,7 @@ virJSONValueObjectDeflattenWorker(const char *key, virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json) { - virJSONValuePtr deflattened; + VIR_AUTOPTR(virJSONValuePtr) deflattened =3D NULL; virJSONValuePtr ret =3D NULL; =20 if (!(deflattened =3D virJSONValueNewObject())) @@ -2140,12 +2136,9 @@ virJSONValueObjectDeflatten(virJSONValuePtr json) if (virJSONValueObjectForeachKeyValue(json, virJSONValueObjectDeflattenWorke= r, deflattened) < 0) - goto cleanup; + return NULL; =20 VIR_STEAL_PTR(ret, deflattened); =20 - cleanup: - virJSONValueFree(deflattened); - return ret; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:27 2024 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 1528400168148847.8172209532081; Thu, 7 Jun 2018 12:36:08 -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 11BE1308A95E; Thu, 7 Jun 2018 19:36: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 D06DC600C9; Thu, 7 Jun 2018 19:36:06 +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 63819180BA83; Thu, 7 Jun 2018 19:36:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZtqL019145 for ; Thu, 7 Jun 2018 15:35:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5578B60E37; Thu, 7 Jun 2018 19:35:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BBD160C4E for ; Thu, 7 Jun 2018 19:35:49 +0000 (UTC) Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) (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 63D4380F8F for ; Thu, 7 Jun 2018 19:35:37 +0000 (UTC) Received: by mail-pf0-f194.google.com with SMTP id a11-v6so5394744pff.8 for ; Thu, 07 Jun 2018 12:35:37 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:34 -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=kajc04scwxEqmm78RcfxJEb6zXVtQchxVL8RTp3ttYU=; b=YqucLRdZ0YEsid0tR2iGm3hOCpXTp1x4fuMIChFV4l7ZvUF3RhMH8wrCBF2SVkR9VK eJXVs/FxaBtkl7Eyn+IbGzlPIzK5XTqnFrvq7ak6YyY5qDekOeNtStQX1hJoMTbpU2cJ B2p/h96fDzyWJnA2azWSU7pJuBNZhy9nHfG+vqxeXRcDR45XD5teM+u0SdaD1KWKre/1 SG5g9fTw37Gil9Lsr+aWfIph4Zq6koOkFxWsa2C+r0PyJClJVrKyFJqgZBCEAAgPyju8 ayhDuXABPbzP/X26KzVorw5B+EACJYQ+vQ4WG4Jun4LXoO7GfSKqJsQNIXI5jSznE+bY S3Cg== 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=kajc04scwxEqmm78RcfxJEb6zXVtQchxVL8RTp3ttYU=; b=nBxwfxKFvf8Ka+BRmqwyDoDyhJQrXG0PuG509YgvlujCrzF+J1Wbxa0UTDcROjU09d wXFroeQEAT1rZqd3mLIUicIM1DZuwAKTI+HMs7Y1B2loebFjKnMwP7bdGjm466NE6ASD a0Vp5KwPOhHisJlmMLoRQFNfs0qO0QcAJluiNoixKpEMDCtHnpEBzjwxZ1V9hFfWAeCd m3gWRFYf31lF8Njg9Le7sXWk/guk+tV2h8S+0/vzpjhG9H8NS61OzMRs2U9vufk3zgWr iA81RwkXNWP5DvjB9lTaiwOAyRUZ5BhT9zwBhTXkG/akWm/laukULGJpfvAS3L1JRHHN eOIA== X-Gm-Message-State: APt69E38mP1zO0lLfpZ/Tul6XIWR/qZLHtn4U/LJ5foVepgzNiBZ0fWW f4OmFPTeKIB/4O4mOZpUwUfnT0HW X-Google-Smtp-Source: ADUXVKIm10oMYwt7tjyHLLVnB1j8pxXVgQ9Nh5LodBK/SXPOoyzf1MzmxemXfJT2iw85eMoxAeOq2Q== X-Received: by 2002:a62:cf44:: with SMTP id b65-v6mr2953863pfg.80.1528400134654; Thu, 07 Jun 2018 12:35:34 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:40 +0530 Message-Id: <1528400083-6788-19-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.27]); Thu, 07 Jun 2018 19:35:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 07 Jun 2018 19:35:37 +0000 (UTC) for IP:'209.85.192.194' DOMAIN:'mail-pf0-f194.google.com' HELO:'mail-pf0-f194.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.511 (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.194 mail-pf0-f194.google.com 209.85.192.194 mail-pf0-f194.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 18/21] util: identity: 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 07 Jun 2018 19:36:07 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/viridentity.c | 54 ++++++++++++++++++++--------------------------= ---- 1 file changed, 22 insertions(+), 32 deletions(-) diff --git a/src/util/viridentity.c b/src/util/viridentity.c index 2f4307b..2060dd7 100644 --- a/src/util/viridentity.c +++ b/src/util/viridentity.c @@ -133,8 +133,8 @@ int virIdentitySetCurrent(virIdentityPtr ident) */ virIdentityPtr virIdentityGetSystem(void) { - char *username =3D NULL; - char *groupname =3D NULL; + VIR_AUTOFREE(char *) username =3D NULL; + VIR_AUTOFREE(char *) groupname =3D NULL; unsigned long long startTime; virIdentityPtr ret =3D NULL; #if WITH_SELINUX @@ -154,14 +154,14 @@ virIdentityPtr virIdentityGetSystem(void) goto error; =20 if (!(username =3D virGetUserName(geteuid()))) - goto cleanup; + return ret; if (virIdentitySetUNIXUserName(ret, username) < 0) goto error; if (virIdentitySetUNIXUserID(ret, getuid()) < 0) goto error; =20 if (!(groupname =3D virGetGroupName(getegid()))) - goto cleanup; + return ret; if (virIdentitySetUNIXGroupName(ret, groupname) < 0) goto error; if (virIdentitySetUNIXGroupID(ret, getgid()) < 0) @@ -172,7 +172,7 @@ virIdentityPtr virIdentityGetSystem(void) if (getcon(&con) < 0) { virReportSystemError(errno, "%s", _("Unable to lookup SELinux process conte= xt")); - goto cleanup; + return ret; } if (virIdentitySetSELinuxContext(ret, con) < 0) { freecon(con); @@ -182,15 +182,9 @@ virIdentityPtr virIdentityGetSystem(void) } #endif =20 - cleanup: - VIR_FREE(username); - VIR_FREE(groupname); - return ret; - error: virObjectUnref(ret); - ret =3D NULL; - goto cleanup; + return NULL; } =20 =20 @@ -461,15 +455,14 @@ int virIdentitySetUNIXUserName(virIdentityPtr ident, int virIdentitySetUNIXUserID(virIdentityPtr ident, uid_t uid) { - char *val; - int ret; + VIR_AUTOFREE(char *) val =3D NULL; + if (virAsprintf(&val, "%d", (int)uid) < 0) return -1; - ret =3D virIdentitySetAttr(ident, + + return virIdentitySetAttr(ident, VIR_IDENTITY_ATTR_UNIX_USER_ID, val); - VIR_FREE(val); - return ret; } =20 =20 @@ -485,45 +478,42 @@ int virIdentitySetUNIXGroupName(virIdentityPtr ident, int virIdentitySetUNIXGroupID(virIdentityPtr ident, gid_t gid) { - char *val; - int ret; + VIR_AUTOFREE(char *) val =3D NULL; + if (virAsprintf(&val, "%d", (int)gid) < 0) return -1; - ret =3D virIdentitySetAttr(ident, + + return virIdentitySetAttr(ident, VIR_IDENTITY_ATTR_UNIX_GROUP_ID, val); - VIR_FREE(val); - return ret; } =20 =20 int virIdentitySetUNIXProcessID(virIdentityPtr ident, pid_t pid) { - char *val; - int ret; + VIR_AUTOFREE(char *) val =3D NULL; + if (virAsprintf(&val, "%lld", (long long) pid) < 0) return -1; - ret =3D virIdentitySetAttr(ident, + + return virIdentitySetAttr(ident, VIR_IDENTITY_ATTR_UNIX_PROCESS_ID, val); - VIR_FREE(val); - return ret; } =20 =20 int virIdentitySetUNIXProcessTime(virIdentityPtr ident, unsigned long long timestamp) { - char *val; - int ret; + VIR_AUTOFREE(char *) val =3D NULL; + if (virAsprintf(&val, "%llu", timestamp) < 0) return -1; - ret =3D virIdentitySetAttr(ident, + + return virIdentitySetAttr(ident, VIR_IDENTITY_ATTR_UNIX_PROCESS_TIME, val); - VIR_FREE(val); - return ret; } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:27 2024 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 1528400158688968.5741930133532; Thu, 7 Jun 2018 12:35:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C5CF308124A; Thu, 7 Jun 2018 19:35:57 +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 605DA2B4AB; Thu, 7 Jun 2018 19:35:57 +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 ED914180121C; Thu, 7 Jun 2018 19:35:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZrGs019136 for ; Thu, 7 Jun 2018 15:35:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 80E1B308BDB2; Thu, 7 Jun 2018 19:35:53 +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 78FDE308BDB1 for ; Thu, 7 Jun 2018 19:35:49 +0000 (UTC) Received: from mail-pg0-f46.google.com (mail-pg0-f46.google.com [74.125.83.46]) (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 6D218820E4 for ; Thu, 7 Jun 2018 19:35:37 +0000 (UTC) Received: by mail-pg0-f46.google.com with SMTP id p9-v6so5220606pgc.9 for ; Thu, 07 Jun 2018 12:35:37 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:36 -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=ca1rysv5j4+fAbHwK4ZhXQvn/gYhwesrsUlJDt9s+yc=; b=UNbemecAkh15Bl+LXeLhODkcH/8aFlRIDHeNJ60LsFUqQzeB4IzkzTRjTvMFSpHDsB 9V0Ek3FfcN9ExW6xqteq4K7AdfkC3lrJBTdLW+YtgDwdWJYCr2HWkle1wI/U0jWEOLz5 M3X5DfMjzUxLeJP2CAxxyK5WY9HTzumPYBWBq/EnMnmywppwfr56J4NpS8FPpc4auzPI SGB6tIOcbGi+rHxljKLKKriwmWCMFu9x2rwvtarM8On9wx4kBWAylg+eeB+r0YtlqJyY ohEJWGLsIzm54d2ojj1voZpSncxHzWcm0Rb5nQ1qgw4zXscUIlPjYD+2W1pTf8oA6K4G mU3g== 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=ca1rysv5j4+fAbHwK4ZhXQvn/gYhwesrsUlJDt9s+yc=; b=fD83+Gexku4dUhGXYnWSb2mVMCEnLt8Mpc2mOHCzoKBNj4AW/ehG3or951JV0qgZS8 ticly1n0KIiGverq18yq0Xfxyln9EK8XdjxNVfb+Ff7xhqFU8kaY1KdY1DFRArZ73LS1 2o13XesahJXOgZKc/yEh6/hBO2j19DwHDbU8mShYHgurEAJdDwskCdz2hAw652QHjtvY dWf4k6CwAYxF7TTNtvFhT749VBqvDjbaJ2q4s+XwHD1qzx7+BWLbKQJuYFmAYuFLIZbR fNwyW6gLqlyTy8RM+8U3WJKeWnF+t9qqopxvTXSOYpoCimcfF3pV18+lwHPxOfPDehrP 5VjQ== X-Gm-Message-State: APt69E2aOBCIrS53FEo9nhYcNnrjwnSLM3uUtzsAlHi7xgBhEdP9C8hj OmQDbgDp9c7cCFD1We3GH8OB1sq9 X-Google-Smtp-Source: ADUXVKL9HLlqpNvELjZTo0ncDIfejOnnwsCSrQPqW8AYgSwEowPFbo1PeVZTTz0jqcL4koxznAuDHA== X-Received: by 2002:a62:3fdd:: with SMTP id z90-v6mr2954974pfj.216.1528400136668; Thu, 07 Jun 2018 12:35:36 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:41 +0530 Message-Id: <1528400083-6788-20-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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, 07 Jun 2018 19:35:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 07 Jun 2018 19:35:37 +0000 (UTC) for IP:'74.125.83.46' DOMAIN:'mail-pg0-f46.google.com' HELO:'mail-pg0-f46.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.46 mail-pg0-f46.google.com 74.125.83.46 mail-pg0-f46.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 19/21] util: bitmap: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 19:35:58 +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" Using the VIR_DEFINE_AUTOPTR_FUNC macro defined in src/util/viralloc.h, define a new wrapper around an existing cleanup function which will be called when a variable declared with VIR_AUTOPTR macro goes out of scope. --- src/util/virbitmap.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 2464814..86bb84e 100644 --- a/src/util/virbitmap.h +++ b/src/util/virbitmap.h @@ -25,6 +25,7 @@ # define __BITMAP_H__ =20 # include "internal.h" +# include "viralloc.h" =20 # include =20 @@ -44,6 +45,8 @@ virBitmapPtr virBitmapNewEmpty(void) ATTRIBUTE_RETURN_CHE= CK; */ void virBitmapFree(virBitmapPtr bitmap); =20 +VIR_DEFINE_AUTOPTR_FUNC(virBitmapPtr, virBitmapFree) + /* * Copy all bits from @src to @dst. The bitmap sizes * must be the same --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:27 2024 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 1528400179007369.5151030539739; Thu, 7 Jun 2018 12:36:19 -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 C6D11356E7; Thu, 7 Jun 2018 19:36:17 +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 7EABC60170; Thu, 7 Jun 2018 19:36:17 +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 F1549180BA8A; Thu, 7 Jun 2018 19:36:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JaDoL019332 for ; Thu, 7 Jun 2018 15:36:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE48C60170; Thu, 7 Jun 2018 19:36:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B81D2600D1 for ; Thu, 7 Jun 2018 19:36:10 +0000 (UTC) Received: from mail-pl0-f42.google.com (mail-pl0-f42.google.com [209.85.160.42]) (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 962213086273 for ; Thu, 7 Jun 2018 19:35:56 +0000 (UTC) Received: by mail-pl0-f42.google.com with SMTP id c41-v6so6755664plj.10 for ; Thu, 07 Jun 2018 12:35:56 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:38 -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=VSXciI06tXTjFotiQ1+jcd1szIK/jQc7CIz3dEL5piE=; b=AFxBUyMumtaawh0HTlz7PrkCAksPSbw7+EfSnBOYLZzQN/DvY8XM2wMnHbLrGDdx00 tdTr577ymljFxAmQzaA+7JZTchdTrZnzsKLblz+ysTkwI5IGY/gZkI8byqzoCn48ba6W dbzM0z7NxCSfYFe/koIVbW53oQXkQepAXYMXDM7ErxEPAieElPL2OPxgMe7xB93hPDF7 WlTUkQsnvlxjydQJD3DHKiY5uiUb3UwRQikaYwIkfw01ABG1zQR6/XnrhadcjvIy6VFI 1FtiAxVfN43WM3hVVHp+tbSKEqQBahMaElUo9BuiCChCt9N8XHdTTJEsEUyGzAseLMI3 PjTw== 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=VSXciI06tXTjFotiQ1+jcd1szIK/jQc7CIz3dEL5piE=; b=dZZ4Prtnex/++9jTwcib8jYyPcmxDFVpVxbEhBLNlPLZc0hQecMFyeS+RBWHG6Jo0s ZWFO2PXXUu29OYjfdsikEg+cj8Pr4IJe304jlpNxXkGzc0l7/WNWqjctz3297n5AOQra lC0wTSVXwZM1fzyXBr/8/RwjA6XgWCOJQKDL8CrEpHKDDQUtWZ9YGvG9bb2UCXvhQWuS mkHdxRTwE3CzDptopbJHkU+b6w5dKGz8jksKBUnsk/FNheEKeZnS7XbFgAXIrriq2cEz v6KaXO79HLBd4lGnQ2rJrBwcL1x4tbF5An1JA7oHuleYNG0rdJ3kgHCE4hlhQmp8Ptx4 zmdQ== X-Gm-Message-State: APt69E1V3RKu+tYppAZlPZRHsVFN7nHPKwkAnLkY9q8MAH4VQwG1ljuX FfNYmm3yq4Hq8BCpSQgx8BhqyjxH X-Google-Smtp-Source: ADUXVKKsDDtGO6t7l6f20y6LA0I1FF2Ud5xk16kH4QTkfGVXwvvMiZ46xaCTOZHA1poOIoMfYMGfDA== X-Received: by 2002:a17:902:722:: with SMTP id 31-v6mr3416773pli.3.1528400138842; Thu, 07 Jun 2018 12:35:38 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:42 +0530 Message-Id: <1528400083-6788-21-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.49]); Thu, 07 Jun 2018 19:35:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 19:35:56 +0000 (UTC) for IP:'209.85.160.42' DOMAIN:'mail-pl0-f42.google.com' HELO:'mail-pl0-f42.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.160.42 mail-pl0-f42.google.com 209.85.160.42 mail-pl0-f42.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 20/21] util: bitmap: remove redundant include directive 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.30]); Thu, 07 Jun 2018 19:36:18 +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" The include directive for viralloc.h is added in virbitmap.h in the previous patch. --- src/util/virbitmap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 0cc5292..ef18dad 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -31,7 +31,6 @@ #include =20 #include "virbitmap.h" -#include "viralloc.h" #include "virbuffer.h" #include "c-ctype.h" #include "count-one-bits.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu May 2 08:22:27 2024 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 1528400179094424.84769807628595; Thu, 7 Jun 2018 12:36:19 -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 977A5C047B74; Thu, 7 Jun 2018 19:36:17 +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 5C6B73083326; Thu, 7 Jun 2018 19:36:17 +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 B9E9A180BA88; Thu, 7 Jun 2018 19:36:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JaDqL019331 for ; Thu, 7 Jun 2018 15:36:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB9E860175; Thu, 7 Jun 2018 19:36:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB83A60170 for ; Thu, 7 Jun 2018 19:36:11 +0000 (UTC) Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.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 2E966308124B for ; Thu, 7 Jun 2018 19:35:58 +0000 (UTC) Received: by mail-pf0-f182.google.com with SMTP id a22-v6so5391542pfo.12 for ; Thu, 07 Jun 2018 12:35:58 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.35.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:35:40 -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=NWlq9kN/v3NhUPJt7fcteisZJAzxvN/tiWxMbf6oNC4=; b=iWAzeXNu5V/KJw3sdx25uxxKx64aehOllKm+pC2tLz3Bkiy5l0eFlpW5jiyG/Lu4Nz T95p1YynsD45sQt8O6BuTuWDB/10e52/bkmcXl+vyajZGYolEIIfGIKSfS/QN8kB9KdW V47op0aa+fdO3tpIjh55OeVkAhPVv357M59DUn0gLgPf1qMmKKWZb+X9d0Sa6zwWx+5N fV1iA5n1w5FoVikNK6LSGu6YgWeM9Uuxe+vJP32uI5KqX343xLEoj0fbeRZgRxQpNlHs 2+dIKDbWkwFRbR4iFeFqIQiVm+XMNlVzA8+5bWY2zaCFTAa8BQtrdS6Fwm1YT1eyfcyB HLNg== 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=NWlq9kN/v3NhUPJt7fcteisZJAzxvN/tiWxMbf6oNC4=; b=tQcasbodZrPqaqyIM9BvOsmdiW/LwvNn1OD809Qhq533/9MCF/ayAzunB/fhBixmlh iIAArx/wM9+cIvBcy7VMp7kuX1cZvRI/TQ4vJNIExrNGiPj92f1Dte4Kk+Y/oNEmvlh7 xI+Too9Xcq5UeZnXpWgwgiGy/VNYAIp6kJkogb0Hx9ofLU7x4JqAvHMyq/+BanYcZ5// hVVNHb+36XkkukmlayNYJNGYLGCflYZDt+u5VVbOVUDuA0MmFz+IPlDs68V1Ys6T28fL ez1DBkU/y7e8gI7Pmx97U3uMyqZnn8H9hAfI2Oo3IrTjrBpYdgESWwJdBpwSObv3N18+ 7kWw== X-Gm-Message-State: APt69E3cQTid8mkj7pagt4D0blhPi6+nc+VQHio0Jz7bZOQF3RQtVTzr vF6bXpMLeuegJeMGSlXhohlPgKe0 X-Google-Smtp-Source: ADUXVKIpOJk3AdPGMElQQ4N7BFas9f4Fxuqb8cJgy8o3SZSWK+IaCJ9BlIn5njqravT3ilZqFKRx4Q== X-Received: by 2002:a65:6355:: with SMTP id p21-v6mr2598494pgv.293.1528400141271; Thu, 07 Jun 2018 12:35:41 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:43 +0530 Message-Id: <1528400083-6788-22-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.49]); Thu, 07 Jun 2018 19:35:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 07 Jun 2018 19:35:58 +0000 (UTC) for IP:'209.85.192.182' DOMAIN:'mail-pf0-f182.google.com' HELO:'mail-pf0-f182.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.182 mail-pf0-f182.google.com 209.85.192.182 mail-pf0-f182.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 21/21] util: bitmap: 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.31]); Thu, 07 Jun 2018 19:36:18 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOPTR macro, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virbitmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index ef18dad..37e5c0e 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -1202,15 +1202,12 @@ char * virBitmapDataFormat(const void *data, int len) { - virBitmapPtr map =3D NULL; - char *ret =3D NULL; + VIR_AUTOPTR(virBitmapPtr) map =3D NULL; =20 if (!(map =3D virBitmapNewData(data, len))) return NULL; =20 - ret =3D virBitmapFormat(map); - virBitmapFree(map); - return ret; + return virBitmapFormat(map); } =20 =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list