[Pkg-libvirt-commits] [libguestfs] 124/156: daemon: add CLEANUP_CLOSE
Hilko Bengen
bengen at moszumanska.debian.org
Sat Aug 30 08:26:13 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch master
in repository libguestfs.
commit 14fa589013401ba1fcad3ac04e1ae4d3a2876e50
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.
(cherry picked from commit 4249ddd8bbd0d38f7e63890b999c6199b54af5b3)
---
daemon/daemon.h | 3 +++
daemon/guestfsd.c | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 8f7e2c6..08799e1 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -172,6 +172,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[];
@@ -404,10 +405,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 6519ea6..0f847ea 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -1461,3 +1461,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