From nobody Mon Feb 9 10:28: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 1533714222560426.1679398909454; Wed, 8 Aug 2018 00:43:42 -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 AA7FB12C36; Wed, 8 Aug 2018 07:43:39 +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 70C9262929; Wed, 8 Aug 2018 07:43:39 +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 DD9533F64B; Wed, 8 Aug 2018 07:43:38 +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 w787haDt005596 for ; Wed, 8 Aug 2018 03:43:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id EFB14608F4; Wed, 8 Aug 2018 07:43:36 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E46D4608F3 for ; Wed, 8 Aug 2018 07:43:36 +0000 (UTC) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.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 7FE8B30820D4 for ; Wed, 8 Aug 2018 07:43:35 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id u24-v6so700520pfn.13 for ; Wed, 08 Aug 2018 00:43:35 -0700 (PDT) Received: from centos.localdomain ([42.106.0.165]) by smtp.gmail.com with ESMTPSA id 9-v6sm9617719pfv.53.2018.08.08.00.43.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=yEVPsv1tDimTuSvu4bO2zdD8A77JHQDNK3OeCvmpD9E=; b=mf6V44AUarK1BH5rGUfb9Guct7apaAAXphumlfbyCjNdYpcYUrHkv5turtDiTCMNoV sEb4H9H3Q3NvEZX88TtNO424x6cjFxDlt8Kp5HWn9FAV8UDcWlTwTTyDh6PDRomwv+kw 1oq7CwBg/XeqMNpLFdfXugdyiTfc+YmAvgvwS3nyoKIJNw8hsZbw3kIfTGVuiJwsdLQ7 U3ntuhiOwLkycRz2mdA22ZZaJY4IVcS55V7+RoOk5CMmEHE78wB1LMjZqNNW18B7ft5w dxATHbWO9fNSVakM8HZOIyG9hVjuqiyQGwHo93Cxw5Zzf/5WgVjiZ6hs2JVbEUjnnt8w ypKA== 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=yEVPsv1tDimTuSvu4bO2zdD8A77JHQDNK3OeCvmpD9E=; b=HUD1ef0//u6dxwewXsUP48wUdPnt9Be9rnu6xoE1YkhR28u4rGpXuXbmfFyWjO765k JYn3/3gKZy9Gm+Xuv5ZV3+v4MdVuHK2om0NHfzmiqWQIw6HSVdW1O+FXa1d5nJaAt8RK EWljYeSccoqDgdlyw/PdDM//izoKVESxH4VV6r4N24Y0XYuGnYjYwTz3bpX2NsmXDHGV xobiYQNOWFcgtOE31DR1fPRg2aR/Z4T0aKp+HbOtc0oqOnYymlombuFxIrnEYxDDRAHs Fw73WUFgjdn7LhW16zt8lYwgIBGHIYxaNHy4cQ9rk119tF8OGp2Y8RRvbY7HhgOF5nAj YILQ== X-Gm-Message-State: AOUpUlHgUDc+xk0DDxmPfBHnAt11NThr4/rQs1TVetnwdwNoM5PixOkQ pfsul6rnHnv4AKdpmbT10KejcYN5 X-Google-Smtp-Source: AA+uWPyprxaxicTai2GCa2LgazikmVSiqzgRZ+Hq9z/Tkb9fQMSulc08jskGkJaOKC7CV/yT1PiwbQ== X-Received: by 2002:a63:ac57:: with SMTP id z23-v6mr1438712pgn.74.1533714214727; Wed, 08 Aug 2018 00:43:34 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:39 +0530 Message-Id: <1533501842-24503-13-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1533501842-24503-1-git-send-email-skrtbhtngr@gmail.com> References: <1533501842-24503-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 08 Aug 2018 07:43:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 08 Aug 2018 07:43:35 +0000 (UTC) for IP:'209.85.210.173' DOMAIN:'mail-pf1-f173.google.com' HELO:'mail-pf1-f173.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.173 mail-pf1-f173.google.com 209.85.210.173 mail-pf1-f173.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 12/35] 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.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.26]); Wed, 08 Aug 2018 07:43:40 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 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