From nobody Tue Jul 1 11:17:27 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531504578527692.9205859870953; Fri, 13 Jul 2018 10:56:18 -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 759973E2D2; Fri, 13 Jul 2018 17:56:15 +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 3D395600D1; Fri, 13 Jul 2018 17:56:15 +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 CA5EA18037F4; Fri, 13 Jul 2018 17:56:14 +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 w6DHtrbr008425 for ; Fri, 13 Jul 2018 13:55:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1F8210694FC; Fri, 13 Jul 2018 17:55:53 +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 905AF10694F0 for ; Fri, 13 Jul 2018 17:55:50 +0000 (UTC) Received: from mail-pf0-f169.google.com (mail-pf0-f169.google.com [209.85.192.169]) (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 B03BAC057FA2 for ; Fri, 13 Jul 2018 17:55:39 +0000 (UTC) Received: by mail-pf0-f169.google.com with SMTP id v15-v6so3038254pff.5 for ; Fri, 13 Jul 2018 10:55:39 -0700 (PDT) Received: from centos.localdomain ([42.106.1.21]) by smtp.gmail.com with ESMTPSA id n5-v6sm26866817pgr.24.2018.07.13.10.55.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 10:55: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=JA8bASW1446UoTQoWaSIaC659blRbC3JFcx7HpN5lC0=; b=jhSOyeNvO9gff2KpDGhNGYWvW4+pkkSt2/dIewz4KBCrxyxHxL8T8WHMhfcUPMYgdo rMr4IoBAAVoezLB4HazRUJXUHq3bIInfD/9J18TISfV2fEo8m+TtsIUyc+f7DviLC3Ss voMy2xn/DU1pEP0w4B6MeW//GTl4uNrs7+GFsp1HvCyyrzornelV0NavizFSYIpveX48 vsMpU1A5xqJkKTtTEhihDI17JsudEtdX73DMwiFpG3A4beHyAE/uionKv8j1B5jV1JMS qTedGY3dKJYtAXkjAGwmMb0cmxhNyalQETVB/4Sq08KuBF7nyZumsgzsg5KPfunarsyM zveg== 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=JA8bASW1446UoTQoWaSIaC659blRbC3JFcx7HpN5lC0=; b=L33gvk5fmkbWj6oIvoR0a/egPQQyAWh94Dtl9ZD4HoOD2JTD2dK4HbZEa6so05JTcX 2CaU4a2/dJykDS/kbaOMAAjdgeS40Zc1d3OJI3eySYP8z7yHaLhTQ4BP8Qg3HuVLmG6g 8b462bHEYFu4dF8vPnuv4pHIo8MFFZfx3orzAL45jBUAmqLZj4ZnXwDQchreAoYYQeFZ 3MCyGTN8vmNHFUmysMwNXjBlk6UoLq2B8R0iWlycVcXg3MKJldEdY7Yi2LN6T7yVOD4S IubVBULOZ/Wghw09AHQDud37Payw/2bmqSl2gCm5WIEaueKCuuAkElcZgiXql405IR+T 7lRw== X-Gm-Message-State: AOUpUlEaFfncfQ/JccJYUZifeCXduXnEkK1LtXZy1pNrIHN0Mm3wl3S6 3rfcLjo/CwHZ5Vh0JchfCcdlDFSw X-Google-Smtp-Source: AAOMgpdcrvrYCad/Z3SFSCMafELhtk3qMptEhnmhRDPoTB252OqKiZM8xkfui7Zx19ocQ33n+8N1rA== X-Received: by 2002:a62:3b89:: with SMTP id w9-v6mr8138081pfj.80.1531504539001; Fri, 13 Jul 2018 10:55:39 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 13 Jul 2018 23:24:46 +0530 Message-Id: <1531504509-7930-9-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1531504509-7930-1-git-send-email-skrtbhtngr@gmail.com> References: <1531504509-7930-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]); Fri, 13 Jul 2018 17:55:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 13 Jul 2018 17:55:39 +0000 (UTC) for IP:'209.85.192.169' DOMAIN:'mail-pf0-f169.google.com' HELO:'mail-pf0-f169.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.3 * (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.169 mail-pf0-f169.google.com 209.85.192.169 mail-pf0-f169.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 08/31] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 13 Jul 2018 17:56: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. 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 Reviewed-by: Erik Skultety --- 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