[Pkg-libvirt-commits] [libguestfs] 68/266: daemon: add CLEANUP_CLOSE

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit 4249ddd8bbd0d38f7e63890b999c6199b54af5b3
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Fri Aug 8 15:34:07 2014 +0200

    daemon: add CLEANUP_CLOSE
    
    Just call close on the specified fd, if valid.
---
 daemon/daemon.h   | 3 +++
 daemon/guestfsd.c | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/daemon/daemon.h b/daemon/daemon.h
index fb74e91..0caad45 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -173,6 +173,7 @@ asprintf_nowarn (char **strp, const char *fmt, ...)
 extern void cleanup_free (void *ptr);
 extern void cleanup_free_string_list (void *ptr);
 extern void cleanup_unlink_free (void *ptr);
+extern void cleanup_close (void *ptr);
 
 /*-- in names.c (auto-generated) --*/
 extern const char *function_names[];
@@ -405,10 +406,12 @@ is_zero (const char *buffer, size_t size)
 #define CLEANUP_FREE_STRING_LIST                        \
     __attribute__((cleanup(cleanup_free_string_list)))
 #define CLEANUP_UNLINK_FREE __attribute__((cleanup(cleanup_unlink_free)))
+#define CLEANUP_CLOSE __attribute__((cleanup(cleanup_close)))
 #else
 #define CLEANUP_FREE
 #define CLEANUP_FREE_STRING_LIST
 #define CLEANUP_UNLINK_FREE
+#define CLEANUP_CLOSE
 #endif
 
 #endif /* GUESTFSD_DAEMON_H */
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 622bda1..0a59c84 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -1482,3 +1482,12 @@ cleanup_unlink_free (void *ptr)
     free (filename);
   }
 }
+
+void
+cleanup_close (void *ptr)
+{
+  int fd = * (int *) ptr;
+
+  if (fd >= 0)
+    close (fd);
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list