From nobody Sun Feb 8 02:21:59 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532806879225750.7928785039442; Sat, 28 Jul 2018 12:41:19 -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 168CF307D863; Sat, 28 Jul 2018 19:41: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 D3CB8194AF; Sat, 28 Jul 2018 19:41: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 87E173FB1D; Sat, 28 Jul 2018 19:41:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6SJereA020443 for ; Sat, 28 Jul 2018 15:40:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id CDAD45D6AA; Sat, 28 Jul 2018 19:40:53 +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 C4EFE5D6A9 for ; Sat, 28 Jul 2018 19:40:50 +0000 (UTC) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (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 8201530E684D for ; Sat, 28 Jul 2018 19:40:49 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id s7-v6so5075990pgv.3 for ; Sat, 28 Jul 2018 12:40:49 -0700 (PDT) Received: from centos.localdomain ([49.32.98.239]) by smtp.gmail.com with ESMTPSA id m26-v6sm20270426pfi.102.2018.07.28.12.40.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:40:48 -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=DbYzgVg2eeR82I/eW6HMe50/tSyoUWh0J0rZzcz4Eaw=; b=IOS0QQX8gzMip0f4DByNURiCXVjVbad9fYqheMzUgJlcJduIXR6Ikj0H2cStFVLiM7 A5Hvnzwq2JLdA78gtfyck3aJ8bhhZz103fGexUbbNaEK/EppGiU7kr8fYiKBLcoIG6Ar EQZ39irIIYn/CRPozyAjuFMFxl8e6z7rCHQd/cYnZ8ZiYnt85VZrO/rqKzrR/KlVIh3C oIjVBH9DMYKv50zC85MKUoYz8Y39uqfJhcP+S/XtVcYL5Kg3FD1lyYfCXOhPN0JFEpJD OOHDhmN9EZ5BNb09W5qsBUWvobofTfzpKM/y4h3Snys82Hk3YKt1aiG1NNomUWUjEFDK Y5cw== 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=DbYzgVg2eeR82I/eW6HMe50/tSyoUWh0J0rZzcz4Eaw=; b=p4hxIGqpeBZLf9H9SXUJGcJGaqCJV/3Ev06x9idJOeZAuIwYI9Q0Kk2ACu+boq38d8 iXlWXHMeOIdPB3ZsL4GG+4G5XcREYDCFbPsOM5et9GXDSEqDdvfbuoxu7tym1Z6OUp4e o8+VHCtfkb57k3KgS9tV+fY8etYwswAuIjOqiMsoJHmZYuucTL1toa+wOzsAyfctT7Ko yXPUZD0+Rn92MHOHlsaxr8IKgMBGmyJedlgrxm6SagKL97laAHVAVTVtFuF8Cw3vf+7n 1ArGBQWw0z558V8f4uXzWUijaEpWXAvnMPEVOwZ40IyBWKa2Mbd6EVBk+ExRaKnluvoN sYrA== X-Gm-Message-State: AOUpUlHIfZNYpVPsFYdoyBwTN07HwQ9PvZoGWSeVFM7LNJDh8LdWssw/ Zz0yjA3ccdmL6n4m1AQFRo53/A86 X-Google-Smtp-Source: AAOMgpeijiPhyv+Ir5oNDTY1MsbB+Cw5Bv22Ios3iwism8tcoyx1+iQU4gvswsdWE1TpHwWsIXpmjg== X-Received: by 2002:a63:ad07:: with SMTP id g7-v6mr10577749pgf.19.1532806848807; Sat, 28 Jul 2018 12:40:48 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:23 +0530 Message-Id: <1532800907-29115-9-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> References: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 28 Jul 2018 19:40:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 28 Jul 2018 19:40:49 +0000 (UTC) for IP:'209.85.215.196' DOMAIN:'mail-pg1-f196.google.com' HELO:'mail-pg1-f196.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.196 mail-pg1-f196.google.com 209.85.215.196 mail-pg1-f196.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 08/32] util: socketaddr: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 28 Jul 2018 19:41: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" 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. Also, drop the redundant viralloc.h include, since that has moved from the source module into the header. When a variable of type virSocketAddrPtr is declared using VIR_AUTOPTR, the function virSocketAddrFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virsocketaddr.c | 7 ++++++- src/util/virsocketaddr.h | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c index 5c3bfad..6b52a3d 100644 --- a/src/util/virsocketaddr.c +++ b/src/util/virsocketaddr.c @@ -26,7 +26,6 @@ #include "virsocketaddr.h" #include "virerror.h" #include "virstring.h" -#include "viralloc.h" #include "virbuffer.h" =20 #include @@ -1253,3 +1252,9 @@ virSocketAddrPTRDomain(const virSocketAddr *addr, ret =3D -2; goto cleanup; } + +void +virSocketAddrFree(virSocketAddrPtr addr) +{ + VIR_FREE(addr); +} diff --git a/src/util/virsocketaddr.h b/src/util/virsocketaddr.h index 3029338..66f5998 100644 --- a/src/util/virsocketaddr.h +++ b/src/util/virsocketaddr.h @@ -24,14 +24,15 @@ #ifndef __VIR_SOCKETADDR_H__ # define __VIR_SOCKETADDR_H__ =20 -# include "internal.h" - # include # include # ifdef HAVE_SYS_UN_H # include # endif =20 +# include "internal.h" +# include "viralloc.h" + /* On architectures which lack these limits, define them (ie. Cygwin). * Note that the libvirt code should be robust enough to handle the * case where actual value is longer than these limits (eg. by setting @@ -162,4 +163,8 @@ int virSocketAddrPTRDomain(const virSocketAddr *addr, char **ptr) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3); =20 +void virSocketAddrFree(virSocketAddrPtr addr); + +VIR_DEFINE_AUTOPTR_FUNC(virSocketAddr, virSocketAddrFree) + #endif /* __VIR_SOCKETADDR_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list