From nobody Sun May 12 10:15:23 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 153048145270559.57173838187259; Sun, 1 Jul 2018 14:44:12 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26E9330E684F; Sun, 1 Jul 2018 21:44: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 BF6E017CC8; Sun, 1 Jul 2018 21:44:10 +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 5EAAF18037ED; Sun, 1 Jul 2018 21:44:09 +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 w61Li6kl009008 for ; Sun, 1 Jul 2018 17:44:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDDD04B7; Sun, 1 Jul 2018 21:44:06 +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 E3B1F5C541 for ; Sun, 1 Jul 2018 21:44:04 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.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 B6EEB87623 for ; Sun, 1 Jul 2018 21:43:51 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id i7-v6so6209772pgp.2 for ; Sun, 01 Jul 2018 14:43:51 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.43.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:43:50 -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=m2YZK9zMymqrh8B/U/U/iI9+/hISBuxIBgBHbSYgPt4=; b=ei2pTXf35CvbXcdB7OKO16kmSIa78H/yoo14EyvKBB2IHQtDibiKQpfNfUt/CEBw8G +HXdfIzd08guk44KZpYNLiRns/mBrnVqkPANPUvJwbzm+E5swxluh81jdTR8k8R8+pTk rDpchJy7GdDyES6tDHR0FkSikUKL8+FvNtBrn9bJ795ayvvO8wEPv1gFqFoIKBd4TjNv gryhal+VG5SSh8tfxa93c2RJGbdcKw6ngHr4AVfIWExziL7Kktp9CjeuCLo+PtDICw4f 3V4mog2O4amac5FrOjBPxJNFfji5tV8BIBW4livtNYodZd8YzG7Eb60N/TeIfJ4DKD7u Xy/A== 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=m2YZK9zMymqrh8B/U/U/iI9+/hISBuxIBgBHbSYgPt4=; b=njtkQUnL0NYfVo9WhFqbvuaTSpOZl3AEomdkIz5dZorkngE1DoUBIUU3FDv2/bhPbF 3Mzuaa691KcOsc4ayzJs1wCfP3Pf7CKVeu7n9ylLxCUTOPJnfTWQhCVomSe5xsK90utk wELGK5tWW7ENZ0uAcxkeUXcDxWRDsPgaQOZuAMIMKrUFgFMm8tZyYQGf00Y3hbFPdPIE WDgqW6eHMWHuwvyTzh6uSVrMEUgaQzYeOZh48CnP+FOYiOSQOEaSeiTYVUSyHDN21vkD ouoM9jlv10QhjmKZvb0xKMNY41RHeyYIDw1E/I7l0xRxMnc69OicZ35XU64xtx2q8Zb1 ufwA== X-Gm-Message-State: APt69E0i1E9VR12F1C9CzF9a53YmDfSolSKwnQhhYbbSmNe/AOtnyNHY OKpeNWoWC/rB4GBsqIUeL6hujtZ9 X-Google-Smtp-Source: AAOMgpcP1lpR4YD8x1JxuadI3r0lZuR7OqmPjY9MCBQxu6P889IeeM9QbnZu/UmZcU9T32Z9wioLdg== X-Received: by 2002:a62:4b48:: with SMTP id y69-v6mr11596293pfa.93.1530481430901; Sun, 01 Jul 2018 14:43:50 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:05 +0530 Message-Id: <1530349239-22049-2-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:43:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 01 Jul 2018 21:43:51 +0000 (UTC) for IP:'74.125.83.66' DOMAIN:'mail-pg0-f66.google.com' HELO:'mail-pg0-f66.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.66 mail-pg0-f66.google.com 74.125.83.66 mail-pg0-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 01/35] util: alloc: 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.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 01 Jul 2018 21:44: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 introduced which help in adding GNU C's cleanup attribute to variable declarations. Variables declared with these macros will have their allocated memory freed automatically when they go out of scope. Signed-off-by: Sukrit Bhatnagar --- src/util/viralloc.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 69d0f90..5c1d0d5 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -596,4 +596,48 @@ void virAllocTestInit(void); int virAllocTestCount(void); void virAllocTestOOM(int n, int m); void virAllocTestHook(void (*func)(int, void*), void *data); + +# define VIR_AUTOPTR_TYPE_NAME(type) type##AutoPtr +# define VIR_AUTOPTR_FUNC_NAME(type) type##AutoPtrFree + +/** + * 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) \ + typedef type *VIR_AUTOPTR_TYPE_NAME(type); \ + static inline void VIR_AUTOPTR_FUNC_NAME(type)(type **_ptr) \ + { \ + if (*_ptr) \ + (func)(*_ptr); \ + *_ptr =3D NULL; \ + } \ + +/** + * 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)))) VIR_AUTOPTR_TYPE= _NAME(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 Sun May 12 10:15:23 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 153048147354029.54409103420562; Sun, 1 Jul 2018 14:44:33 -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 DC9D2308A94D; Sun, 1 Jul 2018 21:44:31 +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 3FF2E30C43A4; Sun, 1 Jul 2018 21:44: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 E96FD4A469; Sun, 1 Jul 2018 21:44:30 +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 w61Li4qn008998 for ; Sun, 1 Jul 2018 17:44:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id AA19C6016F; Sun, 1 Jul 2018 21:44:04 +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 A247C600C9 for ; Sun, 1 Jul 2018 21:44:04 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.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 AD65783F3C for ; Sun, 1 Jul 2018 21:43:53 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id q14-v6so6195564pgt.13 for ; Sun, 01 Jul 2018 14:43:53 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.43.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:43: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=1ij7vJIt8phIjOBicEqy2kqlnUGJT4Q/glKOQvdhSs0=; b=Cf2Qu33mKu4dOmWymfWqefatJ9cvYxK3UvoqyutPunXcvJcDyy9/oEZi4CU0cC8ddJ QQBx/4ZZI4GiFio1FzHfQAtQi6zkx+MyzvXiaOnlESxlbYwBprxojDvOhlvLaoRcZA1A EnPRUYITSmLntqEvWON5CXjeyQT3gNvlYLLoU2w6OAgGCXTIS0QzaBTWpC/MtGnevYTO 08w4OAkmzgtCSpC4tWb67Uip/p4rt9ekMhFpxQM4mXqhh+XNIUoMoA9Q2wPmX3ssg1I4 0Buda797jCEvz7KBxhJUufVwARANMDvv3LZQlfMC3rWxCra+dlFicwq4NqFE8mq0W2Bz VJIQ== 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=1ij7vJIt8phIjOBicEqy2kqlnUGJT4Q/glKOQvdhSs0=; b=dG6WorQAOHiU1o229/tdrknOEWqosf5t7qWornvINiEuK9b4VTnzEBHXnf/4KC5Al6 L3NI3sYxDqF3XeZO7fr8t911Mq6S7R3nb9oBTccrpR59EY8oym/mT3jL3/6KpTf+k5Rh UKdsHNEmVa12LVzdV3tUhYk/8+XnTZpZmpdmNHKXyA63hNSBRrxii3nm63O6fNj+iFoN eDDUP4hXMF8fdpzOV2NDKlXq0dNYArELv8EnL8C/WPsQZeFHBIjXu2GD0EEFEk25MSGG 6ZMNao/9EFndBP+XZiuHLXBOsdc5akubGzPjxVDO2aylbP/FWgegvS4QiSk88HaAB4lM Mrdg== X-Gm-Message-State: APt69E3yKKCHk+QX56yDfxLD6ZbR0fXFMnzYs/GwoUSRpuhEfFxm3l3/ EN7NviPD9emamajUUlc8qjQtIwzM X-Google-Smtp-Source: AAOMgpeSj0gksk+MwbM4R31AbLrLnuy8SJNm/PHQMNwA0onpgYKWEgTZV81xLASa54uekoYzj8AEnw== X-Received: by 2002:a62:1f8c:: with SMTP id l12-v6mr14238506pfj.143.1530481432980; Sun, 01 Jul 2018 14:43:52 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:06 +0530 Message-Id: <1530349239-22049-3-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:43:53 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 01 Jul 2018 21:43:53 +0000 (UTC) for IP:'74.125.83.66' DOMAIN:'mail-pg0-f66.google.com' HELO:'mail-pg0-f66.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.66 mail-pg0-f66.google.com 74.125.83.66 mail-pg0-f66.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 02/35] cfg.mk: variable initialization when declared with cleanup macro 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.41]); Sun, 01 Jul 2018 21:44: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" A variable, which is never assigned a value in the function, might get passed into the cleanup function which may or may not raise any errors. To maintain the correct usage, the variable must be initialized, either with a value or with NULL. This syntax-check rule takes care of that. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- cfg.mk | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cfg.mk b/cfg.mk index 6bebd0a..196d1b2 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1057,6 +1057,17 @@ sc_prohibit_backslash_alignment: halt=3D'Do not attempt to right-align backslashes' \ $(_sc_search_regexp) =20 +# Some syntax rules pertaining to the usage of cleanup macros +# implementing GNU C's cleanup attribute + +# Rule to ensure that varibales declared using a cleanup macro are +# always initialized. +sc_require_attribute_cleanup_initialization: + @prohibit=3D'VIR_AUTO(FREE|PTR)\(.+\) [^=3D]+;' \ + in_vc_files=3D'\.[chx]$$' \ + halt=3D'variable declared with a cleanup macro must be initialized' \ + $(_sc_search_regexp) + # We don't use this feature of maint.mk. prev_version_file =3D /dev/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 Sun May 12 10:15:23 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 1530481452854669.1077206935004; Sun, 1 Jul 2018 14:44:12 -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 E92C381105; Sun, 1 Jul 2018 21:44:10 +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 93A2E600C9; Sun, 1 Jul 2018 21:44:10 +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 4E8B818037EC; Sun, 1 Jul 2018 21:44:09 +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 w61Li6pu009009 for ; Sun, 1 Jul 2018 17:44:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDEA25C6C1; Sun, 1 Jul 2018 21:44:06 +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 E56515C545 for ; Sun, 1 Jul 2018 21:44:06 +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 D813185546 for ; Sun, 1 Jul 2018 21:43:55 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id u16-v6so6534408pfh.3 for ; Sun, 01 Jul 2018 14:43:55 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.43.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=+bGnPugs5Umedbsr2UGRntkvXutsGVXUVwSKuFbZQAI=; b=pUAEH9MWDIIg3DZfplgR6AvLFHs411KzPsDs00POWW2tAFKJuEdk1FjaMuzSJRnVaA sRUEC+VSmL2+cAxfnx8WyVOyw4qzSWy8Q4FX2i/ucaOLYCZjVlHsDk3Ws3qaczgpN+pb OQwO9BBinMqnSzitF1NrWls0TX0fMgF7bLpGsoB+qbbYpSRGQFwFOmsrTG6gKgfAZT/9 C2Sp1cOqKoCeXiVyaIoY9aEjz9zB/nzGpKSOrqyJN+8Uoin9GzC8akjYGB1tGVqUoA67 MeE6IVxfbT8tzys1LVizpgo4usWM8jjLGyBokYCv4xxVE+2kUSNndpoY88gVcSCuMJzR Duzg== 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=+bGnPugs5Umedbsr2UGRntkvXutsGVXUVwSKuFbZQAI=; b=NDtxuPiHTourSGqTAHYgLYN925MGlifWE7cdobR68FTqOq0NEIoNd4UKU5xKMGGUnB 3OzysbyYo55YdAKmQmOJ7t1jlcOfGhoS4AwoduSt1pANlLiSgAyEhqrvH1mfpnJd8/Sm x5ya3/rYIFyFkad43voc5+dEO/+u9yh0RSWLf2aL3nsdAvcUzBrfjRggt5Vj0jpshvuD v4oTrliv+v6ZdVBvVqO79oP7dOTKLLoNhPN/dmjEZdvJuG6URqTJrmPI2VdTMBGuKSmL XRDNHnhcjuOXuRvwF0wZml7tpcgB1DbdTYI7JALJuHb4AVJEQPZZevFarJPmvglztaqy QsxQ== X-Gm-Message-State: APt69E1EWxVvrK8rdM+85RPSTNUOvagwZC/tvexrW8fUO6qq1SAHw7wx IuFFf895jvaQ3tuJUrP3cAVLhoyZ X-Google-Smtp-Source: AAOMgpdRIKiJ3cbV5LjTps76lCcG3zy1Rd2zuO8zkdQ9uo/GFDrLpNjq1yjxtxYXdKLS3TY06zSUZQ== X-Received: by 2002:a62:db05:: with SMTP id f5-v6mr22548389pfg.123.1530481435105; Sun, 01 Jul 2018 14:43:55 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:07 +0530 Message-Id: <1530349239-22049-4-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:43:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 01 Jul 2018 21:43:55 +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: 1.785 * (DATE_IN_PAST_24_48, 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.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 03/35] cfg.mk: correct spacing between type and asterisk in VIR_AUTOFREE 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.28]); Sun, 01 Jul 2018 21:44: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" Add rule to ensure that there is exactly one blank space between the type name and the asterisk when passed as the argument to the VIR_AUTOFREE macro. Signed-off-by: Sukrit Bhatnagar --- cfg.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cfg.mk b/cfg.mk index 196d1b2..d9e90d5 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1068,6 +1068,15 @@ sc_require_attribute_cleanup_initialization: halt=3D'variable declared with a cleanup macro must be initialized' \ $(_sc_search_regexp) =20 +# Rule to ensure that there is exactly one blank space between the +# type name and the asterisk charcater when passed as the argument +# to VIR_AUTOFREE. +sc_require_attribute_cleanup_scalar_type_space: + @prohibit=3D'VIR_AUTOFREE\([^ ]+(| {2,})\*\) .*;' \ + in_vc_files=3D'\.[chx]$$' \ + halt=3D'there must be exactly one space between the type and asterisk = inside VIR_AUTOFREE' \ + $(_sc_search_regexp) + # We don't use this feature of maint.mk. prev_version_file =3D /dev/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 Sun May 12 10:15:23 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 1530481477564946.1236841058293; Sun, 1 Jul 2018 14:44:37 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8904C30E684A; Sun, 1 Jul 2018 21:44:36 +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 23573608F8; Sun, 1 Jul 2018 21:44:36 +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 C431218037EF; Sun, 1 Jul 2018 21:44:35 +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 w61LiB5h009028 for ; Sun, 1 Jul 2018 17:44:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 26571308BDA7; Sun, 1 Jul 2018 21:44:11 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D38C308BDA5 for ; Sun, 1 Jul 2018 21:44:09 +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 9C47D307D859 for ; Sun, 1 Jul 2018 21:43:58 +0000 (UTC) Received: by mail-pl0-f66.google.com with SMTP id a7-v6so6945105plp.3 for ; Sun, 01 Jul 2018 14:43:58 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.43.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:43: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=h0B4SaqcKCjQRkjJk8AwMlcczmxsIUPkKOUun2hwUow=; b=fehunzpLMTrbp9uLXOApwj24qoEsJqQ7ok9SObiUddw2mSS33XtG15BNu7HDeHJlB0 9NP3bsnlhxslVbkSBN/FEbdgXE5NxQovRpRVfRfcyK9gnwML3eSUNTj8InleHj9cFGBI zg2dGTIIAYL7j0WwQ+8Lz1R8ydv4sDWnxsOwnFvG/teY4bQakn+TSHMc2TZBLCHcr1ta eorfnSz8Wcf68ZHv+mXfTMBJtDZwD5nB/F5RnCGyEZmFIZwqhOGM0Y11nPyTXqO1LMGW ExRZXPvZYrW5BeLItv94UKhwNySqsxTFu0MYdf2+wFh4LFaMKDbwhTCHuCWcl7sfhOXT /6kw== 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=h0B4SaqcKCjQRkjJk8AwMlcczmxsIUPkKOUun2hwUow=; b=qC5L44fbL8IAHki4zQOkoyVgFYuZclKMg3xfDH32zSfdg1flB6AqIT32C2jN80RZug kKt1fTmkCV8VLhlmaVCkTzTz7XtinxeyN/Kep7DmYwXxtuDJIXGzbPuCifg0yzORTUJV FPKZpWG2P9hDF7ksNZxJjkAD/BcaJk0Ku40PvJ67yRQ+Dgnwj0R2OAXLcdqO43plALxx Mwila/TJNMY9ySP3KoOID0LEUlNqmvXkaZcrT7NP9RqFRb6yRQ0lumtpJiuqoScvEiSx RsYqN3Q+EsRltyBxQmw3N4+ceWPnxxyAVBwJjO2bUY/hikTHJ6cHWPPLYBqxJJKEKfIZ RbzQ== X-Gm-Message-State: APt69E1fWChLlhikN1KPMUC618+0Yx68/tAu3hqfFbGmwYKDJEnvcqL/ 3i0iNhU7CF4CgzdGGHSWKBLuszON X-Google-Smtp-Source: AAOMgpdEBWzqSDum0PlP+4ArvGSAWsggEGRu0j3YQ82eNyyLCQfgqmIH1rdv7cJhnB8OIm9CvJLmlw== X-Received: by 2002:a17:902:7888:: with SMTP id q8-v6mr18250110pll.79.1530481437935; Sun, 01 Jul 2018 14:43:57 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:08 +0530 Message-Id: <1530349239-22049-5-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.48]); Sun, 01 Jul 2018 21:43:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 01 Jul 2018 21:43:58 +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.766 * (DATE_IN_PAST_24_48, 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.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 04/35] cfg.mk: single variable declaration per line when using cleanup macro 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.46]); Sun, 01 Jul 2018 21:44:37 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add rule to ensure that each variable declaration made using a cleanup macro is in its own separate line. Sometimes a variable might be initialized from a value returned by a macro or a function, which may take on more than one parameter, thereby introducing a comma, which might be mistaken for multiple declarations in a line. This rule takes care of that too. Signed-off-by: Sukrit Bhatnagar --- cfg.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cfg.mk b/cfg.mk index d9e90d5..7949fc8 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1077,6 +1077,14 @@ sc_require_attribute_cleanup_scalar_type_space: halt=3D'there must be exactly one space between the type and asterisk = inside VIR_AUTOFREE' \ $(_sc_search_regexp) =20 +# Rule to ensure that there is only one variable declaration in +# a line when the variable is declared using a cleanup macro. +sc_require_attribute_cleanup_one_per_line: + @prohibit=3D'VIR_AUTO(FREE|PTR)\(.+\) ([^\(]*(, .*)+|[^\(]*\(.*\)(, .*)+)= ;' \ + in_vc_files=3D'\.[chx]$$' \ + halt=3D'there must be only one variable declaration per line when usin= g cleanup macro' \ + $(_sc_search_regexp) + # We don't use this feature of maint.mk. prev_version_file =3D /dev/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 Sun May 12 10:15:23 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 1530481472844322.5475270548004; Sun, 1 Jul 2018 14:44:32 -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 835634E028; Sun, 1 Jul 2018 21:44: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 491769495C; Sun, 1 Jul 2018 21:44: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 ED2C118037F1; Sun, 1 Jul 2018 21:44:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LiDZn009038 for ; Sun, 1 Jul 2018 17:44:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3F6A530C43AE; Sun, 1 Jul 2018 21:44:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3826030C43B0 for ; Sun, 1 Jul 2018 21:44:11 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.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 B85503082A36 for ; Sun, 1 Jul 2018 21:44:00 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id y15-v6so5072183pll.9 for ; Sun, 01 Jul 2018 14:44:00 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.43.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:43:59 -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=odpFJM723TKvOapMlzItA1zQwXCPm70WhWYPrhxGT+Q=; b=p0kkWycZnCT2txmFMA5aqhaRy0tz4kSDNqGoYHqHdJDOgAH4pOZmki8w7WBZfmyWNL A3HT+TEnN/VmYgU6yHrTgf+0gqrVChvasVG+KJ9k2TctqTIkx8GbMm3zNeRZ348+DFsG ORt2t3srejcpAGZME45LCgfzdlYv/vZrcERU8Tonzr8ot2vG6v6wzSUdjZsWAIrfs+5U g/ZIoXnAgP777nFc9G56TYJKP6UBVWvkoLZIM+sAp30D6ZfeJzJiLkrzIkBSqJNWur5G E69Gq9hXBw1RnO3XLX2d4CtE6mW705ssY9uwzVZcIp/0Wjp2t3bW5Y4T5lxA4WLO3hJT 8UEw== 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=odpFJM723TKvOapMlzItA1zQwXCPm70WhWYPrhxGT+Q=; b=YjNfiDSMXo2rT4cFOR1QJDWbExoEiE7Y62+3sSfd58ITMC2huS0KYWSPH8FshN+4pD 7fmq1zaNu3WpUfL5pvUkPdq96MZKCxIC4Io9t78Z1AfJGOxtN9s92CwGbqz9b/C2g7g2 05v1r81A/a9xfcdDIUSdDYhl6HYPBMP9pfZUky5ZCBJQofvFjaGWa5yOi53bI5xFvS8T LZfiPEQE2bd20y+aciMPLqievul4+l3sihSZktIFp/OW+z6+1gO6Q1LrJk5Ywj1jQbJP I9RRM7kef2zKP/RGwZDf5fOoJfOM7sF5gWBNpsPaVnKqtMyUi1gTK/iLiCX0xP133cfh xtzg== X-Gm-Message-State: APt69E2WDafsQA9iCfwIfGyS5odlOR+yyPEIQVNJXEYg+oVVxox0XBP3 Njvrsz/B22RBx+mNxrbDkgFuSP0k X-Google-Smtp-Source: ADUXVKK26N1UiJTM1aqwMNvDg/3hhfuDudC7+JBP8DuKYoXYUou7vbk/Sp/qiBkGV8Q5x/TMHBLEjw== X-Received: by 2002:a17:902:22:: with SMTP id 31-v6mr23655369pla.332.1530481439968; Sun, 01 Jul 2018 14:43:59 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:09 +0530 Message-Id: <1530349239-22049-6-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.45]); Sun, 01 Jul 2018 21:44:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sun, 01 Jul 2018 21:44:00 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 05/35] cfg.mk: no trailing semicolon at line invoking VIR_DEFINE_* cleanup macro 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.38]); Sun, 01 Jul 2018 21:44: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" Add rule to ensure that there is no semicolon at the end of the line where a VIR_DEFINE_* cleanup macro is invoked. Signed-off-by: Sukrit Bhatnagar --- cfg.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cfg.mk b/cfg.mk index 7949fc8..d292005 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1085,6 +1085,15 @@ sc_require_attribute_cleanup_one_per_line: halt=3D'there must be only one variable declaration per line when usin= g cleanup macro' \ $(_sc_search_regexp) =20 +# Rule to ensure that there is no trailing semicolon at the line on +# which a cleanup funciton is defined using a VIR_DEFINE_* macro. +sc_require_attribute_cleanup_no_semicolon: + @prohibit=3D'VIR_DEFINE_AUTOPTR_FUNC\(.+\)\s*;' \ + in_vc_files=3D'\.[chx]$$' \ + halt=3D'cleanup macro defining a function must not end with a semicolo= n' \ + $(_sc_search_regexp) + + # We don't use this feature of maint.mk. prev_version_file =3D /dev/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 Sun May 12 10:15:23 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 1530481473103737.3777083208375; Sun, 1 Jul 2018 14:44:33 -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 BBD2B30820CD; Sun, 1 Jul 2018 21:44: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 7DEFE60851; Sun, 1 Jul 2018 21:44: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 1C72718037F2; Sun, 1 Jul 2018 21:44:31 +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 w61LiI0h009050 for ; Sun, 1 Jul 2018 17:44:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 775AC60BE5; Sun, 1 Jul 2018 21:44:18 +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 6F70960BE3 for ; Sun, 1 Jul 2018 21:44:15 +0000 (UTC) Received: from mail-pl0-f44.google.com (mail-pl0-f44.google.com [209.85.160.44]) (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 BBD403086241 for ; Sun, 1 Jul 2018 21:44:04 +0000 (UTC) Received: by mail-pl0-f44.google.com with SMTP id bi1-v6so6941606plb.12 for ; Sun, 01 Jul 2018 14:44:04 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:03 -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=SUEPWIIm0My1eSn7P8Of+7oQ8M95NkJBk8e1SZVoDho=; b=dzIXHFaaknSMVhA0Z0oH0ca11AaGHqym+psScK/wiwkhBk/bLefB3QojOKDw56HNwl S1Ed+FKSox0ygUUbir54aHF2tcRSVCNZQOzDEDXY5DioQ3jqLAAOoWIa22kM2QkAN+dk 7PO9jWjoNS6tXl1V0KTlatRHs9Mpl415L8/yyzHeRrg9grrxNnqgSAZj85adIA5Gvu35 PTOCU5e6JoFP4q/3AU80MJO8DzjVoaS09ej1++uRAPVqjbuIr8Do/+fs1iOl+ZyE04cY NuG4TXeQQl4uNa0uUa2AfsB+CYM4qIZhvXMDqtmmvRz91S0G/YDV/CqA9lWMhjmSff03 K++g== 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=SUEPWIIm0My1eSn7P8Of+7oQ8M95NkJBk8e1SZVoDho=; b=bKTcOcoTTYssto64rN10Jfmwtu6tm37uGUZY7KjpG2V1a6Z8EzWJ9dFF25NavfOQ69 bbeaWpDY5sfg+7+2dgSOeXPmeY54u7VNqx/A9FrOzXxUr6whOjxskvfZI0nUGvZJkCqz rFRSVBKf8VdxwuivdzZGwXwsiVy12Gk/3dIN6EiY1HBUSbPCvfTfdGE2aF0lDGKKM6ZH S5YWyRBIf18Su3N67wMYF2CusGdmpsHRObGj+OH3CfyVruHktx7pK0RiyKZZ1I3LeEfr kxzBjXOQKXolwQdXwQH+YMzNRN5DIqeOeFCtUy9wbPJ/hMTKRr3UHL+39jk8ETFKYu7T TkKw== X-Gm-Message-State: APt69E2NH9A/CVaZbj3thjtkF9brXcRd//S3rR7WjaPjWO8AY2jIUpyX RR09vYC5l7sFnkEclx9nZYW5i4cN X-Google-Smtp-Source: ADUXVKLe/qWmMoRTyCD8Vn1jvm/MStlZ8KS485q1OtbQcbLwbguxjdk9alo2SanojNamDaejDDq4xQ== X-Received: by 2002:a17:902:bccc:: with SMTP id o12-v6mr23304411pls.169.1530481444061; Sun, 01 Jul 2018 14:44:04 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:10 +0530 Message-Id: <1530349239-22049-7-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:04 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 01 Jul 2018 21:44:04 +0000 (UTC) for IP:'209.85.160.44' DOMAIN:'mail-pl0-f44.google.com' HELO:'mail-pl0-f44.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.44 mail-pl0-f44.google.com 209.85.160.44 mail-pl0-f44.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 06/35] util: string: introduce typedef for string 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.47]); Sun, 01 Jul 2018 21:44: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" Alias virString to (char *) so that the new cleanup macros can be used for a list of strings (char **). Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virstring.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/virstring.h b/src/util/virstring.h index 607ae66..ac930fd 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -26,6 +26,8 @@ =20 # include "internal.h" =20 +typedef char *virString; + char **virStringSplitCount(const char *string, const char *delim, size_t max_tokens, --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481486166995.0598965443133; Sun, 1 Jul 2018 14:44:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCEFF356CA; Sun, 1 Jul 2018 21:44:44 +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 A4F855DD72; Sun, 1 Jul 2018 21:44:44 +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 578733FA54; Sun, 1 Jul 2018 21:44:44 +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 w61LiLBx009060 for ; Sun, 1 Jul 2018 17:44:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F13960177; Sun, 1 Jul 2018 21:44:21 +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 2759A60175 for ; Sun, 1 Jul 2018 21:44:18 +0000 (UTC) Received: from mail-pf0-f181.google.com (mail-pf0-f181.google.com [209.85.192.181]) (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 A37523695F for ; Sun, 1 Jul 2018 21:44:07 +0000 (UTC) Received: by mail-pf0-f181.google.com with SMTP id v9-v6so5401802pff.9 for ; Sun, 01 Jul 2018 14:44:07 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:06 -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=RUWpILjk2geXenu2wmZYP56qH8ah8eKVmQbibOwTK2o=; b=jpDfwEMtsMw/LJXwmsxmcXpzfhgiUchTwH7iaPk0K5lWi2kmt8vdZZSDury8qpdqNd f5I5WRf7Zh3i6oCLPJZ3VND2lJG5/7DecDJeGOX6qIFJsXtHRcPg+skoj33tX6vP7J7q pYIFo9OWBZ0VW5ly6c3jp+d/WDKJKwi71Iw8DiOG+h5cclSxh/drviPZfbB2WuOVTSaU 1gGL0rxpxvqio5WXDScIArHIRWsfFB9pmG0/IhAaEr2cXfQd7b73Y3r4GsafFipWw2O+ U3nrRXYzkty6CXuDLJeLqXKLIyOwtAqr8cnJ66B2jGhUo6R6mrNDL3OfBAFk4CySeZP+ 5Wpg== 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=RUWpILjk2geXenu2wmZYP56qH8ah8eKVmQbibOwTK2o=; b=odIUp7exC+AC0kmpqskXH4X18u7EKfFO8clvGSYa55LTucCm8hCYJTgTVhoTThAL0E bjp8pG3jilVjkuG39VGI8SznR2e+X45G87bjj4lmmpq4nYl2rzPqnUihZPwnHA5n4WNY /DmvA8qqXTkB7i3+fV5JBvhKRXSNrfbDktJeMwxIClojg2utsfC26/xcZj8kgbRoGR0l EUAciX2THN/+OZmd8RG0zvDiYePp2xVYW+IQHGAfoINLT+8Ba5MbjhFC54No4BarWhJ7 PZBr/UiYTnOP6OjY3GxIA3LDezQsnYhCclqFvOBFtWbHe/W19edHzNLLDG80wXwYZ9/T NMmA== X-Gm-Message-State: APt69E0v4SewowET1KTbrLwkA3GazzS/Laor8w2Nw0umX2QPY68rld8L C4BugLqdhyLVJjU/T7QhVlZNUabs X-Google-Smtp-Source: ADUXVKLQUwOR24iOmjsYW19kFOTDej7MhmQy4xyrSMP2IsiS87QSoclIVjAfRHmvo4lUkJSw75NhRw== X-Received: by 2002:a63:951e:: with SMTP id p30-v6mr19525044pgd.318.1530481446896; Sun, 01 Jul 2018 14:44:06 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:11 +0530 Message-Id: <1530349239-22049-8-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 01 Jul 2018 21:44:07 +0000 (UTC) for IP:'209.85.192.181' DOMAIN:'mail-pf0-f181.google.com' HELO:'mail-pf0-f181.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.181 mail-pf0-f181.google.com 209.85.192.181 mail-pf0-f181.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 07/35] util: string: 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 01 Jul 2018 21:44:45 +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 new 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. When a list of strings (virString *) is declared using VIR_AUTOPTR, the function virStringListFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virstring.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virstring.h b/src/util/virstring.h index ac930fd..726e02b 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -25,6 +25,7 @@ # include =20 # include "internal.h" +# include "viralloc.h" =20 typedef char *virString; =20 @@ -311,4 +312,6 @@ int virStringParsePort(const char *str, unsigned int *port) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 +VIR_DEFINE_AUTOPTR_FUNC(virString, virStringListFree) + #endif /* __VIR_STRING_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481477898481.0672068308638; Sun, 1 Jul 2018 14:44:37 -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 CCE11C050DF5; Sun, 1 Jul 2018 21:44:36 +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 A058030C43AF; Sun, 1 Jul 2018 21:44:36 +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 5A9634A46D; Sun, 1 Jul 2018 21:44:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LiOIu009074 for ; Sun, 1 Jul 2018 17:44:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90E75608F8; Sun, 1 Jul 2018 21:44:24 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8760F608F6 for ; Sun, 1 Jul 2018 21:44:21 +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 89079308A94B for ; Sun, 1 Jul 2018 21:44:10 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id u16-v6so6534534pfh.3 for ; Sun, 01 Jul 2018 14:44:10 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44: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=hAnULWAoJNW5o/nXn95SPAEiZecXvvsUF6eR4TroI2g=; b=e0rTBcusaQ11BK3GIn8UPMsOSBFZzLFgW5OiL2uenpV0IKhZSOZ8QSqNimT67XLCKF NJ7qf+m/NKI073AEDR89DjbBV4TcCc2SdI3datJM4JGlgiDAcMx6ZOaOMgFyWfglY3ZG 73/CQcjJRX/J1k/iiE2PC4r6PikHRQLhA84q6a6wXmn60u1JtUPEMVEziTxaicJqvFwx 0pxEOOjva9w06abdb+gigcKeggD5mIfy5tGdhMfr1UaPZ9i0UB2X8CveQ02OZmssNgfJ qwfAgpHuWoW/9V22bXSoBMO7QchXwC2n0Crq7fx7vsD96VZQZIc0H1/AsSI+MESpPE7p P30g== 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=hAnULWAoJNW5o/nXn95SPAEiZecXvvsUF6eR4TroI2g=; b=Pd3iIKAhO5vKp992Y0SlSdzfhZ1AgQXw1iLKMJ4XGScq5IXLfavpR/Py1Goip9vjJm LGSE3OaNV7rio9p2j4IoTBOlLLHYDpCWqzkZPkwpF8DQr29qzePnVFVlkF0dQva3RzNA UrL73lr52Vn193JR4+pjlCPIuO3oqDPo/E3xW/6sP5ofabNyS/c1WolnD1nK6px4c4ca hRJJzDHpRws5IcG/Pbw2+mbY0lroo5RCkF0UEoJ5SDvzw6ckM9VJVZe1qFbvK4nM0w+g XBqiqyBMRw6bDKATPPRtc57axQKfM6qr1KAUDRIYq3f4bWiWjp8O9itcgMi89psqzknl y/8w== X-Gm-Message-State: APt69E1ZCKCDv7Ai5HRIEvhRnzgji1V7E4CogQAduk3S0gsYhXwSgUXy zmBBAn2Qt+exL316x5MyMw9z7oJG X-Google-Smtp-Source: ADUXVKKjVluPF+2/eYvK0tzdWbxHaKWQ1395RIO3jvI4+FGae0dpMr3cGEn7ut8GW05lKdEDUc6H8w== X-Received: by 2002:a65:64cf:: with SMTP id t15-v6mr19471935pgv.79.1530481449777; Sun, 01 Jul 2018 14:44:09 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:12 +0530 Message-Id: <1530349239-22049-9-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.41]); Sun, 01 Jul 2018 21:44:10 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 01 Jul 2018 21:44:10 +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: 1.785 * (DATE_IN_PAST_24_48, 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.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 08/35] util: command: 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 01 Jul 2018 21:44:37 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Using the new 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. When a variable of type virCommandPtr is declared using VIR_AUTOPTR, the function virCommandFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/vircommand.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 883e212..90bcc6c 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -24,6 +24,7 @@ =20 # include "internal.h" # include "virbuffer.h" +# include "viralloc.h" =20 typedef struct _virCommand virCommand; typedef virCommand *virCommandPtr; @@ -218,5 +219,6 @@ int virCommandRunNul(virCommandPtr cmd, virCommandRunNulFunc func, void *data); =20 +VIR_DEFINE_AUTOPTR_FUNC(virCommand, virCommandFree) =20 #endif /* __VIR_COMMAND_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481477792848.0446871956451; Sun, 1 Jul 2018 14:44:37 -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 9C694308A955; Sun, 1 Jul 2018 21:44:36 +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 6A3EC30C43A4; Sun, 1 Jul 2018 21:44:36 +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 2078B4A46C; Sun, 1 Jul 2018 21:44:36 +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 w61LiSGB009093 for ; Sun, 1 Jul 2018 17:44:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 33E3B6C537; Sun, 1 Jul 2018 21:44:28 +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 2CAB76C52B for ; Sun, 1 Jul 2018 21:44:25 +0000 (UTC) Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) (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 4F52487622 for ; Sun, 1 Jul 2018 21:44:14 +0000 (UTC) Received: by mail-pf0-f176.google.com with SMTP id v9-v6so5401849pff.9 for ; Sun, 01 Jul 2018 14:44:14 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:13 -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=U63D+/D1GZaFKvrAgB26q6VCvjtq0ru/P4wuIBorrP8=; b=Op4i/nkJBZ3Iw0vx/RXT9flXmeByPr9oCO7EUc0cTjLvv8wvqYUqJMuGY861rTBTpl BsFp4XGZ/Kd1fPcg4zHFjKil2b8+XxqY/cbZ7bD1CEFEcQNoQ7LSQayIyb8u1aLNvzq5 6Gg7c/Aj9rq62g6MIIh4aZQsE3Fr6MYsBCKNF4ev3GrP8C1TncxMjUtGOnI8Ooclj3k4 ppRsbGbpESQ2As4cJ4CGtlItUeEDnzvEI1uhXVMHdnTf4R6P8beGMya2DNhVms5E2j/V fzegq+urlCv88Nh9Y60ciq/GT2b+33pm8dSwkX6mrQNmyukUzxC5jwSyckwbv659XHNH kfrg== 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=U63D+/D1GZaFKvrAgB26q6VCvjtq0ru/P4wuIBorrP8=; b=lTMZET+e4w0tNw1x6ydLWAgJuxpK66/QvvkgZXidSjyqA85rtLCnknecEn2lQP4uUm uu67fym+UpsW5N6hprlaQDNQxkrN1v/2rQUGGqBcyKSCv5KjkcFaxad72Ew3s+h5tvnc Fip1cHz04/k+vYEgnbC4wnFq/ZE/cAzlZTh/uvbL2vfPvh3kMk4a867yB7Ya/yk/fm5o kWZAncZMvqJyamzxe1IWDJsIaE7pPgPElzKtiowM61yVHssre+ZRQOzzZyNa50QiT2vj MsGvrzye8rcVYmjSJLFjy8Ukmi0XNXnbLI3y7VIthAGK01+hVeeVv9dCLpOWvMjEU0rC HAlQ== X-Gm-Message-State: APt69E20B/Qmk8gqf6aQ/Le2tQMfprXttKgXKcQyFcrPdQwZxA6cbsSy LK4lO6neDyWGj4Bm5rcBT1lDw+cY X-Google-Smtp-Source: ADUXVKKwgivLaxkn6QCdmu9zUcI9L297TufxGcD1KPaE8RLJZXlidD/vVsMMCoeDPM0ntdV9sqRT2Q== X-Received: by 2002:a65:4ec3:: with SMTP id w3-v6mr19737322pgq.256.1530481453515; Sun, 01 Jul 2018 14:44:13 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:13 +0530 Message-Id: <1530349239-22049-10-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 01 Jul 2018 21:44:14 +0000 (UTC) for IP:'209.85.192.176' DOMAIN:'mail-pf0-f176.google.com' HELO:'mail-pf0-f176.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.176 mail-pf0-f176.google.com 209.85.192.176 mail-pf0-f176.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 09/35] util: command: 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 01 Jul 2018 21:44:37 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The include directive for viralloc.h is added in vircommand.h in a previous patch. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/vircommand.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 6dab105..8681e7b 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -44,7 +44,6 @@ =20 #define __VIR_COMMAND_PRIV_H_ALLOW__ #include "vircommandpriv.h" -#include "viralloc.h" #include "virerror.h" #include "virutil.h" #include "virlog.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481492004594.7522354911893; Sun, 1 Jul 2018 14:44:52 -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 040BCC0587E3; Sun, 1 Jul 2018 21:44:51 +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 B5185308BDA5; Sun, 1 Jul 2018 21:44: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 650534BB78; Sun, 1 Jul 2018 21:44:50 +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 w61LiSYk009098 for ; Sun, 1 Jul 2018 17:44:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id A820660BE3; Sun, 1 Jul 2018 21:44:28 +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 9D8F660BEC for ; Sun, 1 Jul 2018 21:44:28 +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 E9AF23680B for ; Sun, 1 Jul 2018 21:44:15 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id l123-v6so3475222pfl.13 for ; Sun, 01 Jul 2018 14:44:15 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44: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=lvRM8Dqj/U9Ss7FQFnHMF02vr/oSugsz8ASkCWcZ/+Q=; b=f7C1wwWGsGkRPdHdT14glWpYUfi38xqKZR/L7nFqTPafNGEQsr88L00dhOFOMX0qiG QAb2T+DePF+JY/DNwXBxbwWRMm/4E6I0WjMv2QS6nRgvmoCgcc6VXQdw381ya3RUsr9g uWJ/o1a/opvVg1o2Mpfz+ub+hNgCkIcVS7o6ibgRfuXIWmqyfHbXDyNWkJY29V0KVMGu 0LM/q+cTSi72nAvUE2zOcwU/9SFiYZimYdbxYxReEAhEU5HtIpCWRfbDEqynUhaz8mZS x/6gBsD87Vna1HpX8ysCb3ZRa/v4E3pE5DvVp36WDSGKqiJoSf0DOLAUAnNUJhZ5YASm kblQ== 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=lvRM8Dqj/U9Ss7FQFnHMF02vr/oSugsz8ASkCWcZ/+Q=; b=KT8mcatXfcD3h3xFUJy07nV16M+uDIM6a+MKxraT0Z8RL1Zb/9PZpJ49Bd0h4P+9Z6 xgxrRyTB+pszYOeAfeaIdH9yW+XT+0HtbIa3CB3xlkZBEq77N97bxcss1Xyz293ZaIRO QJwGW2whlUhpAycBPJ/JIQcoqpuJWDpVI2e6zYG1DWhis+WvKmQKmg4fqLZ1zdSNd7Mj gltIFCA7uhhGZz6oGRmDdLJZlyRBOc9mvqUDpix8kcHS1R4iRw3FtkvXJpBW3p79i83t hoYcrcqk2xieuKTN/2XZuWgA0YQ+bnQgZx5V5jq1OzrphUrG8lPTaXBSqwC3KEDjn6c1 qQjg== X-Gm-Message-State: APt69E05kxM779PgKFow15Ab1aI5xIjFYubogfvKm6aV0ytxoy8uSCHS G1LEKKZH4FDxPi0W2UUARhuYWMh/ X-Google-Smtp-Source: AAOMgpeab8Xdkr6+k32K5DVzAAOpnNB7G9zQJDJMjF1GS5QIW3IPHAPp2Qinj5sh8Z8AQ84f+QlpIA== X-Received: by 2002:a63:5c10:: with SMTP id q16-v6mr1038235pgb.452.1530481455214; Sun, 01 Jul 2018 14:44:15 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:14 +0530 Message-Id: <1530349239-22049-11-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 01 Jul 2018 21:44:16 +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: 1.785 * (DATE_IN_PAST_24_48, 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.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 10/35] util: command: 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.32]); Sun, 01 Jul 2018 21:44: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 GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/vircommand.c | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index 8681e7b..d328431 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -507,11 +507,11 @@ virExec(virCommandPtr cmd) int childout =3D -1; int childerr =3D -1; int tmpfd; - char *binarystr =3D NULL; + VIR_AUTOFREE(char *) binarystr =3D NULL; const char *binary =3D NULL; int ret; struct sigaction waxon, waxoff; - gid_t *groups =3D NULL; + VIR_AUTOFREE(gid_t *) groups =3D NULL; int ngroups; =20 if (cmd->args[0][0] !=3D '/') { @@ -604,9 +604,6 @@ virExec(virCommandPtr cmd) =20 cmd->pid =3D pid; =20 - VIR_FREE(groups); - VIR_FREE(binarystr); - return 0; } =20 @@ -796,9 +793,6 @@ virExec(virCommandPtr cmd) /* This is cleanup of parent process only - child should never jump here on error */ =20 - VIR_FREE(binarystr); - VIR_FREE(groups); - /* NB we don't virReportError() on any failures here because the code which jumped here already raised an error condition which we must not overwrite */ @@ -2386,7 +2380,7 @@ int virCommandRunAsync(virCommandPtr cmd, pid_t *pid) { int ret =3D -1; - char *str =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; size_t i; bool synchronous =3D false; int infd[2] =3D {-1, -1}; @@ -2511,7 +2505,6 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid) VIR_FORCE_CLOSE(cmd->infd); VIR_FORCE_CLOSE(cmd->inpipe); } - VIR_FREE(str); return ret; } =20 @@ -2588,8 +2581,8 @@ virCommandWait(virCommandPtr cmd, int *exitstatus) if (exitstatus && (cmd->rawStatus || WIFEXITED(status))) { *exitstatus =3D cmd->rawStatus ? status : WEXITSTATUS(status); } else if (status) { - char *str =3D virCommandToString(cmd); - char *st =3D virProcessTranslateStatus(status); + VIR_AUTOFREE(char *) str =3D virCommandToString(cmd); + VIR_AUTOFREE(char *) st =3D virProcessTranslateStatus(status); bool haveErrMsg =3D cmd->errbuf && *cmd->errbuf && (*cmd->errb= uf)[0]; =20 virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2597,8 +2590,6 @@ virCommandWait(virCommandPtr cmd, int *exitstatus) str ? str : cmd->args[0], NULLSTR(st), haveErrMsg ? ": " : "", haveErrMsg ? *cmd->errbuf : ""); - VIR_FREE(str); - VIR_FREE(st); return -1; } } @@ -2718,7 +2709,7 @@ int virCommandHandshakeWait(virCommandPtr cmd) return -1; } if (c !=3D '1') { - char *msg; + VIR_AUTOFREE(char *) msg =3D NULL; ssize_t len; if (VIR_ALLOC_N(msg, 1024) < 0) { VIR_FORCE_CLOSE(cmd->handshakeWait[0]); @@ -2731,7 +2722,6 @@ int virCommandHandshakeWait(virCommandPtr cmd) =20 if ((len =3D saferead(cmd->handshakeWait[0], msg, 1024)) < 0) { VIR_FORCE_CLOSE(cmd->handshakeWait[0]); - VIR_FREE(msg); virReportSystemError(errno, "%s", _("No error message from child failure")); return -1; @@ -2739,7 +2729,6 @@ int virCommandHandshakeWait(virCommandPtr cmd) VIR_FORCE_CLOSE(cmd->handshakeWait[0]); msg[len-1] =3D '\0'; virReportError(VIR_ERR_INTERNAL_ERROR, "%s", msg); - VIR_FREE(msg); return -1; } VIR_FORCE_CLOSE(cmd->handshakeWait[0]); @@ -2853,8 +2842,8 @@ virCommandFree(virCommandPtr cmd) * This requests asynchronous string IO on @cmd. It is useful in * combination with virCommandRunAsync(): * - * virCommandPtr cmd =3D virCommandNew*(...); - * char *buf =3D NULL; + * VIR_AUTOPTR(virCommand) cmd =3D virCommandNew*(...); + * VIR_AUTOFREE(char *) buf =3D NULL; * * ... * @@ -2862,21 +2851,18 @@ virCommandFree(virCommandPtr cmd) * virCommandDoAsyncIO(cmd); * * if (virCommandRunAsync(cmd, NULL) < 0) - * goto cleanup; + * return; * * ... * * if (virCommandWait(cmd, NULL) < 0) - * goto cleanup; + * return; * * // @buf now contains @cmd's stdout * VIR_DEBUG("STDOUT: %s", NULLSTR(buf)); * * ... * - * cleanup: - * VIR_FREE(buf); - * virCommandFree(cmd); * * The libvirt's event loop is used for handling stdios of @cmd. * Since current implementation uses strlen to determine length @@ -2969,11 +2955,11 @@ virCommandRunRegex(virCommandPtr cmd, { int err; regex_t *reg; - regmatch_t *vars =3D NULL; + VIR_AUTOFREE(regmatch_t *) vars =3D NULL; size_t i, j, k; int totgroups =3D 0, ngroup =3D 0, maxvars =3D 0; char **groups; - char *outbuf =3D NULL; + VIR_AUTOFREE(char *) outbuf =3D NULL; char **lines =3D NULL; int ret =3D -1; =20 @@ -3054,13 +3040,11 @@ virCommandRunRegex(virCommandPtr cmd, ret =3D 0; cleanup: virStringListFree(lines); - VIR_FREE(outbuf); if (groups) { for (j =3D 0; j < totgroups; j++) VIR_FREE(groups[j]); VIR_FREE(groups); } - VIR_FREE(vars); =20 for (i =3D 0; i < nregex; i++) regfree(®[i]); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481496631910.2247186380814; Sun, 1 Jul 2018 14:44:56 -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 A0DFB3082A40; Sun, 1 Jul 2018 21:44:55 +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 6FA2730C43B2; Sun, 1 Jul 2018 21:44:55 +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 22DAE3D3BE; Sun, 1 Jul 2018 21:44:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LiTV4009103 for ; Sun, 1 Jul 2018 17:44:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E265608F6; Sun, 1 Jul 2018 21:44:29 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04002608F8 for ; Sun, 1 Jul 2018 21:44:28 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.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 25B094E4C5 for ; Sun, 1 Jul 2018 21:44:18 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id t6-v6so6948473plo.7 for ; Sun, 01 Jul 2018 14:44:18 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:17 -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=tOY/lSEpCM4I6q908+WiXmkAdwpCKC8sP3NS/2fkyt0=; b=UH3A1NhsFrN1RvioSwpjwHKHa0QlQwar0II7avrYFmOXHELUbw6+8EPxIw+HJKWOU0 BIQWHpW5+AATZWyZGfOtb52/EC09Wv24HGVnjwlrRJJu7XHwBGD9x0xR/7qqT736zf2f 9YYyqTpl0XXD06y4wPTz1p0Y5Hc6K6i8ZKk9xrjVHyKxiMU/TgeSIfHGPj9LtRrGG0HN 7cF+8dI7AUHSmX3P8igPhjKqaz88CSLsf2qy53jWrkdiAUuPFQZmBOR0GCSP9ZYhTfEX UEVv3cpPx/mYFtOL2X4mVV5VcLHP/aQ3lTSnjLg0uLhk1qrsKwH2GVgOIlrydS0rXESl SD2A== 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=tOY/lSEpCM4I6q908+WiXmkAdwpCKC8sP3NS/2fkyt0=; b=uXzaRFDcrZIH86FN85sp09SzfAqr/kgsGnViw8thysviHRMjAi5QZpr8ftp9HPBrr3 n3+3BXuW+c5FkKLHOiGIMaJayiIL0YNU0pCIAaRPJSXYF+moraiFKEtkWaues8Pi+QqG Nz4Phm1PbGW1h1ydCuKeKEy8HjrIRGsQ7c5EbNeb/5P0+7w8Tvn0feWZC03weneJ+Bx+ P9P5tqrHhsJmXjIdsMylHtivZEjYURHSfCNFkqiQjoz5n5e6iDOSu9dtUvJ/gozwYVg3 7bQK5k8lvH5ps6zPU8Pl42sfmkXXDJi0OiPgVq6iUZR7ChcRQ/aMixpfCUZgPp5owXg6 eL/A== X-Gm-Message-State: APt69E2tH/xHPM3Vw2vgGsN7IBJIfHHbFjPoQ+mBhIS78iDlhcxl8CgT zb9mF1Mg14q216VS/nd9VnQTXQnj X-Google-Smtp-Source: ADUXVKIlLOI9QQdzWtkG2BvEf3pMvAcvL6c+BiMVwQf3WX83xas6eULQJoYdWTTwZUrdt4HoNR7tVA== X-Received: by 2002:a17:902:a9ca:: with SMTP id b10-v6mr23379825plr.275.1530481457456; Sun, 01 Jul 2018 14:44:17 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:15 +0530 Message-Id: <1530349239-22049-12-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.38]); Sun, 01 Jul 2018 21:44:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:44:18 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 11/35] util: command: 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.45]); Sun, 01 Jul 2018 21:44:56 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/vircommand.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/vircommand.c b/src/util/vircommand.c index d328431..6edb4d5 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -823,10 +823,9 @@ int virRun(const char *const*argv, int *status) { int ret; - virCommandPtr cmd =3D virCommandNewArgs(argv); + VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgs(argv); =20 ret =3D virCommandRun(cmd, status); - virCommandFree(cmd); return ret; } =20 @@ -2960,7 +2959,7 @@ virCommandRunRegex(virCommandPtr cmd, int totgroups =3D 0, ngroup =3D 0, maxvars =3D 0; char **groups; VIR_AUTOFREE(char *) outbuf =3D NULL; - char **lines =3D NULL; + VIR_AUTOPTR(virString) lines =3D NULL; int ret =3D -1; =20 /* Compile all regular expressions */ @@ -3039,7 +3038,6 @@ virCommandRunRegex(virCommandPtr cmd, =20 ret =3D 0; cleanup: - virStringListFree(lines); if (groups) { for (j =3D 0; j < totgroups; j++) VIR_FREE(groups[j]); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481501701485.99482133094614; Sun, 1 Jul 2018 14:45:01 -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 93CD83082132; Sun, 1 Jul 2018 21:45:00 +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 4CEEE5C541; Sun, 1 Jul 2018 21:45:00 +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 EFD8D18037F0; Sun, 1 Jul 2018 21:44:59 +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 w61LiX5X009123 for ; Sun, 1 Jul 2018 17:44:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8FCA20155E2; Sun, 1 Jul 2018 21:44:33 +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 BCAC820155E0 for ; Sun, 1 Jul 2018 21:44:31 +0000 (UTC) Received: from mail-pl0-f52.google.com (mail-pl0-f52.google.com [209.85.160.52]) (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 237F713AA5 for ; Sun, 1 Jul 2018 21:44:20 +0000 (UTC) Received: by mail-pl0-f52.google.com with SMTP id 6-v6so6953400plb.0 for ; Sun, 01 Jul 2018 14:44:20 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:18 -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=ngktednXz9q/csZrbr0IoRKhu8K8M3DmP78L/LpM26w=; b=dZjQLvWwKL75xd4Q27P8N7HmP9jKnWYSheHB03rM6v3B7K3sxhk7QoJlnwRgjomTts 8WXiIQPXhBWx7z3afHDa2LcQrOg5JHLy+tu2eiGGka+i++Ichq1wgcEaj4abl8j/Mql7 09FvdObAUB2WVj9QRkOQ92vsxLeM12VGn7FQp2pwMKmmiwSizGutcejE38Pr9V4qso53 SlAJGhPMENQEwTUVyEpphmDX02nu8MjWnJRrDz/MIW2OZc4mUwln23TLXrSUjR4arGU0 9/YNlQKf5TOJALv7j+HWvZGWRr/gD/ERu11mS5YznQBppONA8NlE9Eng4v+Bc1WhgViG pdKw== 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=ngktednXz9q/csZrbr0IoRKhu8K8M3DmP78L/LpM26w=; b=jjHvKvi9+1Typpgfj/AZqB30ZL1Uh4JktpMcS5J+NdSx5OXqvb72OXFZ6dLZUmSEdj AWGoCwIakIMlZgl3UgxHvaOR3nLmOmCftajsqX2WasEG+dMR/tLbY6/glByiVUlUmntW XgqY86XI56A+AXQ+yNR971G3g9uG+LKttM+mwsep+rOiV8XM+XkcOb5MnXq+LCM0AN5a 259KwcjieEdT+xraIoEXH8pjbbw8sVHancKD9tGAVbgPw/4KO6G9ShYkQNv5bHVe0GmM 8MMwCJaY6lSGNYuKX/9qbRjKARRKbvRPp5y/jZPUqTlaogEk2i8kCOC5A8WDPc+M8Nnh aQBg== X-Gm-Message-State: APt69E3iJWYC0hlfOboyzFl5hTsbFWfyc5B8j3lA5HyShq5DhF9onx2v Wi2hzNjsLZPZqKDMWqI8uXNdHGpZ X-Google-Smtp-Source: AAOMgpd3oh42hlFoAiPGvvcTu91BtRyD51nDiJ/zavD4w1ctWeywW53pYR2EGXGhm5w2PAGZhHkD1w== X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr17282762pln.290.1530481459436; Sun, 01 Jul 2018 14:44:19 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:16 +0530 Message-Id: <1530349239-22049-13-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 01 Jul 2018 21:44:20 +0000 (UTC) for IP:'209.85.160.52' DOMAIN:'mail-pl0-f52.google.com' HELO:'mail-pl0-f52.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.52 mail-pl0-f52.google.com 209.85.160.52 mail-pl0-f52.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 12/35] util: file: 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 01 Jul 2018 21:45: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" Using the new 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. When a variable of type virFileWrapperFdPtr is declared using VIR_AUTOPTR, the function virFileWrapperFdFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar --- src/util/virfile.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virfile.h b/src/util/virfile.h index 6f1e802..b30a1d3 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -32,6 +32,7 @@ # include "internal.h" # include "virbitmap.h" # include "virstoragefile.h" +# include "viralloc.h" =20 typedef enum { VIR_FILE_CLOSE_PRESERVE_ERRNO =3D 1 << 0, @@ -367,4 +368,6 @@ int virFileInData(int fd, int *inData, long long *length); =20 +VIR_DEFINE_AUTOPTR_FUNC(virFileWrapperFd, virFileWrapperFdFree) + #endif /* __VIR_FILE_H */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481508126690.5048446725415; Sun, 1 Jul 2018 14:45:08 -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 B292D3086261; Sun, 1 Jul 2018 21:45:06 +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 7826A30C43B2; Sun, 1 Jul 2018 21:45: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 1B2EC24F63; Sun, 1 Jul 2018 21:45: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 w61Lib2Z009141 for ; Sun, 1 Jul 2018 17:44:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8287A60BEC; Sun, 1 Jul 2018 21:44:37 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AC4C60BE7 for ; Sun, 1 Jul 2018 21:44:34 +0000 (UTC) Received: from mail-pg0-f42.google.com (mail-pg0-f42.google.com [74.125.83.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 87BCA308A953 for ; Sun, 1 Jul 2018 21:44:23 +0000 (UTC) Received: by mail-pg0-f42.google.com with SMTP id w8-v6so6213532pgp.7 for ; Sun, 01 Jul 2018 14:44:23 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:22 -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=VkJL0q8bQ2pFuNygNVK/Z0w3XZ1W86TmhZtdSBRozug=; b=GCp05mG7KHAj+WARFdzzDgtJy0mgpL2IpRHuAF61QlUCV9fcYD/USKuZn8z9YDe1dA glopkHAvYoU9nn0DUjrPo9ol0T+HuCQRlVBBmYLebDmwFV9kiB3F0OEZYCKH0ymQdKTY /WvwMH1dAcHgadvss+hhuTUW+45p0JkaojjtSF86nE4ToYCZxL6zUTAVUGVGGcCqFAw3 Il2os6SByCKD0WRZh6UtXMOTHbKgvRhGC9haA9IqdTrnMNdE5lmZb8gwUht4UwP1qJ4l rcANa2RhLLXfq53KHm85O7SXODY9DbjwsxSxVCk5ud8edElMspgszDufikVN98GPAABr s3tQ== 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=VkJL0q8bQ2pFuNygNVK/Z0w3XZ1W86TmhZtdSBRozug=; b=tXwxmbOAyzStT6SFMMkMV1V5hvkyi9WMr3TuHMBlYDvmDry5DuTyatLQIHns7AETCb AXYW+FwWHXCt7XTwydP9ipIxuJzGKn0HMPWCPZupZMfxGuQ3HtB4PD3ByJ4Hf76m5+6t 7vmcJizosc8d8NWFCnhMcd5vHLwr0pcqu56HzxbzKSjfydI4tkgxG6Q6OrGwiWD3N5/i U3TZNOjcqmVN9BSkWKb12lB8Ox2Rz1hjd1D9rEIubzypXgPg9dfmdwwJO0TVH+BqdLDo B3e5twIekyteRAK0zgnpGt8WaZXvxwDT0XlAZE+2GgqmMmmQpUcw9pFpShZIYZ3EW4Qw 8kQQ== X-Gm-Message-State: APt69E1B6sV9cs2+RVUMr4h/3UuKJaKWSitGetBpIN3nnjmanExUsLwv EHPhk2Dy98b4xKo5gYo7bLMPLL9L X-Google-Smtp-Source: AAOMgpddwufeQOoKZ/c7Z8g8BM1vqCIKhf2tSAWcK/hcaM8RywJxvgjojYNMRwSxpfy412r/vpMaRQ== X-Received: by 2002:a62:c8a:: with SMTP id 10-v6mr22770865pfm.27.1530481462773; Sun, 01 Jul 2018 14:44:22 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:17 +0530 Message-Id: <1530349239-22049-14-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.41]); Sun, 01 Jul 2018 21:44:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 01 Jul 2018 21:44:23 +0000 (UTC) for IP:'74.125.83.42' DOMAIN:'mail-pg0-f42.google.com' HELO:'mail-pg0-f42.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.786 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.42 mail-pg0-f42.google.com 74.125.83.42 mail-pg0-f42.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 13/35] util: file: 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 01 Jul 2018 21:45: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" The include directive for viralloc.h is added in virfile.h in a previous patch. Signed-off-by: Sukrit Bhatnagar --- src/util/virfile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 378d03e..2690e2d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -67,7 +67,6 @@ =20 #include "configmake.h" #include "intprops.h" -#include "viralloc.h" #include "vircommand.h" #include "virerror.h" #include "virfile.h" --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481485236361.34595530413526; Sun, 1 Jul 2018 14:44:45 -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 B8FEF3680F; Sun, 1 Jul 2018 21:44: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 7029C4B7; Sun, 1 Jul 2018 21:44:42 +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 15EBE18037F9; Sun, 1 Jul 2018 21:44:42 +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 w61Lid18009155 for ; Sun, 1 Jul 2018 17:44:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79EBD20155E5; Sun, 1 Jul 2018 21:44:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7093720155E4 for ; Sun, 1 Jul 2018 21:44:39 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.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 CB277307D847 for ; Sun, 1 Jul 2018 21:44:27 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id z1-v6so6200313pgv.12 for ; Sun, 01 Jul 2018 14:44:27 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:26 -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=zZ57GmBoEfhxDgjPC9x4xpCfzSRTKV/B0f+4wugy59Y=; b=Bp6AozNiLkfw1wtozOExIZq5vkxRR1WPL3bjEM8P+i/WkrNWeU/NnkXHjF5V7O36Py /Cdn5acimlYhaAJn5Sre8x+XoitS+YLC5hKWoJvgYac0VT3q6UU/lmYHis/+bZeo5WHZ +jPTKaZ8t6xE7wYWwHiXs02LAdr2rgtwvTgRXziLNYMmmcAv68gydFxhfAKfY1292IaU dTu/5C0lqejGLlQPmNOQJjzuzzyfyD/StY34t3P3lc62FmnECpts07VUYLK0y4//wGc8 gvf/IGjl1EvyEVXnDicIJoituwT7EbB2Ul536C6PdqQIbcITXO9kUMkVklgItF26BjqA jr4w== 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=zZ57GmBoEfhxDgjPC9x4xpCfzSRTKV/B0f+4wugy59Y=; b=nEKkx1yud1JOnEYSEw/e2kJxjIfQdx3N/4AjhwmY1YxLw+RHgXQB9JYXhr/F5MMGoW FsvUkbOwKQIWu/Wpe8eOs4VG4bShvo5Y/iaEup6Y2VyFDNMWdG0NuBFGGMvh+yPzQI0X 6RFP3Pufpdf06+UwZwgEhr95WUCqRFQA5BoHYs3ukXWYTIeEVPWxum03gkx+zBbUO7DO l3W7CjyC8udi8rVWH7f/JS8oZrSCG1Fiq/iTL7Q1wix7o7X5EOJqRX1+wWa2VGZBO/Q0 v/dK3ziEBfOyXvKCxpGALXH2cdOtdDo9SoWqBhT2723cYWPoV2kS9L+RjRrUrKLE+pcr d6TA== X-Gm-Message-State: APt69E35c8B4b6PtQJhHYKbT884oWcV4elb/VmuFBVbgE+JtuS0Z7aaB 4z7g8/fBxKLLU8cJmEiJjpKT9Wrv X-Google-Smtp-Source: ADUXVKLi6z8JkwhGsVGVk8n0bBStn02oJKxsJlaZiJnFQsq3SZ64mm138xVobqKh0Qhq2xQkjHOzlg== X-Received: by 2002:a65:418b:: with SMTP id a11-v6mr19544612pgq.118.1530481466869; Sun, 01 Jul 2018 14:44:26 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:18 +0530 Message-Id: <1530349239-22049-15-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.48]); Sun, 01 Jul 2018 21:44:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 01 Jul 2018 21:44:27 +0000 (UTC) for IP:'74.125.83.66' DOMAIN:'mail-pg0-f66.google.com' HELO:'mail-pg0-f66.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.66 mail-pg0-f66.google.com 74.125.83.66 mail-pg0-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 14/35] util: file: 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Sun, 01 Jul 2018 21:44:44 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety (patches 12-14) --- src/util/virfile.c | 310 ++++++++++++++++++-------------------------------= ---- 1 file changed, 102 insertions(+), 208 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 2690e2d..3a7445f 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -211,7 +211,7 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) bool output =3D false; int pipefd[2] =3D { -1, -1 }; int mode =3D -1; - char *iohelper_path =3D NULL; + VIR_AUTOFREE(char *) iohelper_path =3D NULL; =20 if (!flags) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -262,8 +262,6 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) =20 ret->cmd =3D virCommandNewArgList(iohelper_path, name, NULL); =20 - VIR_FREE(iohelper_path); - if (output) { virCommandSetInputFD(ret->cmd, pipefd[0]); virCommandSetOutputFD(ret->cmd, fd); @@ -294,7 +292,6 @@ virFileWrapperFdNew(int *fd, const char *name, unsigned= int flags) return ret; =20 error: - VIR_FREE(iohelper_path); VIR_FORCE_CLOSE(pipefd[0]); VIR_FORCE_CLOSE(pipefd[1]); virFileWrapperFdFree(ret); @@ -492,7 +489,7 @@ virFileRewrite(const char *path, virFileRewriteFunc rewrite, const void *opaque) { - char *newfile =3D NULL; + VIR_AUTOFREE(char *) newfile =3D NULL; int fd =3D -1; int ret =3D -1; =20 @@ -533,10 +530,8 @@ virFileRewrite(const char *path, =20 cleanup: VIR_FORCE_CLOSE(fd); - if (newfile) { + if (newfile) unlink(newfile); - VIR_FREE(newfile); - } return ret; } =20 @@ -763,7 +758,7 @@ int virFileLoopDeviceAssociate(const char *file, int lofd =3D -1; int fsfd =3D -1; struct loop_info64 lo; - char *loname =3D NULL; + VIR_AUTOFREE(char *) loname =3D NULL; int ret =3D -1; =20 if ((lofd =3D virFileLoopDeviceOpen(&loname)) < 0) @@ -801,7 +796,6 @@ int virFileLoopDeviceAssociate(const char *file, ret =3D 0; =20 cleanup: - VIR_FREE(loname); VIR_FORCE_CLOSE(fsfd); if (ret =3D=3D -1) VIR_FORCE_CLOSE(lofd); @@ -816,8 +810,7 @@ int virFileLoopDeviceAssociate(const char *file, static int virFileNBDDeviceIsBusy(const char *dev_name) { - char *path; - int ret =3D -1; + VIR_AUTOFREE(char *) path =3D NULL; =20 if (virAsprintf(&path, SYSFS_BLOCK_DIR "/%s/pid", dev_name) < 0) @@ -825,18 +818,14 @@ virFileNBDDeviceIsBusy(const char *dev_name) =20 if (!virFileExists(path)) { if (errno =3D=3D ENOENT) - ret =3D 0; + return 0; else virReportSystemError(errno, _("Cannot check NBD device %s pid"), dev_name); - goto cleanup; + return -1; } - ret =3D 1; - - cleanup: - VIR_FREE(path); - return ret; + return 1; } =20 =20 @@ -881,15 +870,13 @@ virFileNBDLoadDriver(void) "administratively prohibited")); return false; } else { - char *errbuf =3D NULL; + VIR_AUTOFREE(char *) errbuf =3D NULL; =20 if ((errbuf =3D virKModLoad(NBD_DRIVER, true))) { - VIR_FREE(errbuf); virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to load nbd module")); return false; } - VIR_FREE(errbuf); } return true; } @@ -899,8 +886,8 @@ int virFileNBDDeviceAssociate(const char *file, bool readonly, char **dev) { - char *nbddev =3D NULL; - char *qemunbd =3D NULL; + VIR_AUTOFREE(char *) nbddev =3D NULL; + VIR_AUTOFREE(char *) qemunbd =3D NULL; virCommandPtr cmd =3D NULL; int ret =3D -1; const char *fmtstr =3D NULL; @@ -948,8 +935,6 @@ int virFileNBDDeviceAssociate(const char *file, ret =3D 0; =20 cleanup: - VIR_FREE(nbddev); - VIR_FREE(qemunbd); virCommandFree(cmd); return ret; } @@ -996,7 +981,6 @@ int virFileDeleteTree(const char *dir) { DIR *dh; struct dirent *de; - char *filepath =3D NULL; int ret =3D -1; int direrr; =20 @@ -1008,6 +992,7 @@ int virFileDeleteTree(const char *dir) return -1; =20 while ((direrr =3D virDirRead(dh, &de, dir)) > 0) { + VIR_AUTOFREE(char *) filepath =3D NULL; struct stat sb; =20 if (virAsprintf(&filepath, "%s/%s", @@ -1031,8 +1016,6 @@ int virFileDeleteTree(const char *dir) goto cleanup; } } - - VIR_FREE(filepath); } if (direrr < 0) goto cleanup; @@ -1047,7 +1030,6 @@ int virFileDeleteTree(const char *dir) ret =3D 0; =20 cleanup: - VIR_FREE(filepath); VIR_DIR_CLOSE(dh); return ret; } @@ -1205,7 +1187,7 @@ static int safezero_slow(int fd, off_t offset, off_t len) { int r; - char *buf; + VIR_AUTOFREE(char *) buf =3D NULL; unsigned long long remain, bytes; =20 if (lseek(fd, offset, SEEK_SET) < 0) @@ -1226,15 +1208,12 @@ safezero_slow(int fd, off_t offset, off_t len) bytes =3D remain; =20 r =3D safewrite(fd, buf, bytes); - if (r < 0) { - VIR_FREE(buf); + if (r < 0) return -1; - } =20 /* safewrite() guarantees all data will be written */ remain -=3D bytes; } - VIR_FREE(buf); return 0; } =20 @@ -1597,8 +1576,7 @@ virFileRelLinkPointsTo(const char *directory, const char *checkLink, const char *checkDest) { - char *candidate; - int ret; + VIR_AUTOFREE(char *) candidate =3D NULL; =20 if (*checkLink =3D=3D '/') return virFileLinkPointsTo(checkLink, checkDest); @@ -1610,9 +1588,7 @@ virFileRelLinkPointsTo(const char *directory, } if (virAsprintf(&candidate, "%s/%s", directory, checkLink) < 0) return -1; - ret =3D virFileLinkPointsTo(candidate, checkDest); - VIR_FREE(candidate); - return ret; + return virFileLinkPointsTo(candidate, checkDest); } =20 =20 @@ -1945,44 +1921,40 @@ virFileIsExecutable(const char *file) */ int virFileIsMountPoint(const char *file) { - char *parent =3D NULL; - int ret =3D -1; + VIR_AUTOFREE(char *) parent =3D NULL; + int ret; struct stat sb1, sb2; =20 if (!(parent =3D mdir_name(file))) { virReportOOMError(); - goto cleanup; + return -1; } =20 VIR_DEBUG("Comparing '%s' to '%s'", file, parent); =20 if (stat(file, &sb1) < 0) { if (errno =3D=3D ENOENT) - ret =3D 0; + return 0; else virReportSystemError(errno, _("Cannot stat '%s'"), file); - goto cleanup; + return -1; } =20 if (stat(parent, &sb2) < 0) { virReportSystemError(errno, _("Cannot stat '%s'"), parent); - goto cleanup; + return -1; } =20 - if (!S_ISDIR(sb1.st_mode)) { - ret =3D 0; - goto cleanup; - } + if (!S_ISDIR(sb1.st_mode)) + return 0; =20 ret =3D sb1.st_dev !=3D sb2.st_dev; VIR_DEBUG("Is mount %d", ret); =20 - cleanup: - VIR_FREE(parent); return ret; } =20 @@ -2165,7 +2137,7 @@ virFileAccessibleAs(const char *path, int mode, { pid_t pid =3D 0; int status, ret =3D 0; - gid_t *groups; + VIR_AUTOFREE(gid_t *) groups =3D NULL; int ngroups; =20 if (uid =3D=3D geteuid() && @@ -2178,13 +2150,10 @@ virFileAccessibleAs(const char *path, int mode, =20 pid =3D virFork(); =20 - if (pid < 0) { - VIR_FREE(groups); + if (pid < 0) return -1; - } =20 if (pid) { /* parent */ - VIR_FREE(groups); if (virProcessWait(pid, &status, false) < 0) { /* virProcessWait() already reported error */ errno =3D EINTR; @@ -2280,7 +2249,7 @@ virFileOpenForked(const char *path, int openflags, mo= de_t mode, int recvfd_errno =3D 0; int fd =3D -1; int pair[2] =3D { -1, -1 }; - gid_t *groups; + VIR_AUTOFREE(gid_t *) groups =3D NULL; int ngroups; bool created =3D false; =20 @@ -2298,16 +2267,12 @@ virFileOpenForked(const char *path, int openflags, = mode_t mode, virReportSystemError(errno, _("failed to create socket needed for '%s'"), path); - VIR_FREE(groups); return ret; } =20 pid =3D virFork(); - if (pid < 0) { - ret =3D -errno; - VIR_FREE(groups); - return ret; - } + if (pid < 0) + return -errno; =20 if (pid =3D=3D 0) { =20 @@ -2372,7 +2337,6 @@ virFileOpenForked(const char *path, int openflags, mo= de_t mode, =20 /* parent */ =20 - VIR_FREE(groups); VIR_FORCE_CLOSE(pair[1]); =20 do { @@ -2573,7 +2537,7 @@ virFileRemove(const char *path, { pid_t pid; int status =3D 0, ret =3D 0; - gid_t *groups; + VIR_AUTOFREE(gid_t *) groups =3D NULL; int ngroups; =20 if (!virFileRemoveNeedsSetuid(path, uid, gid)) { @@ -2598,15 +2562,11 @@ virFileRemove(const char *path, =20 pid =3D virFork(); =20 - if (pid < 0) { - ret =3D -errno; - VIR_FREE(groups); - return ret; - } + if (pid < 0) + return -errno; =20 if (pid) { /* parent */ /* wait for child to complete, and retrieve its exit code */ - VIR_FREE(groups); =20 if (virProcessWait(pid, &status, 0) < 0) { /* virProcessWait() reports errno on waitpid failure, so we'll= just @@ -2738,7 +2698,7 @@ virDirCreate(const char *path, struct stat st; pid_t pid; int status =3D 0, ret =3D 0; - gid_t *groups; + VIR_AUTOFREE(gid_t *) groups =3D NULL; int ngroups; bool created =3D false; =20 @@ -2774,15 +2734,11 @@ virDirCreate(const char *path, =20 pid =3D virFork(); =20 - if (pid < 0) { - ret =3D -errno; - VIR_FREE(groups); - return ret; - } + if (pid < 0) + return -errno; =20 if (pid) { /* parent */ /* wait for child to complete, and retrieve its exit code */ - VIR_FREE(groups); =20 if (virProcessWait(pid, &status, 0) < 0) { /* virProcessWait() reports errno on waitpid failure, so we'll= just @@ -3047,13 +3003,13 @@ int virFileChownFiles(const char *name, int ret =3D -1; int direrr; DIR *dir; - char *path =3D NULL; =20 if (virDirOpen(&dir, name) < 0) return -1; =20 while ((direrr =3D virDirRead(dir, &ent, name)) > 0) { - VIR_FREE(path); + VIR_AUTOFREE(char *) path =3D NULL; + if (virAsprintf(&path, "%s/%s", name, ent->d_name) < 0) goto cleanup; =20 @@ -3075,8 +3031,6 @@ int virFileChownFiles(const char *name, ret =3D 0; =20 cleanup: - VIR_FREE(path); - virDirClose(&dir); =20 return ret; @@ -3138,19 +3092,14 @@ int virFileMakePathWithMode(const char *path, mode_t mode) { - int ret =3D -1; - char *tmp; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 if (VIR_STRDUP(tmp, path) < 0) { errno =3D ENOMEM; - goto cleanup; + return -1; } =20 - ret =3D virFileMakePathHelper(tmp, mode); - - cleanup: - VIR_FREE(tmp); - return ret; + return virFileMakePathHelper(tmp, mode); } =20 =20 @@ -3158,8 +3107,7 @@ int virFileMakeParentPath(const char *path) { char *p; - char *tmp; - int ret =3D -1; + VIR_AUTOFREE(char *) tmp =3D NULL; =20 VIR_DEBUG("path=3D%s", path); =20 @@ -3170,15 +3118,11 @@ virFileMakeParentPath(const char *path) =20 if ((p =3D strrchr(tmp, '/')) =3D=3D NULL) { errno =3D EINVAL; - goto cleanup; + return -1; } *p =3D '\0'; =20 - ret =3D virFileMakePathHelper(tmp, 0777); - - cleanup: - VIR_FREE(tmp); - return ret; + return virFileMakePathHelper(tmp, 0777); } =20 =20 @@ -3212,7 +3156,7 @@ virFileOpenTty(int *ttymaster, char **ttyName, int ra= wmode) * doesn't have to worry about that mess? */ int ret =3D -1; int slave =3D -1; - char *name =3D NULL; + VIR_AUTOFREE(char *) name =3D NULL; =20 /* Unfortunately, we can't use the name argument of openpty, since * there is no guarantee on how large the buffer has to be. @@ -3273,7 +3217,6 @@ virFileOpenTty(int *ttymaster, char **ttyName, int ra= wmode) if (ret !=3D 0) VIR_FORCE_CLOSE(*ttymaster); VIR_FORCE_CLOSE(slave); - VIR_FREE(name); =20 return ret; } @@ -3373,21 +3316,17 @@ virFileSkipRoot(const char *path) int virFileAbsPath(const char *path, char **abspath) { - char *buf; - if (path[0] =3D=3D '/') { if (VIR_STRDUP(*abspath, path) < 0) return -1; } else { - buf =3D getcwd(NULL, 0); + VIR_AUTOFREE(char *) buf =3D getcwd(NULL, 0); + if (buf =3D=3D NULL) return -1; =20 - if (virAsprintf(abspath, "%s/%s", buf, path) < 0) { - VIR_FREE(buf); + if (virAsprintf(abspath, "%s/%s", buf, path) < 0) return -1; - } - VIR_FREE(buf); } =20 return 0; @@ -3487,7 +3426,7 @@ virFileRemoveLastComponent(char *path) int virFilePrintf(FILE *fp, const char *msg, ...) { va_list vargs; - char *str; + VIR_AUTOFREE(char *) str =3D NULL; int ret; =20 va_start(vargs, msg); @@ -3501,8 +3440,6 @@ int virFilePrintf(FILE *fp, const char *msg, ...) ret =3D -1; } =20 - VIR_FREE(str); - cleanup: va_end(vargs); =20 @@ -3538,7 +3475,8 @@ int virFileIsSharedFSType(const char *path, int fstypes) { - char *dirpath, *p; + VIR_AUTOFREE(char *) dirpath =3D NULL; + char *p; struct statfs sb; int statfs_ret; =20 @@ -3558,7 +3496,6 @@ virFileIsSharedFSType(const char *path, if ((p =3D strrchr(dirpath, '/')) =3D=3D NULL) { virReportSystemError(EINVAL, _("Invalid relative path '%s'"), path); - VIR_FREE(dirpath); return -1; } =20 @@ -3571,8 +3508,6 @@ virFileIsSharedFSType(const char *path, =20 } while ((statfs_ret < 0) && (p !=3D dirpath)); =20 - VIR_FREE(dirpath); - if (statfs_ret < 0) { virReportSystemError(errno, _("cannot determine filesystem for '%s'"), @@ -3639,18 +3574,20 @@ virFileGetHugepageSize(const char *path, static int virFileGetDefaultHugepageSize(unsigned long long *size) { - int ret =3D -1; - char *meminfo, *c, *n, *unit; + VIR_AUTOFREE(char *) meminfo =3D NULL; + char *c; + char *n; + char *unit; =20 if (virFileReadAll(PROC_MEMINFO, 4096, &meminfo) < 0) - goto cleanup; + return -1; =20 if (!(c =3D strstr(meminfo, HUGEPAGESIZE_STR))) { virReportError(VIR_ERR_NO_SUPPORT, _("%s not found in %s"), HUGEPAGESIZE_STR, PROC_MEMINFO); - goto cleanup; + return -1; } c +=3D strlen(HUGEPAGESIZE_STR); =20 @@ -3663,13 +3600,10 @@ virFileGetDefaultHugepageSize(unsigned long long *s= ize) virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to parse %s %s"), HUGEPAGESIZE_STR, c); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FREE(meminfo); - return ret; + return 0; } =20 # define PROC_MOUNTS "/proc/mounts" @@ -3963,10 +3897,8 @@ virFileCopyACLs(const char *src, int virFileComparePaths(const char *p1, const char *p2) { - int ret =3D -1; - char *res1, *res2; - - res1 =3D res2 =3D NULL; + VIR_AUTOFREE(char *) res1 =3D NULL; + VIR_AUTOFREE(char *) res2 =3D NULL; =20 /* Assume p1 and p2 are symlinks, so try to resolve and canonicalize t= hem. * Canonicalization fails for example on file systems names like 'proc= ' or @@ -3975,19 +3907,13 @@ virFileComparePaths(const char *p1, const char *p2) */ ignore_value(virFileResolveLink(p1, &res1)); if (!res1 && VIR_STRDUP(res1, p1) < 0) - goto cleanup; + return -1; =20 ignore_value(virFileResolveLink(p2, &res2)); if (!res2 && VIR_STRDUP(res2, p2) < 0) - goto cleanup; - - ret =3D STREQ_NULLABLE(res1, res2); - - cleanup: - VIR_FREE(res1); - VIR_FREE(res2); + return -1; =20 - return ret; + return STREQ_NULLABLE(res1, res2); } =20 =20 @@ -4131,25 +4057,22 @@ virFileInData(int fd ATTRIBUTE_UNUSED, int virFileReadValueInt(int *value, const char *format, ...) { - int ret =3D -1; - char *str =3D NULL; - char *path =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; va_list ap; =20 va_start(ap, format); if (virVasprintf(&path, format, ap) < 0) { va_end(ap); - goto cleanup; + return -1; } va_end(ap); =20 - if (!virFileExists(path)) { - ret =3D -2; - goto cleanup; - } + if (!virFileExists(path)) + return -2; =20 if (virFileReadAll(path, INT_BUFSIZE_BOUND(*value), &str) < 0) - goto cleanup; + return -1; =20 virStringTrimOptionalNewline(str); =20 @@ -4157,14 +4080,10 @@ virFileReadValueInt(int *value, const char *format,= ...) virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid integer value '%s' in file '%s'"), str, path); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FREE(path); - VIR_FREE(str); - return ret; + return 0; } =20 =20 @@ -4181,25 +4100,22 @@ virFileReadValueInt(int *value, const char *format,= ...) int virFileReadValueUint(unsigned int *value, const char *format, ...) { - int ret =3D -1; - char *str =3D NULL; - char *path =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; va_list ap; =20 va_start(ap, format); if (virVasprintf(&path, format, ap) < 0) { va_end(ap); - goto cleanup; + return -1; } va_end(ap); =20 - if (!virFileExists(path)) { - ret =3D -2; - goto cleanup; - } + if (!virFileExists(path)) + return -2; =20 if (virFileReadAll(path, INT_BUFSIZE_BOUND(*value), &str) < 0) - goto cleanup; + return -1; =20 virStringTrimOptionalNewline(str); =20 @@ -4207,14 +4123,10 @@ virFileReadValueUint(unsigned int *value, const cha= r *format, ...) virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid unsigned integer value '%s' in file '%s'= "), str, path); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FREE(path); - VIR_FREE(str); - return ret; + return 0; } =20 =20 @@ -4231,26 +4143,23 @@ virFileReadValueUint(unsigned int *value, const cha= r *format, ...) int virFileReadValueScaledInt(unsigned long long *value, const char *format, .= ..) { - int ret =3D -1; - char *str =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; char *endp =3D NULL; - char *path =3D NULL; va_list ap; =20 va_start(ap, format); if (virVasprintf(&path, format, ap) < 0) { va_end(ap); - goto cleanup; + return -1; } va_end(ap); =20 - if (!virFileExists(path)) { - ret =3D -2; - goto cleanup; - } + if (!virFileExists(path)) + return -2; =20 if (virFileReadAll(path, INT_BUFSIZE_BOUND(*value), &str) < 0) - goto cleanup; + return -1; =20 virStringTrimOptionalNewline(str); =20 @@ -4258,14 +4167,10 @@ virFileReadValueScaledInt(unsigned long long *value= , const char *format, ...) virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid unsigned scaled integer value '%s' in fi= le '%s'"), str, path); - goto cleanup; + return -1; } =20 - ret =3D virScaleInteger(value, endp, 1024, ULLONG_MAX); - cleanup: - VIR_FREE(path); - VIR_FREE(str); - return ret; + return virScaleInteger(value, endp, 1024, ULLONG_MAX); } =20 /* Arbitrarily sized number, feel free to change, but the function should = be @@ -4285,37 +4190,30 @@ virFileReadValueScaledInt(unsigned long long *value= , const char *format, ...) int virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...) { - int ret =3D -1; - char *str =3D NULL; - char *path =3D NULL; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; va_list ap; =20 va_start(ap, format); if (virVasprintf(&path, format, ap) < 0) { va_end(ap); - goto cleanup; + return -1; } va_end(ap); =20 - if (!virFileExists(path)) { - ret =3D -2; - goto cleanup; - } + if (!virFileExists(path)) + return -2; =20 if (virFileReadAll(path, VIR_FILE_READ_VALUE_STRING_MAX, &str) < 0) - goto cleanup; + return -1; =20 virStringTrimOptionalNewline(str); =20 *value =3D virBitmapParseUnlimited(str); if (!*value) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - VIR_FREE(path); - VIR_FREE(str); - return ret; + return 0; } =20 /** @@ -4333,30 +4231,26 @@ virFileReadValueBitmap(virBitmapPtr *value, const c= har *format, ...) int virFileReadValueString(char **value, const char *format, ...) { - int ret =3D -1; - char *str =3D NULL; - char *path =3D NULL; + int ret; + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; va_list ap; =20 va_start(ap, format); if (virVasprintf(&path, format, ap) < 0) { va_end(ap); - goto cleanup; + return -1; } va_end(ap); =20 - if (!virFileExists(path)) { - ret =3D -2; - goto cleanup; - } + if (!virFileExists(path)) + return -2; =20 ret =3D virFileReadAll(path, VIR_FILE_READ_VALUE_STRING_MAX, value); =20 if (*value) virStringTrimOptionalNewline(*value); - cleanup: - VIR_FREE(path); - VIR_FREE(str); + 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 Sun May 12 10:15:23 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 1530481489074256.2743479889324; Sun, 1 Jul 2018 14:44:49 -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 E90E9308A95A; Sun, 1 Jul 2018 21:44:47 +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 B1C3B20155E2; Sun, 1 Jul 2018 21:44:47 +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 6508C18037EF; Sun, 1 Jul 2018 21:44:47 +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 w61Lihv2009171 for ; Sun, 1 Jul 2018 17:44:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3FC9017481; Sun, 1 Jul 2018 21:44:43 +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 35BFA94968 for ; Sun, 1 Jul 2018 21:44:40 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) (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 4F55881DF2 for ; Sun, 1 Jul 2018 21:44:29 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id h20-v6so4604589pfn.4 for ; Sun, 01 Jul 2018 14:44:29 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:28 -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=R9m95y8hUrtRCR9P2uOJz5RbVEFHf9MIDYaVVXDKwGQ=; b=eFpHlj/EP0bd/Mi/O/PQ8w3qvmQmTNCVjce/xvEiOv4OC/ZNhpfFKzzLnv6VsDCXU3 XyijQ4e7eLLhIglDVva2e5I8OqgVxA5JirtrCPUCmbo/BrNST4Gh4ogLjqfeV19TFF0m TCnGhod72eMhwIDAruVK4p5FQGpFm+ru7e158BB+7cxO8ZzHbXuAWtBQ0hXCZVw+4q/c ILZ15eugVNKjkki9HRSwmHG8bCR+OzWKr2uJ6eGEhLlUXvNjB4Tb+7vVRi8GflTxVYij oPA3U6RnbvtzZ56jZmU0uoLnv+xC5iwytHd4/H/2/NiDFFq7NGk8ZKN1cOezYi3ZDMtk bn+A== 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=R9m95y8hUrtRCR9P2uOJz5RbVEFHf9MIDYaVVXDKwGQ=; b=jyr8CWF+qhMmY593iSdg/iJuXIgmScZR0Imw914P71ukGwmO6DQMh10cv7SrYNDTN4 ADePWVP2YSO3pQr5+Gs+kalGkM85HdvUd8vLYRAaYG+YtWg+7bNmABP3sZrsrBbAzgME XD+D6XClrgZRyQJfHqb/PD5kvT+FeKdGDnDr9zVLrF8PZWL0uMnaOtWRL6Tent+uXGU7 JxYnsyyqR8W6r8aS1sorGLyI9iOCGpaARj/ogwFDxlTdPI7SNVeX+qK6zgzfOjm9OOZO /2oIThyQBZk5BrQ/8YBGh6F1JdJ5ds/U3G9fw1NY47ajF2NDKds6qrp63SWaenflHcH6 eIXw== X-Gm-Message-State: APt69E1aBU7xlu3g286ttzkHjS3NyyKaihtJBPC7tzqTCRh30oPEemQC rbMk8MSfFGZzOrM8Dj6/tjWysmQb X-Google-Smtp-Source: ADUXVKJIvxDfXHKuueizzl+VSqZeVfEhqqb/zwB/0pzvXWbbgL0zcOdYE23N9r4l8mdr51G5NVOxtg== X-Received: by 2002:a63:2dc2:: with SMTP id t185-v6mr19954616pgt.204.1530481468586; Sun, 01 Jul 2018 14:44:28 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:19 +0530 Message-Id: <1530349239-22049-16-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sun, 01 Jul 2018 21:44:29 +0000 (UTC) for IP:'209.85.192.193' DOMAIN:'mail-pf0-f193.google.com' HELO:'mail-pf0-f193.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.193 mail-pf0-f193.google.com 209.85.192.193 mail-pf0-f193.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 v3 15/35] util: file: 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 01 Jul 2018 21:44:48 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virfile.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 3a7445f..6b94885 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -888,20 +888,19 @@ int virFileNBDDeviceAssociate(const char *file, { VIR_AUTOFREE(char *) nbddev =3D NULL; VIR_AUTOFREE(char *) qemunbd =3D NULL; - virCommandPtr cmd =3D NULL; - int ret =3D -1; + VIR_AUTOPTR(virCommand) cmd =3D NULL; const char *fmtstr =3D NULL; =20 if (!virFileNBDLoadDriver()) - goto cleanup; + return -1; =20 if (!(nbddev =3D virFileNBDDeviceFindUnused())) - goto cleanup; + return -1; =20 if (!(qemunbd =3D virFindFileInPath("qemu-nbd"))) { virReportSystemError(ENOENT, "%s", _("Unable to find 'qemu-nbd' binary in $PATH"= )); - goto cleanup; + return -1; } =20 if (fmt > 0) @@ -926,17 +925,14 @@ int virFileNBDDeviceAssociate(const char *file, /* qemu-nbd will daemonize itself */ =20 if (virCommandRun(cmd, NULL) < 0) - goto cleanup; + return -1; =20 VIR_DEBUG("Associated NBD device %s with file %s and format %s", nbddev, file, fmtstr); *dev =3D nbddev; nbddev =3D NULL; - ret =3D 0; =20 - cleanup: - virCommandFree(cmd); - return ret; + return 0; } =20 #else /* __linux__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481493836284.8489194700169; Sun, 1 Jul 2018 14:44:53 -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 D5342C0587EA; Sun, 1 Jul 2018 21:44:52 +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 9E66F30C43AE; Sun, 1 Jul 2018 21:44:52 +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 5CD493F64F; Sun, 1 Jul 2018 21:44:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61Lij4n009209 for ; Sun, 1 Jul 2018 17:44:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id 210E830C43AF; Sun, 1 Jul 2018 21:44:45 +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 1AB653083324 for ; Sun, 1 Jul 2018 21:44:42 +0000 (UTC) Received: from mail-pl0-f51.google.com (mail-pl0-f51.google.com [209.85.160.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 8C9B9C049D7F for ; Sun, 1 Jul 2018 21:44:31 +0000 (UTC) Received: by mail-pl0-f51.google.com with SMTP id d10-v6so6943334plo.5 for ; Sun, 01 Jul 2018 14:44:31 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44: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=iCBeAnUK4EbV+bL3GoZNgVbdBYhCOBrahiFPxfCR2dI=; b=WUVmMQdOu+rXEkKbcX6NCgieh2Gc7ezcawV++2hmHuwm6NvKqtbaG97IiNLtbTiWRI iLQHy/KJZ1nDDo1wafjTl2a4CTi8WU1m5Qws78oSwH/kObCDKGRzgyG40tXJwJrCa9AF k1QFoo6U3qQmAI16bRYUr4oS6ilPwfOMtUvuQIH8n6HxYuDmC6TgIiubaJDCfUrw+C/+ D6GecGR8rJiFMbGejRn4KaQm0At9l3x6jwzNPmzYznQQCdQ/+GaJZ+QwexdWPSMtw2Fz FIiAAbe8O+3pARipvZ5ZE4BKw2dsRviYc+2YLQ1+yK9/tTDqgM7rCTE4j8961yio5m4p jPdA== 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=iCBeAnUK4EbV+bL3GoZNgVbdBYhCOBrahiFPxfCR2dI=; b=ZSdND/+dAIJyZfn+hSeexZoOwm5hZfFVYq4uMpI7EnEBbrQC2aR4WGVFg7qLhZhcnT H/q+J6ep3dDHjKRe3dpBM4V31A3bEAK7uj1h4whT1yILeahPTxv+XNiH9JyHN5NjmRnd afvuzQxP8WeYjLNhE9BwmAfC0piS1knmRulRBuR2WQl0lEUTeuonrLmxtGqw+MqiOVHI 986NJrPxv0m5U7r0Pj0q/ziRxr5qA5tn3aSMni1Hg9J/uozYa5Q36QNNH2nOWtZbXnon tXJrZ37z73VS6GT7k8yzcnKj1lEehPN+ewM1W6lQlay9ZiH1fqBuwI5+s8NCWd/0Hi5S /81w== X-Gm-Message-State: APt69E1eA4V8xW0uTfm1wTtNe3M9qtdCT/12SwbzBED0+05BYwUl3dBH 3yMiR0l+Ao+jI+TuiOK7Iz06GXEZ X-Google-Smtp-Source: ADUXVKJdyrR8WUPQZjkHuV2wUcjQhL/cc2b7UtQd2M2Q01KfbCqvGbBLNsbopfwvop8dmMeifwV+MA== X-Received: by 2002:a17:902:5a83:: with SMTP id r3-v6mr22940729pli.78.1530481470832; Sun, 01 Jul 2018 14:44:30 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:20 +0530 Message-Id: <1530349239-22049-17-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:31 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 01 Jul 2018 21:44:31 +0000 (UTC) for IP:'209.85.160.51' DOMAIN:'mail-pl0-f51.google.com' HELO:'mail-pl0-f51.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.51 mail-pl0-f51.google.com 209.85.160.51 mail-pl0-f51.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 16/35] 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.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.32]); Sun, 01 Jul 2018 21:44:53 +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 new 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. When a variable of type virAuthConfigPtr is declared using VIR_AUTOPTR, the function virAuthConfigFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virauthconfig.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virauthconfig.h b/src/util/virauthconfig.h index ac0ceeb..d8a3849 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(virAuthConfig, 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 Sun May 12 10:15:23 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 1530481513129429.9632419526631; Sun, 1 Jul 2018 14:45:13 -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 E730E4DD62; Sun, 1 Jul 2018 21:45: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 9F83F6017C; Sun, 1 Jul 2018 21:45: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 5452B18037FC; Sun, 1 Jul 2018 21:45:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61Lin5U009232 for ; Sun, 1 Jul 2018 17:44:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4878B608FA; Sun, 1 Jul 2018 21:44:49 +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 3E17B608F8 for ; Sun, 1 Jul 2018 21:44:45 +0000 (UTC) Received: from mail-pl0-f41.google.com (mail-pl0-f41.google.com [209.85.160.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 A668DFECB for ; Sun, 1 Jul 2018 21:44:34 +0000 (UTC) Received: by mail-pl0-f41.google.com with SMTP id a7-v6so6945427plp.3 for ; Sun, 01 Jul 2018 14:44:34 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:33 -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=mEGVFLSaec9DKwx6lOA7+7Hm0/QEDWNf2cvl32N2vO8=; b=kunuWg5GQ/equ8Qu2T4R9ZdgzSpJHufk7G5P9QlBZyV4ZF9U8giayxBeqMNivuMTFA fQ0qrvzQvritlUETJCMOj+nITPNP592y5VSpIRE81LW8yPO/+i7pA2raLtbQ3xs+X+Ez g24ArFuFC4l6OvLPIvrKRMTwAJZtipMLkxQBSkqBSrFhOBYrFDMpx8t/7M1LzcEUANKG 1ipjtFPqsXCCDRJOGb8t5MWIjzTjBUqIBVTmKCqrNXdOqtzQqAQtgPu2oiLZ+pDW2S9o hvuJXWM3h1tgnkQStqkkK1YHgSWfvuTP2TpuIWMmQqBXZQEh5BM6rQ0WL9c9tKWZP7tr H3Pg== 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=mEGVFLSaec9DKwx6lOA7+7Hm0/QEDWNf2cvl32N2vO8=; b=pHXpKbNeL1BxmJbLbk+WSsJ6BbftXKbkYRD5lmQ1fVAUHq2Chd41ObnSsUz4YR6i70 oQawOQWkUI7idHis0LR408ECA605+3vU5VpycN9yRS+cGGGyGuBEEL9SIL+KDXbK/VN5 y1j16ViTDkfFtrQhlgSPHPfTJ1Ummq5v9GmeVDG9UQBhP0nBJdJABnZZthA+gepaEFfL OSv+tI2uIK67aHylwmWNfYT4IrXd7wuOYUOD5sELnzTB/pdeEWjhYGglY+fKDtOl+utz UqCp/inxFQKEjs31wDgIWPduac8J0piZsjlBSKcLC6QQc7WJ0XG6jLAVLoRNMDNHny/W PkUg== X-Gm-Message-State: APt69E2kckoh+Rgnjg+xpTEdVMivkXpLuxuFGGY5xAeMFMzslP1F/5eu 161ohc9ELsiPK4meXT09h16FwjSR X-Google-Smtp-Source: ADUXVKISgWS2Gu6CXOCCeZoCoSOv/huvzKyDcMFCG04DmHFbAC4UnJqKnAsIQxCulnHurAtIRfWumg== X-Received: by 2002:a17:902:1127:: with SMTP id d36-v6mr23608270pla.267.1530481473968; Sun, 01 Jul 2018 14:44:33 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:21 +0530 Message-Id: <1530349239-22049-18-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sun, 01 Jul 2018 21:44:34 +0000 (UTC) for IP:'209.85.160.41' DOMAIN:'mail-pl0-f41.google.com' HELO:'mail-pl0-f41.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.41 mail-pl0-f41.google.com 209.85.160.41 mail-pl0-f41.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 17/35] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:45:12 +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. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- 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 Sun May 12 10:15:23 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 1530481498754316.7436685156042; Sun, 1 Jul 2018 14:44:58 -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 A6D11308404C; Sun, 1 Jul 2018 21:44: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 70F1517496; Sun, 1 Jul 2018 21:44: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 2B13418037F9; Sun, 1 Jul 2018 21:44:57 +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 w61LiqV8009242 for ; Sun, 1 Jul 2018 17:44:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42748308BDA8; Sun, 1 Jul 2018 21:44:52 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39567308BDA5 for ; Sun, 1 Jul 2018 21:44:50 +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 9D4F04DD62 for ; Sun, 1 Jul 2018 21:44:39 +0000 (UTC) Received: by mail-pg0-f43.google.com with SMTP id q14-v6so6195936pgt.13 for ; Sun, 01 Jul 2018 14:44:39 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44: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=1b6g1jQcYhrmY8R4HlaCUb3a76RtXFQ+ryTHastPalk=; b=o0JjedVxk7MPXqYGLoCYldxDPAbBtRp/+v3DQPnsSRItyA5tP0TkiwSCIwtzveNs79 DzF5PBCsSvnbgeBg7bqUYmFfOntvdJBuKeiZx193M1HbtrUY/D8zepnXcYzFz7PtOPTe IFbdHAWo30cgMtM0ALUdEr49a92t/aeoSTaZYPACOpcG4VZhlDokQa1th0wLR2jWYjjr Z2ZIyC8mnKG7FRn9Cf34vwseioyhfnvHIEbHzZ5jDYAF6watlEEMxUA1VQpoYf4EUUdh P3hGXVF+E/2eHoOgN/f6teB9y93gbyD4APkTpJddQraoKGYWtGrPjaAiHFBPqte+YFfZ JmkQ== 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=1b6g1jQcYhrmY8R4HlaCUb3a76RtXFQ+ryTHastPalk=; b=bzhtoS+G9+csWevi5b64BqC81dcFOmCt2bo1j/3oqoaB0UIBsaO+SnRpKWF2PXr7CK 9lKl5wQX/b4lV7URB9Vzu3aTgPuTjyi/flcEqvhw5+QXH42KFF/tRqTcB965XuNQSRs/ YLb+wcEvpin5oXrhKUTvSDszzxshXmQEG6F16Ovr0p70iUslAZVGdeF9ngc1Xz+TVKSl yGxpDjmaCQk9excowZTjvm0O9fiqGm+uLZxm1GCkx433oiZAIJKOJJ5zWr46N2aKElx1 YOGHd6tHE5Rh1Bg/PptGcfNki5OMQD/BmL3UOIYgt9UHZlSL4e5n5cm/B5GyYEnWNUrK 2qwQ== X-Gm-Message-State: APt69E0yiPCJqVwnjsFrzrXCuih9Gs5eEhj7Dxpy6Kg+csw7l1tXZSMq 2iseBMpOsIBZOeHm2XAIvYLs9uCw X-Google-Smtp-Source: AAOMgpc2ByG7jMe/Oqbr2/a9d8+CIikoAlFFFqSnTvjoap9WM/3aSzsHsMjN/6k3g5feAn9yt5q/gg== X-Received: by 2002:a65:52cc:: with SMTP id z12-v6mr10254431pgp.69.1530481478844; Sun, 01 Jul 2018 14:44:38 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:22 +0530 Message-Id: <1530349239-22049-19-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.38]); Sun, 01 Jul 2018 21:44:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:44:39 +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.786 * (DATE_IN_PAST_24_48, 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.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 18/35] 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.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.40]); Sun, 01 Jul 2018 21:44: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" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virauthconfig.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/util/virauthconfig.c b/src/util/virauthconfig.c index 3487cc2..4acdf1d 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 Sun May 12 10:15:23 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 153048150600174.18970846374486; Sun, 1 Jul 2018 14:45:06 -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 BBC0332B678; Sun, 1 Jul 2018 21:45:04 +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 7EBB130C43AF; Sun, 1 Jul 2018 21:45:04 +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 0718D25547; Sun, 1 Jul 2018 21:45:04 +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 w61LivGf009292 for ; Sun, 1 Jul 2018 17:44:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D25988116; Sun, 1 Jul 2018 21:44:57 +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 87EB16C52B for ; Sun, 1 Jul 2018 21:44:54 +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 4DFC83082136 for ; Sun, 1 Jul 2018 21:44:43 +0000 (UTC) Received: by mail-pl0-f47.google.com with SMTP id t6-v6so6948700plo.7 for ; Sun, 01 Jul 2018 14:44:43 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:42 -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=zzpAJ5jIlYQSbeynEa+eOrNyuulIBLZ+3kOjES9N5pE=; b=Ge72up8LYpwAJyFZ8e2aOCEOE/W2v1KAFFoF8Vkzqc8TYX4R1KT6L0kXrBXmPK/Vh6 QV9Z0cvTVDer4O0ezEoSGJiR2RtWjI5Le85c2KyakGWUMPXYd+IMI+mIn3Ct8EKd+lKI B4lEHxGUlnk/p/tvyGAKf5tEDXDKgPri0Ni5muBqbAOMkXIyLfMcaWmkBH2PJeS6epS5 7ry5bDm3SvBJbG6jGIJFgrtatscpbbDV0n6mWuVXvXoYC3v/Wqipk8gV1AcuK+Ip8dLC f3g5/ZfCRrN5zmzw/WyssIsF3neh5c3NSMgi7zBGzXtvdXHKFreP5jrMgRt/6a3qzPNK fTvg== 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=zzpAJ5jIlYQSbeynEa+eOrNyuulIBLZ+3kOjES9N5pE=; b=XG4313UjsttmN+ovwpgPCzMMvpLmQQbDJLLO8UfDloCCtXgoC32RcNTm2u1Pjtpvw6 nwrrcl5FDdmaztQrWwi2NIazTF/6Dd7TccZADXozW0tBf0gc+HaeDLAGeqK99+L3MVA8 nYCKprXYnPZSdSvN7izc3Sh8mZALKj428uu21QwfOrEuPIlLqaCWvmnw3ProaMX3pF9I yq2GmsYCDtlQvk2s6wbum4zTU16bdQr6GDh5hV+3GjxqkGQ6Kl8Q3YBt4PU+lATh2uZs Q8hv1N+anRk5e9Picw25/vyhYeAfnbn9fTbKbIvc3gQwtl/pccB5SuMTlCTFgwjZ2w1y gCBg== X-Gm-Message-State: APt69E1/xtAYnXdZO2bASZooHGsMM9fQ6HY65rP9QBte8HaTUBK3Mk/H 8nm8cGZgyvPb3nWC3a7WX1JLzTfM X-Google-Smtp-Source: AAOMgpeVxWoVfUbAvDe2XUh/gK1Poy7YoNIPkSa4MHWHn4FfW31qwW/o5LhPQwGUtcZLtRThZhVhbQ== X-Received: by 2002:a17:902:a716:: with SMTP id w22-v6mr6181216plq.271.1530481482549; Sun, 01 Jul 2018 14:44:42 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:23 +0530 Message-Id: <1530349239-22049-20-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 01 Jul 2018 21:44:43 +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: 1.785 * (DATE_IN_PAST_24_48, 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.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 19/35] 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:45:05 +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. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- 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 Sun May 12 10:15:23 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 1530481505225538.554179392944; Sun, 1 Jul 2018 14:45:05 -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 D95B33086249; Sun, 1 Jul 2018 21:45:03 +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 920E4308BDBB; Sun, 1 Jul 2018 21:45:03 +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 1A7C9264FB; Sun, 1 Jul 2018 21:45:03 +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 w61Lj1u4009323 for ; Sun, 1 Jul 2018 17:45:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 31DAD17CDB; Sun, 1 Jul 2018 21:45:01 +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 293D017D0F for ; Sun, 1 Jul 2018 21:44:58 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) (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 8F887308212F for ; Sun, 1 Jul 2018 21:44:47 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id j17-v6so6530726pfn.5 for ; Sun, 01 Jul 2018 14:44:47 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:46 -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=lFsX1T9niIpbAIyB8ZfvwfZ97t74pSrHPdkySwSBHqk=; b=dSwhr+PnedFZzetE56nbsdyiphHXlKx14XKdoroQ0iQDFBHlLxY/32hCGHAfonmvuF LGQpSUy0M6G64W7V3lnPZN0F9wLZxICzx2Hr4TKd0EhYxGiWGl6k/njQJBA7LE9o2vsr t0uBrYE3o7Sr24phtxHK7uw/iMJ0zDYq9ubUG23K3zQDAlQhCeX579/Cww+sz/t9vFaY 7O8hzvbH3/H4yQuWurKZPp+O2I3/XKHsgqx1i2YsD1OQljLEY0SVTd3tnF/YoeCOuAVI 18sOhssITQD2MkzmudXyWbxMO03D5exAtPf+O1FnprsNffDYos5ja7zaCrjwspfHzikF u9eg== 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=lFsX1T9niIpbAIyB8ZfvwfZ97t74pSrHPdkySwSBHqk=; b=tgWoS2YuY5ZDxdFEVeQoP9208uPp9Mq7gsNRmXMd+PMtiQaVBjwiiaS1tyFEPbXTZ5 vJUxE7ObY7RRzt8ekuYGbikctGXCzaVWcajBmPWamx+Dlp3fn1OOfhz82gxdLfXLUwOo djctU/i5yOrJ5cuSgc+B7X1HDq5sRnCDD/9R47jC+hYHCiVUvp5SGPPKUto2k7LZG6pm EWWSweNRrpPe5gg7cS4GnxZGbm5uS/vZvhNZry+NmASo0SxKMn5EAA02Qh3j2UQLk/2O 5upsf8IqyM6sns/mZdG+2LD7+BGkYqFoQuyuanODeVRpIMNWgh/TO9xrtqswA0BOYQAm 9HsA== X-Gm-Message-State: APt69E1B+uIyWEDT5VJxP0hWz39zt49gRmz32csWRKKazM0VrLH7FnvP xvc/djZ07SkpSVJUdxYK7/AyJIgH X-Google-Smtp-Source: AAOMgpeUxtyherRoc8DJvWhHs5CAOSDy58x7ytRjH4fuN/JpVlIDEU6lSw0GWZF6quhd/JVJTRUm+A== X-Received: by 2002:a65:4acd:: with SMTP id c13-v6mr14796217pgu.436.1530481486863; Sun, 01 Jul 2018 14:44:46 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:24 +0530 Message-Id: <1530349239-22049-21-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 01 Jul 2018 21:44:47 +0000 (UTC) for IP:'209.85.192.193' DOMAIN:'mail-pf0-f193.google.com' HELO:'mail-pf0-f193.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.193 mail-pf0-f193.google.com 209.85.192.193 mail-pf0-f193.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 20/35] 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Sun, 01 Jul 2018 21:45:04 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/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 Sun May 12 10:15:23 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 1530481518716867.8901340375703; Sun, 1 Jul 2018 14:45:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 838D732B683; Sun, 1 Jul 2018 21:45: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 4629617D38; Sun, 1 Jul 2018 21:45: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 E446F24F58; Sun, 1 Jul 2018 21:45: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 w61LjEpP009474 for ; Sun, 1 Jul 2018 17:45:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id D824D6017C; Sun, 1 Jul 2018 21:45:14 +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 CFC446017B for ; Sun, 1 Jul 2018 21:45:03 +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 96E0280F7B for ; Sun, 1 Jul 2018 21:44:51 +0000 (UTC) Received: by mail-pf0-f182.google.com with SMTP id l123-v6so3475508pfl.13 for ; Sun, 01 Jul 2018 14:44:51 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:50 -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=XjDXJ9jNYl/wsOF+GgskcC9+Csa8Kus1PeUjuSdKV98=; b=QzO/JRe5B6cQJn3g67dQi4/uVTdW5lR74TJXRBSuuZD46s4REF9Zn2+QR658Cw2YRe L2LSPD9rgGnc1e5BEei1LUSikJDx1WRlLCGuj0JDuburaIglM3hUPMyZbo21MHPqM4T0 EWKAZRcUiuwWHNdmLMNtC+cK133xogYBXX3OoF0HCVOQlnQXkrv7DyJgLIijyszKRtk+ wXV9VN+z4624o08rW2jEp8gsl20uNCzOytPM3L601NwQ9WZuhGXbSpu9jKUKAhuGZhbK K6Hs/FBd18SmpHYUNdRypJJ5IdCSYpbdMD/LQnghGG+0vwU60r6CD+YlpP5tMQPFnHpk 5fSw== 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=XjDXJ9jNYl/wsOF+GgskcC9+Csa8Kus1PeUjuSdKV98=; b=I4P+R/Tqt/agd+UkGOCMlA4mEWv5Kj5lwU95dMqtVDpdCmQ8qT9gTp7EDJwqxDZcyX 4XAGymHcTi7vXLYGwf4kTZ5J8oVwwqgf6ZtJP+KvzrIh1+xXyr+n6VyOo6qBMpvUt/Vt E5umxr4mydWDSK4tNE9jTGjfjLaaTqYZwb5LgJ42pliOyT4lvETvCtIEtT2YuQ2aPCRs Cyao88NOMVn/PVaJ2ahtj9FZbmBM4/X4q0+Z3wdnZB5gUyUqMawzoj2wIPzUjpEjT8oC P9yoLvqInlpaj9Q/+fyY6BcNQBtuZoEh5CKi0LfTSoZpTH1fe+w9mhC7TaPjw0qd8Hpz QxCA== X-Gm-Message-State: APt69E2CauCsc12SV79oTv91MSBQswvqzqqUW5QSfyAjd6L2zg1wfCUo 5RnFw9DD5IGh+SwlMQzRsDLtoATC X-Google-Smtp-Source: AAOMgpeXHIig1hvLzSoiZxoF1D7Q3OUWqmwVVpYHuNyagfHBcG/0nl67EQjj4DkgUqPL1tVP74msXQ== X-Received: by 2002:a62:d09:: with SMTP id v9-v6mr22521009pfi.163.1530481490830; Sun, 01 Jul 2018 14:44:50 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:25 +0530 Message-Id: <1530349239-22049-22-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:44:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 01 Jul 2018 21:44:51 +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.786 * (DATE_IN_PAST_24_48, 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.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 21/35] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:45: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 GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virauth.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index d3a5cc7..8c450b6 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(virAuthConfig) 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 Sun May 12 10:15:23 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 1530481513505707.8547681007373; Sun, 1 Jul 2018 14:45:13 -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 2DBAF87628; Sun, 1 Jul 2018 21:45:12 +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 EA71C60BE3; Sun, 1 Jul 2018 21:45: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 9969018037FE; Sun, 1 Jul 2018 21:45:11 +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 w61Lj83H009400 for ; Sun, 1 Jul 2018 17:45:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9F40F60C9A; Sun, 1 Jul 2018 21:45:08 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96E4D60C8F for ; Sun, 1 Jul 2018 21:45:05 +0000 (UTC) Received: from mail-pf0-f173.google.com (mail-pf0-f173.google.com [209.85.192.173]) (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 8D0925F72E for ; Sun, 1 Jul 2018 21:44:54 +0000 (UTC) Received: by mail-pf0-f173.google.com with SMTP id b17-v6so6536031pfi.0 for ; Sun, 01 Jul 2018 14:44:54 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:53 -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=xKQxb9U//91Q1YnVAMBpbTLuREZpQxVGdHFspQ8iNHU=; b=Z27LHwEaaiJaIS6M37hqB174Ws2ge1PPNRsZnU4DSawv5go8n05FWKAawIXMDgRrR9 amrHc5NnoSSPkW9XNlh3rg9shhmYhSgxEHnprfpCY2Ps0UkpzuI7UrxQPEFVKBiWsTDz MjquWnwGMVTrtVWR2owNbLz7YgJip4P8GRA0XTBxM9DRu8PF2b6iIgQeka42DPkUbIwm OWhxeFP0DLrW7cb3xNwzCVe84Tzj71paDn1y6t3R/mkQZgase+XgZOv5RXFirqVJ98lt 6pC0sKDjebWOHY6CcicChHJGr9ZT9CMlcjFC02qqBbjWAEEES+36QDkvbWARP5PLbpo4 spYA== 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=xKQxb9U//91Q1YnVAMBpbTLuREZpQxVGdHFspQ8iNHU=; b=QPxWFOzdXDO8aBrmk6Pdnj6TA4yCufnZLrhnWnXc/n3Mceqlboozgmx3wX1o/d1zqH OZNmBWAhqlzHZMxjpYyzKDd2rDRdQM4jNK83xo/gIxN8HV+AWkaqu+whOyxKezBfbNxb QrCVc+hrN22Qgj1Rxp9HBKp8Ycu4/RiqbYJduFSjLqUFjHY0/O1g0sI6USu2ChlLJ3js knIRk5hG9uPWdvCs+kAHP6i2uPlcoq+qUhAR0Vbaps6In7X4NMQGC27raZzr7kl4FJZ0 sECJxPyNh0R6dRrt+aflmdt8kmTJwDQKRlt9QpFcH6rL+npzoArQQmxZEqIv88WohJiz Th0Q== X-Gm-Message-State: APt69E0XBEotpDWWOJWIofzg4KVw9AsVOCcnEVG4OMcGCh7rpTmglpoK tsibh8mtNeRIp/PL/9c5rvbkERk7 X-Google-Smtp-Source: AAOMgpecDknHfZijlnwsEOktJUMkNS68V4uwT4VGLeYNIr0P+8torKbmT+2Bz6RiLPP83QVBu4PUcg== X-Received: by 2002:a62:2119:: with SMTP id h25-v6mr10191053pfh.112.1530481493745; Sun, 01 Jul 2018 14:44:53 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:26 +0530 Message-Id: <1530349239-22049-23-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.39]); Sun, 01 Jul 2018 21:44:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 01 Jul 2018 21:44:54 +0000 (UTC) for IP:'209.85.192.173' DOMAIN:'mail-pf0-f173.google.com' HELO:'mail-pf0-f173.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.173 mail-pf0-f173.google.com 209.85.192.173 mail-pf0-f173.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 22/35] 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.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.26]); Sun, 01 Jul 2018 21:45:12 +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 new 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. When a variable of type virJSONValuePtr is declared using VIR_AUTOPTR, the function virJSONValueFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar --- src/util/virjson.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virjson.h b/src/util/virjson.h index e4a82bd..75f7f17 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 @@ -156,4 +157,6 @@ char *virJSONStringReformat(const char *jsonstr, bool p= retty); =20 virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json); =20 +VIR_DEFINE_AUTOPTR_FUNC(virJSONValue, virJSONValueFree) + #endif /* __VIR_JSON_H_ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481518336112.14713895878106; Sun, 1 Jul 2018 14:45:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E36630832DF; Sun, 1 Jul 2018 21:45: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 E6C5C5DD96; Sun, 1 Jul 2018 21:45: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 909401800FD8; Sun, 1 Jul 2018 21:45:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LjCCx009446 for ; Sun, 1 Jul 2018 17:45:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5BBB430C43A4; Sun, 1 Jul 2018 21:45:12 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 543CF30C43AE for ; Sun, 1 Jul 2018 21:45:08 +0000 (UTC) Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) (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 2A6F9308A953 for ; Sun, 1 Jul 2018 21:44:57 +0000 (UTC) Received: by mail-pf0-f176.google.com with SMTP id a11-v6so6529768pff.8 for ; Sun, 01 Jul 2018 14:44:57 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:56 -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=F1dgqWZUZJSqIfKebK6BrxgK88nyrFcvHFntUlk6seg=; b=bSJhCVtdS01GOjxcgWmd+L+B/FikhUztHHszGRroFMgROz1XHJLy6WadC1XtZiZoil IroKNcPHnrCVeFQzDVL6TDJwCbljN1YlIMvSHRrwn83zg6Fes16kqoYZ86uG8utfw+4/ 3e1/FA3mYXKaiWtB2UpirWCvwmyHN0l78ZrDPBh93bonsiY2ISbAqg74aTPBcQCzDOvr 6f3dDmT9WCEN0c05iFbvt6DY2LSSJNo8r++pWygcjSGIXS3xXwEwsZLcjIL8A1a96zIG Bf+hK0toqw1g+icStb35oaxiq43mZJjVi5FeWgAD5bsGTdFTUn2UzlzUvBcMx21u10ZM Xsgg== 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=F1dgqWZUZJSqIfKebK6BrxgK88nyrFcvHFntUlk6seg=; b=ii0MbdLYI0bA5vzKnIO5a6ggwO79yNb2y8jJCg0Sa+RIMgNX9ITx59lLibmCXAwfWO 420HgGERd8PvZE7O6lBdsmF+wiKHjSTCu+Eby4Ww8NeLGorawfV8G0HPmJIHALNpnVQO yQbg0E0A9x/ft0gPJBJZOf0k71gzAKgrDXVRr+0bC4Qewun90ulMxA0hMNpmtrRDzQXM 5m2HGYmWdt46AYVwwSqsZIkFniUV7EvkUo/VlL7Gc1NBR5aMKTQY/GJW8s5lbCcgFObh gGKKO9XeymdF8fieBH6D/AttXlDCtXA9cnKo/ZzWd+ix8FfOBgh20tDsXVjlCcDgj/Jh Shgg== X-Gm-Message-State: APt69E0YqLwqqRym2dYIRuXSbhkmeZLLTl1yFicY/LqlsDAIVnW5WYlx nrUJURHTSlSc5+/ztRuxWXosZAGP X-Google-Smtp-Source: AAOMgpcX/+sJqTAq0hXCwpSqDtkgSDdAjJGe4+5aFHU8M8TeRHqBWPm55cQq/tit3ord+fojOag/UQ== X-Received: by 2002:a62:df4e:: with SMTP id u75-v6mr10900605pfg.195.1530481496473; Sun, 01 Jul 2018 14:44:56 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:27 +0530 Message-Id: <1530349239-22049-24-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.41]); Sun, 01 Jul 2018 21:44:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Sun, 01 Jul 2018 21:44:57 +0000 (UTC) for IP:'209.85.192.176' DOMAIN:'mail-pf0-f176.google.com' HELO:'mail-pf0-f176.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.176 mail-pf0-f176.google.com 209.85.192.176 mail-pf0-f176.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 23/35] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Sun, 01 Jul 2018 21:45: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" The include directive for viralloc.h is added in virjson.h in a previous patch. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety (patches 22-23) --- 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 Sun May 12 10:15:23 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 1530481523835415.2440918297257; Sun, 1 Jul 2018 14:45:23 -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 AE1CB81DEB; Sun, 1 Jul 2018 21:45:22 +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 76573308BDA7; Sun, 1 Jul 2018 21:45:22 +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 2BA9624F57; Sun, 1 Jul 2018 21:45:22 +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 w61LjFAg009484 for ; Sun, 1 Jul 2018 17:45:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DDD82010CC5; Sun, 1 Jul 2018 21:45:15 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92DF72010CA6 for ; Sun, 1 Jul 2018 21:45:12 +0000 (UTC) Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DDC91307D859 for ; Sun, 1 Jul 2018 21:44:59 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id m19-v6so2674501pgv.3 for ; Sun, 01 Jul 2018 14:44:59 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:44:58 -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=rAhu08CpMkl8FXidtesYOYaipgvlKrTCVrJqH3Aq1eo=; b=d2JzPZaK+A0Y9tne+d5xm73XdQ/QmNKFgNDmmDlmRjXMF0eUOoqpnzjnkSU2CtbJlM AotaZOIMYsc3ZxmXsXC4MygKL21GgI+UbiF1OXn0967M4FTsX5oU6XeBbhVYwt+rrDb1 P0t8HmzjHMk73BEUYONVIaiTdodCCsYxMpfTETwKsqd5xEaxub/ZDgIUDb8ajUOm6XX9 KOinRx1ZMzY4NqH42bDNPjr1Q4/OFW0mUlahQJrJCUd5TqEcBjZJ8007E/GSs4NW3Vfv nGd7pnikp6qso1n6xO/VHzaHH1J1GjcVe9A6jCtGfgtmltjeZ1VjMeTgWYPRzw2m9KfG 2TRA== 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=rAhu08CpMkl8FXidtesYOYaipgvlKrTCVrJqH3Aq1eo=; b=NVvDcIsOQz1pJRlbtl90tx+p5PLRdv3qsbUjGIylMoW2WiYZm+RnPRmOY2Jg+UnCH1 8PFaFBip/Sz0eZ4FdHiYUD4ANnH67AZt48y8ZPGGjaEyt9UmodVKisMiYmq1Woiyb/mr Y2NaB4T4PcKO7+J2SFujT7Bhy3rSdAJx+dTl6eJRL7OjCktjpuwwt1i9sR0FXiHK5HqE GXJVa0MKoZaavwiK/K5fh19SX4SHJghhjDKIfmqOMd8jfBpz5GmhV8SI60/rjMr0xnKZ A5Aw3bFC6S6mAw21BBX1ul5exzLS1KHdqKiumuR3iWP1/7/oKWk6f9zGebZ+npzEFOwc dcNQ== X-Gm-Message-State: APt69E0BlCfQN6vScn4pVwsQNVQWiAu2UtFASCaeSxf18SLWUZyhyvRp 1EKYkkBMTGbqZR5kuijGPVC8eHyV X-Google-Smtp-Source: AAOMgpd50xNgRF+IOuxcIAZWnShhzAzlY1f/odV6lKw52W15A4FhYRbYOVLupV2cABovqEnpuAIXFg== X-Received: by 2002:a62:3b89:: with SMTP id w9-v6mr15406136pfj.80.1530481499150; Sun, 01 Jul 2018 14:44:59 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:28 +0530 Message-Id: <1530349239-22049-25-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.48]); Sun, 01 Jul 2018 21:45:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 01 Jul 2018 21:45:00 +0000 (UTC) for IP:'74.125.83.65' DOMAIN:'mail-pg0-f65.google.com' HELO:'mail-pg0-f65.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.65 mail-pg0-f65.google.com 74.125.83.65 mail-pg0-f65.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 24/35] 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.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.25]); Sun, 01 Jul 2018 21:45:23 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- src/util/virjson.c | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 92f3994..82f539f 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -496,65 +496,50 @@ virJSONValueNewNumber(const char *data) 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; + return virJSONValueNewNumber(str); } =20 =20 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; + return virJSONValueNewNumber(str); } =20 =20 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; + return virJSONValueNewNumber(str); } =20 =20 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; + return virJSONValueNewNumber(str); } =20 =20 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; + return virJSONValueNewNumber(str); } =20 =20 @@ -1171,10 +1156,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 +1175,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 Sun May 12 10:15:23 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 1530481521927948.2573516684874; Sun, 1 Jul 2018 14:45:21 -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 AB18AC059B7F; Sun, 1 Jul 2018 21:45:20 +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 6EAA452FCA; Sun, 1 Jul 2018 21:45: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 20A8624F5B; Sun, 1 Jul 2018 21:45:20 +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 w61LjIHe009516 for ; Sun, 1 Jul 2018 17:45:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 34C9186F95; Sun, 1 Jul 2018 21:45:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DA7B86F19 for ; Sun, 1 Jul 2018 21:45:13 +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 84005C059B7F for ; Sun, 1 Jul 2018 21:45:02 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id q14-v6so6196121pgt.13 for ; Sun, 01 Jul 2018 14:45:02 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.44.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:01 -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=L8kGehXgvwdlsF1kIazBHRKiH3s4jscaFCs8JxSc8zc=; b=m+kMdpnUfCBQQXRmt6WVp7tujJjcedfDIeZotisDWJoBellEoWLIrXRvmzTqmmZkCx DBCrfoJQdIZhp8yZxV9aXErQwsThd6+FpG4Ou90H0SInIssuJxr/nMj6iF8gN//pKFZI YKXx1qEY4+iv6myZ3o/+s4LV4DvzwfBexC7M/tuNHv25L65EpAhiINXh/3MtW4AnWl57 O4zhhjDCoL5F6NcJbxsfrzTKUF+1R9EDhVcTtoWHo5cnI8/rcPPCeHOfQCjrlclFrLR7 vbOO9rlMlLad0rhHdnpXEzrzgsnicy4Fdmv1drOU+9TvT/lQN38kxBIkvlkdeLHHmtj+ hlig== 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=L8kGehXgvwdlsF1kIazBHRKiH3s4jscaFCs8JxSc8zc=; b=N1TWH83lMw3MhS2vBISPclMl6XycpHmXZhxODeog2Jn50u+6MB+C/oa80T4TM/S3eR dY5j94ySFcW4fxTZBJ2qPiMLvXIXe0mxfEJO8jZ9O+uH0uA3nuEDPPXU9LVm7eVKed6C YA6kODukNIsxpTGNeDLA0DKRxmknDgjbkztjvtBio3Wzealjmak2SeX3fr4xgLnwU+B5 hLKEXHjJJ9J5KlUWX28eh3jt0HBIUyU4hX7EKEeE+DABUS9E+MipNvkoeIzN40oFNlJD n0gF5DIDl0sSuUpGzpaPnmcPn6/LZ+N3YJ1cPAgkYWNEmZ7yOfxLnbf2IF8PJWn1fuyU xzjg== X-Gm-Message-State: APt69E0OWOEBqsgAbbUmSaUkzyqQi1SxXQk+VFTM7SqqegTYFW6WNR5N ga/fyC6+oDiQv68fF9TlCsASUBy+ X-Google-Smtp-Source: AAOMgpf6TTsOxFZuKKwmIPVEB1PSoOKcmXseeghuPw8MdXwmVpogvKPSXTxO4lwcjFTvI+6qK2l2wQ== X-Received: by 2002:a62:e03:: with SMTP id w3-v6mr22851834pfi.173.1530481501726; Sun, 01 Jul 2018 14:45:01 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:29 +0530 Message-Id: <1530349239-22049-26-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.32]); Sun, 01 Jul 2018 21:45:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 01 Jul 2018 21:45:02 +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.766 * (DATE_IN_PAST_24_48, 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.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 25/35] 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 01 Jul 2018 21:45: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 GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- src/util/virjson.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 82f539f..29530dc 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1786,7 +1786,7 @@ virJSONValueFromString(const char *jsonstring) size_t len =3D strlen(jsonstring); # ifndef WITH_YAJL2 yajl_parser_config cfg =3D { 0, 1 }; /* Match yajl 2 default behavior = */ - virJSONValuePtr tmp; + VIR_AUTOPTR(virJSONValue) tmp =3D NULL; # endif =20 VIR_DEBUG("string=3D%s", jsonstring); @@ -1850,7 +1850,6 @@ virJSONValueFromString(const char *jsonstring) jsonstring); else ret =3D virJSONValueArraySteal(tmp, 0); - virJSONValueFree(tmp); # endif } =20 @@ -2023,16 +2022,12 @@ char * virJSONStringReformat(const char *jsonstr, bool pretty) { - virJSONValuePtr json; - char *ret; + VIR_AUTOPTR(virJSONValue) 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 @@ -2121,7 +2116,7 @@ virJSONValueObjectDeflattenWorker(const char *key, virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json) { - virJSONValuePtr deflattened; + VIR_AUTOPTR(virJSONValue) deflattened =3D NULL; virJSONValuePtr ret =3D NULL; =20 if (!(deflattened =3D virJSONValueNewObject())) @@ -2130,12 +2125,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 Sun May 12 10:15:23 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 153048152946042.609438822615516; Sun, 1 Jul 2018 14:45:29 -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 5E23830820D2; Sun, 1 Jul 2018 21:45:28 +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 2089A5C545; Sun, 1 Jul 2018 21:45:28 +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 C24A924F12; Sun, 1 Jul 2018 21:45:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LjLQn009541 for ; Sun, 1 Jul 2018 17:45:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id A058A6090A; Sun, 1 Jul 2018 21:45:21 +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 94C3E608F8 for ; Sun, 1 Jul 2018 21:45:17 +0000 (UTC) Received: from mail-pg0-f49.google.com (mail-pg0-f49.google.com [74.125.83.49]) (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 90C3FC047B63 for ; Sun, 1 Jul 2018 21:45:06 +0000 (UTC) Received: by mail-pg0-f49.google.com with SMTP id e11-v6so6212699pgq.0 for ; Sun, 01 Jul 2018 14:45:06 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:05 -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=JrB5eyBCUFZaXVsMEQimhXJfs9e8CSX4i+J75Me5MAQ=; b=B0oq76N9UaZvzuD9WfTWAyBJcAOqtP3oW58H3qQ3SmzsnOMW+x99lgviwPdxgL9vld ucI2ziiTiympWwUTSqv9+s9MN+Z/CjGITZDYR7YaxKc/GG1VMqZt2B3ML8Cl2XY5SX7U p3BNBLqMERTopcwU1XW7QPXha48YkpnGPweN8+qICJQSYGJkspbxFNzlEY5dMUs/8JT8 t1UeDqVsJTLI/zQAg5GV6DAtlMur3xaJ1sAxCFotQqSb941QN8N8dvMDpj2dMikCzoPM M0YzsFSz84jgEDQ3eZbhbyCke10HDOBEuKtRuJ5i5Bmt9iLkpxjBmmPhZEaNrQQ+dwCI 6HUw== 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=JrB5eyBCUFZaXVsMEQimhXJfs9e8CSX4i+J75Me5MAQ=; b=AuvOFzUGm453rfP8S7QILPCLmp8Lbci6+wWSyAPPNVzVPQxiy3JIW8hvzK877VcJyu hD0CNdYqQ+LVcSLXpPrmBMwc958ZgSTPHPFD/O72CqFn8+3wtZXdCfr+SkJMIyB7Ao2I bT/Mbb1lfzqH9jPeEKbtrcJVFHuY+GBQuIAGztsAwrUhjd1HqtwO8YQPL+PsaILRYN6/ LoKvV6HIjQrtxPTY0ZGlq74r9D4z1+8Ze4m9I9bJ47oaFG98SnZZ520ibKXIAng/DRnG M8nUCFHrKB4Ow5Miobn7dFJM/uq4h3ZJvxQHhWFlg6KeW78PUfXUgzKzXTlrLMGqRvQh zIuA== X-Gm-Message-State: APt69E1UDtv1GNxSDrkabzd2KOwutEXJMFEmY9auU1Okk93wz17/gUza Db9k9EGZsBujv2THk+Ju0WxnNoS7 X-Google-Smtp-Source: AAOMgpf0Uqk+YEb1PaY7QJt4OhAlt/9TGtd7LOWp67w4/fkl4m+iCugTCroirZQEPiFMinLTqu/Cqg== X-Received: by 2002:a62:3783:: with SMTP id e125-v6mr22744780pfa.232.1530481505826; Sun, 01 Jul 2018 14:45:05 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:30 +0530 Message-Id: <1530349239-22049-27-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:45:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 01 Jul 2018 21:45:06 +0000 (UTC) for IP:'74.125.83.49' DOMAIN:'mail-pg0-f49.google.com' HELO:'mail-pg0-f49.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.786 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.49 mail-pg0-f49.google.com 74.125.83.49 mail-pg0-f49.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 26/35] 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.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.47]); Sun, 01 Jul 2018 21:45:29 +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 new 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. When a variable of type virBitmapPtr is declared using VIR_AUTOPTR, the function virBitmapFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virbitmap.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h index 2464814..312e7e2 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 @@ -155,4 +156,6 @@ void virBitmapSubtract(virBitmapPtr a, virBitmapPtr b) =20 void virBitmapShrink(virBitmapPtr map, size_t b); =20 +VIR_DEFINE_AUTOPTR_FUNC(virBitmap, virBitmapFree) + #endif --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 12 10:15:23 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 1530481534699806.786196141845; Sun, 1 Jul 2018 14:45:34 -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 97B193082138; Sun, 1 Jul 2018 21:45:33 +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 5818016BE6; Sun, 1 Jul 2018 21:45:33 +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 D9740249A6; Sun, 1 Jul 2018 21:45:32 +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 w61LjOYe009561 for ; Sun, 1 Jul 2018 17:45:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E321171BC; Sun, 1 Jul 2018 21:45:24 +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 841A3171A8 for ; Sun, 1 Jul 2018 21:45:19 +0000 (UTC) Received: from mail-pf0-f177.google.com (mail-pf0-f177.google.com [209.85.192.177]) (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 C203B308212F for ; Sun, 1 Jul 2018 21:45:08 +0000 (UTC) Received: by mail-pf0-f177.google.com with SMTP id y24-v6so2272206pfe.12 for ; Sun, 01 Jul 2018 14:45:08 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45: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=LfJcwky6ZyTg/9k5/HgNpSYuytXJxPBZEVoPk4WePHk=; b=QhBmUNkdWEH9ja5uOQ9Klj1ZvbFu0NzAJZgHXJK7YUZlWn3ksRBk/SPoKkjZw1dg95 A8Mwbv+y4oKly34bz78KkoSfZLZ4WaThCSPpBTlfn69qZNYhkSbJ3DukN8TaEiT9TwxW 8WZNccIL9vt7bCM5Vm/echsfsagz4KjEI+PmZCGwwp42DMNFVwZDdKWxYuIUhb0VP5g0 TJawsys2XLuZDMdyNvnUDdhokKgd07PaEtImKAI2cIyvXcDlmRiIfEKnv5lYYH4UwER4 buC6xt0T35XoWvhLa8zl2x+7CP3L1Ii46t6z1rB9eJM120qoDAfCKviVHVMT8lkw+dID wDag== 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=LfJcwky6ZyTg/9k5/HgNpSYuytXJxPBZEVoPk4WePHk=; b=oPr/VsiEPWUmPCXpstgiEcRBHNVph8geE4hnrYbjjhArHw7G5KE1pbdO+IG/r13yEa eC4yTzEFNwO4kcifny9qv6GBID73iLZS2fGtCTcrI4RU5iR8jVq70ItjKD9JjHjquoX+ tlyshwU128x7GolO7oX9ikS+DT/XwI5wgJFMcxyHlceX8K8F5Ipnt81dpmTDy7JOjpqu TK99MH0vK0J8gqqDbf7mWVbhEy6vgXAzsPwKkTFMtD/2ve+j98Tdsntsw83IMdzmbjOv DZamh15VXhGfnoNLLdHlrlV0+xmVdA8DmKLeQF0Wo9WcvniHjdmwo2qQQNFdaspVWnh0 djVg== X-Gm-Message-State: APt69E02DFGJvQw8p1ZYkLxsoTKJhAerAEluMl5GCyr9sFGwMoQADGkQ QYhh/eC2lq9KMSbkPLcWlpA1jnzX X-Google-Smtp-Source: AAOMgpdMEuSXbCgyRRTny+xW0TIFwYZzPq8KSZPYC/E6LtV8Wd0X6LnIeHMWFfF4gnb6UGhO40dHxg== X-Received: by 2002:a62:4b48:: with SMTP id y69-v6mr11598460pfa.93.1530481507991; Sun, 01 Jul 2018 14:45:07 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:31 +0530 Message-Id: <1530349239-22049-28-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:45:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 01 Jul 2018 21:45:08 +0000 (UTC) for IP:'209.85.192.177' DOMAIN:'mail-pf0-f177.google.com' HELO:'mail-pf0-f177.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, 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.177 mail-pf0-f177.google.com 209.85.192.177 mail-pf0-f177.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 27/35] 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.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.42]); Sun, 01 Jul 2018 21:45:34 +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 a previous patch. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- 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 Sun May 12 10:15:23 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 1530481531117263.3442383713294; Sun, 1 Jul 2018 14:45:31 -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 040C75F72E; Sun, 1 Jul 2018 21:45:30 +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 B517188110; Sun, 1 Jul 2018 21:45:29 +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 688E624B76; Sun, 1 Jul 2018 21:45:29 +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 w61LjRMW009587 for ; Sun, 1 Jul 2018 17:45:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3B17E174AB; Sun, 1 Jul 2018 21:45:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30DD217481 for ; Sun, 1 Jul 2018 21:45:22 +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 8F0484901F for ; Sun, 1 Jul 2018 21:45:11 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id q14-v6so6196217pgt.13 for ; Sun, 01 Jul 2018 14:45:11 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=d5+PZLYwJROzNEskpQwuv7/Ngbsq2FlIf/xjzQvdr5w=; b=aVw9z8/5QPSsGoFkAPJftjWcoPs05dv22MJgAYaJjHhoXMt9MIwFyaG8Rph9QY+t0f b+bxa9cCg1I7yYsDSKoJARyeyBLRrcknP/Dk14kNFiWz6YieNz3NZ15brgc3LPEXinrR NSIUB2F0WK4RRcuaBXzrhKHWsgyHgK3gSRFI/XIhRYH/bJEktQxgO5GiPi1aHlJmyIDZ XkdFn9rNsNuEYwH4CshVieuMj2ijNsdhivrnbsOQHld8Ub7Zevn1d3ddRHDRGKXy1Qzs hpZFE6zhgSZndd2S2McM0vIjGmeJAsJ7vZtzyur9Pyc3M818jNtdIkERA5c5KLSeEjG/ zLiQ== 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=d5+PZLYwJROzNEskpQwuv7/Ngbsq2FlIf/xjzQvdr5w=; b=I6yP7Moxa1iJVwW3dT7l+jx45a+2OOQgouiIFI6iJVYS9JwnLgKjWWnTXHxdRP3ywo rkHEYkMBVg7IfrInrbtEj2qMahcagD/n5nrEQmXU+zWypV1vPzdRFyqXdIAOOFHidOSf iu/vEFFpfuiPRjyJXw15Fahuf4tR6O4ifuYLI1NlvCoXWqyzTvTmvrszDY+i3XPVsJJW CxJvysr87clUdJ1wg0lepOUaD+8C9ZY59S/gDHJZVjxoAEufxMDvJ1Je0PWCvRwrdozX 6uMLdP5KGvp7z6gsRGtd8rTnKmN5DaPBcnj/ebAw81c546QWQgUyP8oOx7rBfhg3CdUT 4JAg== X-Gm-Message-State: APt69E3MpJd0C75BIGmZpw0lGRXBOxS8akSUSBU5I3s08iWXQ6oNkFeO z+36KOIAaBvxJVjrd+LwxmfXpSQy X-Google-Smtp-Source: AAOMgpdb+UI0KK5FJF95SeR5EPxj8A2zU0D7a9tKLkRH3DauqDyvTUOlULYef/hC+XZ+0XzQ2sCn7g== X-Received: by 2002:a62:4308:: with SMTP id q8-v6mr2942291pfa.86.1530481510833; Sun, 01 Jul 2018 14:45:10 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:32 +0530 Message-Id: <1530349239-22049-29-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.38]); Sun, 01 Jul 2018 21:45:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 01 Jul 2018 21:45:11 +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.766 * (DATE_IN_PAST_24_48, 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.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 28/35] 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 01 Jul 2018 21:45:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virbitmap.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index ef18dad..5b6e55f 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(virBitmap) 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 From nobody Sun May 12 10:15:23 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 1530481539658787.9425575941419; Sun, 1 Jul 2018 14:45:39 -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 7ADAD30820D3; Sun, 1 Jul 2018 21:45:38 +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 44D1F60BE3; Sun, 1 Jul 2018 21:45:38 +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 ECA171800CAD; Sun, 1 Jul 2018 21:45:37 +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 w61LjRMY009594 for ; Sun, 1 Jul 2018 17:45:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4DBC81001F5A; Sun, 1 Jul 2018 21:45:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 401461001F41 for ; Sun, 1 Jul 2018 21:45:25 +0000 (UTC) Received: from mail-pg0-f50.google.com (mail-pg0-f50.google.com [74.125.83.50]) (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 AD252307D847 for ; Sun, 1 Jul 2018 21:45:14 +0000 (UTC) Received: by mail-pg0-f50.google.com with SMTP id i7-v6so6210451pgp.2 for ; Sun, 01 Jul 2018 14:45:14 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:13 -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=c80o36F8JCeGv0Mh1VaQytM8dCfW7480fny3RIAKNdo=; b=Luc/KQrNSri+qemo73TKyFl+ewOJ1Hd+GhtECBN8atjRpAZjgnPLmvP18FkPU4/xLL xCULiUQzWTIa+pX1IWNmvAhK1bEGJkyc1ZeuVwG0LIzybFnCXeWUg9iKVONW6e4B/0St S+oH4XoLqgDyNZ2WGGHoJz1cTWWVcKt4H5/qPZlPNB5AVFxh+tkpCXJ8gzVo24xVeJkK ZNMCwy6JKpYTv/bnl7LFoYlZjENmfVYHKinO+2r3KOD5dljTDbxwt16mVvLYzop7reoW 0npTE8pKC2svuAJ6ci7ljOBCGtAPYYpfoma7gtdcr8LGv6FD8XNfbxKrH55PlgMTrEEQ abWA== 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=c80o36F8JCeGv0Mh1VaQytM8dCfW7480fny3RIAKNdo=; b=L7baSEpblJjiX9Efvw3dfgvaki7hcUuLhCkcHQWYGdPC4pMbu8fNsLFya9PfHz7SHm VE5zgonIcn0flcNykwsKvvRCFUq/rBkaOYA1s+5V2vNw8qUmdb6jwAM6BuxIOQWTQ3Lt h+7nzMm8XOsvJXqNVYUXlh9yBFKYQACfPRNrRYMKbjUfTysm9HvnNrxun8ZpYKmTSjmP ZzYcRjjuUcCMmWAMy6hhXwTzPiWlBb2qBWDN1uIZInO6tOfuSOiprYHnFxQJeff1Hl87 on4N4v6vGvb25xdCV/rHJGsvhnpxhGcc9R6QeO6EB8MMz+bx98qi9WIYK6WWIIUokyNQ OjEA== X-Gm-Message-State: APt69E2L9RAMzYHzy2sa8IEYo/gHACSOn6AAOcWMNlzczwt4joLapkIZ V4CHU0ZFtUGiL0gfyyqE3Pcl4yeF X-Google-Smtp-Source: AAOMgpfMI9mkUN+9LVa6CH209efrMfyOd6JZmewYqzfj7R20FD8WXpPUgHagHkwbTQfXN/lFNRRLvw== X-Received: by 2002:a62:90d4:: with SMTP id q81-v6mr14041994pfk.37.1530481513908; Sun, 01 Jul 2018 14:45:13 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:33 +0530 Message-Id: <1530349239-22049-30-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.48]); Sun, 01 Jul 2018 21:45:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 01 Jul 2018 21:45:14 +0000 (UTC) for IP:'74.125.83.50' DOMAIN:'mail-pg0-f50.google.com' HELO:'mail-pg0-f50.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.786 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.50 mail-pg0-f50.google.com 74.125.83.50 mail-pg0-f50.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 29/35] 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.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.47]); Sun, 01 Jul 2018 21:45:39 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/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 Sun May 12 10:15:23 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 1530481545052133.8545145033147; Sun, 1 Jul 2018 14:45:45 -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 F0772C059B7A; Sun, 1 Jul 2018 21:45:43 +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 9EAE24B7; Sun, 1 Jul 2018 21:45:43 +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 2EA10EFD2; Sun, 1 Jul 2018 21:45:43 +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 w61LjRqY009600 for ; Sun, 1 Jul 2018 17:45:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id BAAE71001925; Sun, 1 Jul 2018 21:45:27 +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 A9888100164E for ; Sun, 1 Jul 2018 21:45:27 +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 D663B308212C for ; Sun, 1 Jul 2018 21:45:16 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id j3-v6so6524985pfh.11 for ; Sun, 01 Jul 2018 14:45:16 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:15 -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=aRUeMHF/7MrFY/oGmg8WCmEp385Hz8Tr71SDIPyUS5I=; b=F/n4Ow54SSgz4pv/IrOSVmx3+ixsh8iIm1pHeSzFoem/x5JoAi2RUJwCnPvhAe/whT x4J8rwIOl+zcL/WS41TZkMrHsHpdwlbhts1au3xSzqjJC4GnrT52y6Lx1Lcc6bsp84+r A4/oBAOB1gRasom+mI1Qrzx/uwJ+jor36xrPE+MHQEhfQEMG0X5Hv80HBxaCSaWbdrl8 6lcRBunw/EiWly6Dzz63xVyiI3hDbXGK/pMf0tsrcWEDeS5TuuMMJyuTcLdHnMmaNBTX VQz9qvpQIsKRDylaJ56OoMWvBnjq3Ee3jiivgpwHXNviKd194AzsNuMCYysnsRiM0Q04 448w== 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=aRUeMHF/7MrFY/oGmg8WCmEp385Hz8Tr71SDIPyUS5I=; b=LKTm4iG80u/vbNhbyFHCE/ZD1EOf/ownQQgv4+E3EsbRZ9D5VQQ8XKY1RZjnRdrd9w QCJDqO3vu55bscErLQZaFyKjjoHEpHUuVYyFrIN8kXBoHezAeIvh72pOPNdRjqrjifce QDl/0nFdtN4yH5TrxXLOBeU6KowXXvANJbG+bkQgUh+YfGvkGi8yIGAnALypTnqNeblW u2g4J5CkSa4QP5oQ4DaAAZMcmXWAMfj7i2tNbz+NQhJ6wkLT1rHbWRryw9qSwXBeeu0H wG5yoExCYrvhgVJBd+/e2nG4DnUOKcDiZFsSaR9LQ1qOYQAZoV19h+4AEOYtXYfxdGzV etMg== X-Gm-Message-State: APt69E0Oa0QjJIpO1G+SnWqoJ1MIGkmg/5hN5KiS/PCdOdyFLbGTivFU c+gPW5FVF9WGC0n6gwSizEGsIVSo X-Google-Smtp-Source: AAOMgpdQiOcSRBGIzPyiyukZ4d7dc3cVCn7uKljflv3pdDDkry+pzgLpnDBFr8zXAnmsBI7K+swauw== X-Received: by 2002:a62:6a01:: with SMTP id f1-v6mr6239366pfc.156.1530481516157; Sun, 01 Jul 2018 14:45:16 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:34 +0530 Message-Id: <1530349239-22049-31-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:45:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 01 Jul 2018 21:45:16 +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: 1.785 * (DATE_IN_PAST_24_48, 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.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 30/35] 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.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.32]); Sun, 01 Jul 2018 21:45:44 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/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 Sun May 12 10:15:23 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 1530481538843136.44281196107204; Sun, 1 Jul 2018 14:45:38 -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 D23EA3082A49; Sun, 1 Jul 2018 21:45:37 +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 9100F5C6C1; Sun, 1 Jul 2018 21:45:37 +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 3488F24601; Sun, 1 Jul 2018 21:45:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LjYEs009667 for ; Sun, 1 Jul 2018 17:45:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 06795308332C; Sun, 1 Jul 2018 21:45:34 +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 F2E9D30C43AF for ; Sun, 1 Jul 2018 21:45:29 +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 2E41D80F7B for ; Sun, 1 Jul 2018 21:45:19 +0000 (UTC) Received: by mail-pg0-f41.google.com with SMTP id n2-v6so6207885pgq.6 for ; Sun, 01 Jul 2018 14:45:19 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:17 -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=4qHGja3bo5OuimEyhJ5N9gK7bmu+Wargau/y77zFPh4=; b=gG5pri0Jg/rrw50dnVUwKv+itXTaRGQZV4kDTy3tI5cK42btqPo9VhVq3fOMhlELzC 84J5VdFemUypHrLn8345W9bmha5/zVpb5xWYKAage/apf3UFsWF8vQSOwVk4I31MvtFK D54F4TloJBwu56dgoi4ohTtZQUnByzpS6qS5LnF2w/PIN2KOC+VIjDpTZejxj84UCxmy 7xyI+2t+dU8leu0M2tDTUpcuyXZ7EPCJaZAuCYu8IzWFaWDfv0WjaoQ/np0kcs+GXupG uaBku4VVzPLJlDGG3OwbUIiYgzHTEMdBfG+DQ2UeCWK045OMX3aKXnSF4mZKCFF7AQok rXTQ== 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=4qHGja3bo5OuimEyhJ5N9gK7bmu+Wargau/y77zFPh4=; b=NYqR3FwR08wqKU8E7AslmPtrarpE5vKbCf3yvB1f2V8koM2ZvjI6PTZly5qsjdVZRq 0joWhKEFiY6991nycbFSjq4rEzadLDAY/LC7QkU0bfpq+qEYbjwNKYcr7s8ORVW7c+Qk SrkGoaXz1M4qd2eJcDzGfmaGDB9rfS3B63og6OlgQEZvFg0kU7Poa9QwYjiMvdgBLIc1 Sh2KDwSeSeoogGl0H6MCzVDW+J3iw2D+OBiai58XZjueMuLrxj+QQwcXsZnDzdBgnTFn 7ncHWa+ebUs4FzUlnwdPnlhl2pPn4hVsqEvE8RJncYXExxIVPr9m7zMiBcbsyVYgAQLh 4c4A== X-Gm-Message-State: APt69E30/nE+jZQJDTJVh2wrYaUVBfKKg4/wzT0UMyhqqD39od1zO0/5 mC4wsaqaQ4Wiu0otFY/S2jmN61M6 X-Google-Smtp-Source: AAOMgpeOybXArxppVPuuBPQN3YqoXSI7iZp0l1ACLLnd5nV4j0fi/EPszUAhZond10HXzKHT53nzUA== X-Received: by 2002:a62:d09:: with SMTP id v9-v6mr22521828pfi.163.1530481518407; Sun, 01 Jul 2018 14:45:18 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:35 +0530 Message-Id: <1530349239-22049-32-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:45:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 01 Jul 2018 21:45:19 +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.786 * (DATE_IN_PAST_24_48, 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.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 31/35] 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Sun, 01 Jul 2018 21:45:38 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- 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 Sun May 12 10:15:23 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 15304815445841005.5250411173263; Sun, 1 Jul 2018 14:45:44 -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 4641D80F91; Sun, 1 Jul 2018 21:45:43 +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 0268F308BDA5; Sun, 1 Jul 2018 21:45:43 +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 65678245FE; Sun, 1 Jul 2018 21:45:42 +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 w61LjYTT009679 for ; Sun, 1 Jul 2018 17:45:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C097308BDBC; Sun, 1 Jul 2018 21:45:34 +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 72BBC308BDBB for ; Sun, 1 Jul 2018 21:45:32 +0000 (UTC) Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) (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 51249C04AC4C for ; Sun, 1 Jul 2018 21:45:21 +0000 (UTC) Received: by mail-pf0-f174.google.com with SMTP id y8-v6so6528428pfm.10 for ; Sun, 01 Jul 2018 14:45:21 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:20 -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=IJSR/J5eHqR3zCxPH+ThM8bw0XEoeOMsSCZuN7EsHCA=; b=tIGjef1LIWZye7yFvuSq3VyQ/aEv6QH3T6/uRT3TY+Fs4b4BbzEg07DtImamCy6IBS Xj39q/DbLLxxX1gy8aC1KaIFm7E5J9XgLM29kUozlbh1f5reQBgo/98WnowAE4uuPhYc mi1qc71J8xfAS3E+uGQj0URJsScBQ2EmI9AxNe+t+I9zK2WMfItDeIRkPLxlsCPJRJ6I zyN4IC4RDkW+iraFVVXwNsEBK9l5fmAUFcnrcdEIVjqBNP3poBQFCtu8hJYYTNmqMTIE Dm/U5JdKQ2JiOw0+iw2yn/M02yF4oz+bl1HYQyDU8ymEL5z4VSDIlnuLkCw3Aa/4fmy1 4FPg== 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=IJSR/J5eHqR3zCxPH+ThM8bw0XEoeOMsSCZuN7EsHCA=; b=CLDNNn7sEhEnLdLy3VuXG7om4+BCDgKrzBq+2dRUYriIgqPEkwkVzQUUTrRdyVSA1i RgZ9q645/aE3vhdoKZc9a/RdOUSM0e5cQaIkH8JwgghugVbL2sjPmXoLFpsoC6V2q0Kd O87MFR6805g0nf7q2CzTWFHzAsQbKM8Hhe7vPJoVCdjjrcCXPCAGw+l8jV5JH6Kg27e2 +A9DUsM18rU5UdLPZ7AY0Qvz/UAk08N0zXTb6MAoqVKTyAv7eobS7PZkFWcdm0M1sChc edPRBRV1mullSsMUm3/yvFxX2Gnd6OqOqe/c1sTaZzTzwT1hwgRdy++ytxM2kpStThdx Zj9g== X-Gm-Message-State: APt69E1YHmkY5AeycnLPTfXsTpwUXqEYk5pB199JIC/4+4F3fD3/m0sm 0yQIzaXGHv01eNhxL3zh744EpNd0 X-Google-Smtp-Source: AAOMgpf5xFViOVh5bELNmISSVB7thXy7hwxOrO+A7rnLvgltGgc39AeqJlrWwFdIuIKtr3wuPAJfow== X-Received: by 2002:a62:8917:: with SMTP id v23-v6mr23062121pfd.127.1530481520503; Sun, 01 Jul 2018 14:45:20 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:36 +0530 Message-Id: <1530349239-22049-33-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:45:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sun, 01 Jul 2018 21:45:21 +0000 (UTC) for IP:'209.85.192.174' DOMAIN:'mail-pf0-f174.google.com' HELO:'mail-pf0-f174.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.786 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.192.174 mail-pf0-f174.google.com 209.85.192.174 mail-pf0-f174.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 32/35] 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Sun, 01 Jul 2018 21:45:44 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- 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 Sun May 12 10:15:23 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 1530481550676283.18148057866415; Sun, 1 Jul 2018 14:45:50 -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 2B677804E9; Sun, 1 Jul 2018 21:45:49 +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 D8C5560BE7; Sun, 1 Jul 2018 21:45:48 +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 8D5041800CAF; Sun, 1 Jul 2018 21:45:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LjYGB009690 for ; Sun, 1 Jul 2018 17:45:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id D2DAF6090A; Sun, 1 Jul 2018 21:45:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C881560851 for ; Sun, 1 Jul 2018 21:45:34 +0000 (UTC) Received: from mail-pl0-f50.google.com (mail-pl0-f50.google.com [209.85.160.50]) (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 A17155F740 for ; Sun, 1 Jul 2018 21:45:23 +0000 (UTC) Received: by mail-pl0-f50.google.com with SMTP id t6-v6so6949056plo.7 for ; Sun, 01 Jul 2018 14:45:23 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:22 -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=m3/gUvx0MnHb7L72ql0Ea3uygNixqYb3QCGyn8SKFl0=; b=vWVYvUgs3mOd6oEzwr+W6JBkAwModOMeTpgTxnH9K6bZkWnsGjBDMOhZi9z4YaUz/y dU23e1yjx2hL5hMbVuNwEIeRgKKKmZS9+7pEz9i5WzXXROE2l9MxO8TpUGl1ps3Mr4Ku 1mLSDyAUhIpZIB3bX32m+9iDPBqBW/CNi0SoTbmr8ZDWS3TUSDxzHjunpWxIUxnvvtCW GAG6x3N8uVEtgIscJAeIoxwahIKFHmBxsU+dW+F/47wQuHwgXnltlGwQ2paydwpcRAkp YFABtyFCcSeRvHyVcIoN9a2tQyOQK9sJBPVAha6aPkJhLH4gdgivhzTHTg7sljK11MMS 5H6g== 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=m3/gUvx0MnHb7L72ql0Ea3uygNixqYb3QCGyn8SKFl0=; b=BJfmkzSsInlExNtz/nJAr5ui4tTpW6gCt7DGJzrUuqXSh/aOmYyGAcnu/AHcemVQ3l 2L+MVbJ69bDo867jYBc3yhk5mdoBy7jr42hUVoKdPn2SjcSSoanNDUFObKIc7Vdi+W7h riwTzXHkpCLgASPcDODbeOEoc4xXGLZA4rOBN95G+bMtca0c/sF2EqsWZz1ogQnpeEz+ 39JOD280uY1t11FKelzg8uYgzxHim8PVnkXCKbt6aUM2HuUF0oGBHnDRrSB31WgP8vHp TvIDJjvd/wXwaZyzBXQBuqIPnsrp6J5xmJEXvzQo02D8DuoiMQwpQcZ6AZetXg3SjEZs 97VQ== X-Gm-Message-State: APt69E1Gmxbj4IwGnT3r8pC8wB7aN7XpLjjvWobeuixeqo1xoElFQghu TI9QHVdQMtpJwCrl0a1emkpOiOFN X-Google-Smtp-Source: AAOMgpe1v1JcBAy7qLx1Yy1kY1WmhbGDM+JkDUgzTyG+ptzT02IIZhGA43chUbLIK1/oGEjGbTrpBw== X-Received: by 2002:a17:902:528a:: with SMTP id a10-v6mr15213934pli.73.1530481522944; Sun, 01 Jul 2018 14:45:22 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:37 +0530 Message-Id: <1530349239-22049-34-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.39]); Sun, 01 Jul 2018 21:45:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Sun, 01 Jul 2018 21:45:23 +0000 (UTC) for IP:'209.85.160.50' DOMAIN:'mail-pl0-f50.google.com' HELO:'mail-pl0-f50.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.786 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 209.85.160.50 mail-pl0-f50.google.com 209.85.160.50 mail-pl0-f50.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 33/35] 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.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.27]); Sun, 01 Jul 2018 21:45: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 GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- 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 Sun May 12 10:15:23 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 1530481550736580.4133373534012; Sun, 1 Jul 2018 14:45:50 -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 9EBFF3084031; Sun, 1 Jul 2018 21:45:49 +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 6145416BE0; Sun, 1 Jul 2018 21:45: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 EDAC01800B68; Sun, 1 Jul 2018 21:45:48 +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 w61Ljdkh009734 for ; Sun, 1 Jul 2018 17:45:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BA5460C8C; Sun, 1 Jul 2018 21:45:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 944C660BE3 for ; Sun, 1 Jul 2018 21:45:36 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.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 0F1BA307D859 for ; Sun, 1 Jul 2018 21:45:26 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id s24-v6so6942884plq.6 for ; Sun, 01 Jul 2018 14:45:26 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:24 -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=HJ0k1Mx3lDcW/X1DmXpucpaAmDjb6UGBMBKbJgTfroY=; b=NsTFXBHnGbOyc++ucQxvpDemHwJej88WOBRCos3NoxeWTASUsav6kerYz79xnymqBw ZfQ55ybqsV3BY8a3MrSwd1CA6IfHbeo/8Ch1OtzkfWfNB1JauOpY+2ljDAdJNKwmnHTG VtaI9LG0s7wzxapRGDnEpDdF1IvRIf+RLNlSoYPJMXGOctl/qwkHr3eWb6DPf01Zh7/H 9zhYEqtOXswVIMeKoURMJnWgyX9Tc7t8mN5KX6wZUJxAlM5QN7yZpXYRDlUfp8G+Y8Qg 2kUvTxHq8iOgSgzjZJIIawmTSmxvb/+xEkXX6Ix0CM54YWTiOJFoTwiD/zInbWIkQr7Z 1gOA== 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=HJ0k1Mx3lDcW/X1DmXpucpaAmDjb6UGBMBKbJgTfroY=; b=eW0/BURlVs6cMg7UBAe58uWnMw9F7oiUgihdK3fT0TFyAMZZHDT6FlOBuIrIsS8mD1 eynrJ4nu4wSGrOfvhRgu8swodg7CRVF9NyT/4FLJ9HDJqRZyDLAGF9IEwffMqdr5UX2P OhaJ2H0O2fhFw+Ijk/tS7n1rrL0gkSPCYA2CsXI3GS3Lt1nFZ8eepA7WiGL+SqjABD6x +vaaQsUSx3RAIZv4Bevmz6S1QB64gn8xUROwTm1Dy7bevukzbXSLHO0HHRVfdDqVzwGr oijsyo47xtxlQkFsfVryQ9tht4N66ZRRlcp7GYWhKBZMHc3iDe+dXlEqiTm97taiwnn0 wm1A== X-Gm-Message-State: APt69E19lfnn4yVD6rrVrZHdT0xQb9+V8E4JX+xiDwWbPU+yl95vnSqR L30Mrf7Ytl6PeHr6qO5hxqxNo8v4 X-Google-Smtp-Source: ADUXVKI7LbZpSb+zWNAey3iP+f9n6BJaZwu8G06X7gRt+wlaKb/5BM4xp9ihmUwrK24j72Cc7L+msw== X-Received: by 2002:a17:902:43a4:: with SMTP id j33-v6mr23388206pld.118.1530481525370; Sun, 01 Jul 2018 14:45:25 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:38 +0530 Message-Id: <1530349239-22049-35-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.48]); Sun, 01 Jul 2018 21:45:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sun, 01 Jul 2018 21:45:26 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.766 * (DATE_IN_PAST_24_48, 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.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 34/35] 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.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.40]); Sun, 01 Jul 2018 21:45: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 GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar --- 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 Sun May 12 10:15:23 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 1530481555966985.705017325825; Sun, 1 Jul 2018 14:45:55 -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 EC3DD8762E; Sun, 1 Jul 2018 21:45:54 +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 B749B60BE7; Sun, 1 Jul 2018 21:45:54 +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 5BE1B1800B6C; Sun, 1 Jul 2018 21:45:54 +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 w61Ljew1009739 for ; Sun, 1 Jul 2018 17:45:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3644260BE3; Sun, 1 Jul 2018 21:45:40 +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 945D260BE7 for ; Sun, 1 Jul 2018 21:45:38 +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 F1C5A30E6870 for ; Sun, 1 Jul 2018 21:45:27 +0000 (UTC) Received: by mail-pl0-f42.google.com with SMTP id t6-v6so6949096plo.7 for ; Sun, 01 Jul 2018 14:45:27 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45:26 -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=m2TQIlp8ao8fsMleA2Bt/rGpAdS7T4vIQMPKwZx1jd4=; b=NXUsGLm8cCM5x8/zo8NI0qddToS+XqL9s7AK4Qaw3Rw32b/93bKgyKki0GW5ZsvgBh 2MYYH/ciVIas2YLx5f8VrxxlvlwYgxiApiuWzK16jk2bM5a7MkhYG5M93iBszSg/gapV oE0Zevfy+lwk/u1wq4zFziH1bhBe2yJpgtnGLgKMJZXG0yLBsJFgSxpQvjXFp1LHXn6J N73vCh4Z4SH/lgVc/cPTU7xZCSa5ep63ZtBg83NbNdNHCHBvZV99rU8foLwyFja0pLjh UernjIVwNWLP1JvyTDNo9EXIdQc/xSRP4dY0+81Z1H88mbEU0ln7n82jT32ze7NUdM9p YkZg== 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=m2TQIlp8ao8fsMleA2Bt/rGpAdS7T4vIQMPKwZx1jd4=; b=LYCOlXtiqIiaTfEncLqGF3Nm4pQtnZOs/FSkkn8hhLOyfpWIBkd2I7iY+9f4iu/Tt0 2TzT1kWfGlPwriCxfZoXdEL5Bn7YkEZRP36OgfrCpkLqXr/GHLLlE7v6x2KsxGC1U2ND n4MRv3Z2IoxlCOXzpjubbiZQ+yqKpTqQhJYbEztxCccuTTznTtmpmPq6f+ylT5dGZtpo 5+1cU2BZci9vaseDopINcbfxt7RWKRHNO0tGbIMBivXmvYax79QQNEgq3B2gGhLRybfO JMjCDFYBtDCsNQ3BQbsJmjcn48ghM22+1vv3xAKoqsN+otbF4AP7WEUrPhO7B/q2U203 H3fQ== X-Gm-Message-State: APt69E1AGiiOO7syXYb8C/PXWljbYHUa0ufRryl/rm4Fczdd3IyZw8hs q4EuU/NNyisO9bTTeRwRgyfpZOze X-Google-Smtp-Source: ADUXVKJ+rQZPg0IjeiQ/mXE58uUho0zYZkjHta604rgcnJ6beaANoYb20BKR3BA6xkXbZbfnjj973A== X-Received: by 2002:a17:902:8486:: with SMTP id c6-v6mr23033199plo.283.1530481527247; Sun, 01 Jul 2018 14:45:27 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:39 +0530 Message-Id: <1530349239-22049-36-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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]); Sun, 01 Jul 2018 21:45:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 01 Jul 2018 21:45:28 +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.766 * (DATE_IN_PAST_24_48, 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.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.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 35/35] 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sun, 01 Jul 2018 21:45:55 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" By making use of GNU C's cleanup attribute handled by the VIR_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/viridentity.c | 52 +++++++++++++++++++++-------------------------= ---- 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/src/util/viridentity.c b/src/util/viridentity.c index 2f4307b..c621444 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,11 @@ virIdentityPtr virIdentityGetSystem(void) } #endif =20 - cleanup: - VIR_FREE(username); - VIR_FREE(groupname); return ret; =20 error: virObjectUnref(ret); - ret =3D NULL; - goto cleanup; + return NULL; } =20 =20 @@ -461,15 +457,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 +480,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