[Libguestfs] [PATCH 1/5] daemon: make aug_close cleanup available for all

Pino Toscano ptoscano at redhat.com
Thu Sep 4 15:18:27 UTC 2014


Just code motion, no behaviour changes.
---
 daemon/daemon.h     |  3 +++
 daemon/guestfsd.c   | 11 +++++++++++
 daemon/lvm-filter.c | 16 ----------------
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/daemon/daemon.h b/daemon/daemon.h
index d90b3e7..b9e7402 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -176,6 +176,7 @@ 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);
+extern void cleanup_aug_close (void *ptr);
 
 /*-- in names.c (auto-generated) --*/
 extern const char *function_names[];
@@ -426,11 +427,13 @@ is_zero (const char *buffer, size_t size)
     __attribute__((cleanup(cleanup_free_string_list)))
 #define CLEANUP_UNLINK_FREE __attribute__((cleanup(cleanup_unlink_free)))
 #define CLEANUP_CLOSE __attribute__((cleanup(cleanup_close)))
+#define CLEANUP_AUG_CLOSE __attribute__((cleanup(cleanup_aug_close)))
 #else
 #define CLEANUP_FREE
 #define CLEANUP_FREE_STRING_LIST
 #define CLEANUP_UNLINK_FREE
 #define CLEANUP_CLOSE
+#define CLEANUP_AUG_CLOSE
 #endif
 
 #endif /* GUESTFSD_DAEMON_H */
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 321544f..34a47ab 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -47,6 +47,8 @@
 # include <printf.h>
 #endif
 
+#include <augeas.h>
+
 #include "sockets.h"
 #include "c-ctype.h"
 #include "ignore-value.h"
@@ -1511,3 +1513,12 @@ cleanup_close (void *ptr)
   if (fd >= 0)
     close (fd);
 }
+
+void
+cleanup_aug_close (void *ptr)
+{
+  augeas *aug = * (augeas **) ptr;
+
+  if (aug != NULL)
+    aug_close (aug);
+}
diff --git a/daemon/lvm-filter.c b/daemon/lvm-filter.c
index 3bab9bf..3b117c5 100644
--- a/daemon/lvm-filter.c
+++ b/daemon/lvm-filter.c
@@ -33,22 +33,6 @@
 #include "daemon.h"
 #include "actions.h"
 
-#ifdef HAVE_ATTRIBUTE_CLEANUP
-#define CLEANUP_AUG_CLOSE __attribute__((cleanup(cleanup_aug_close)))
-
-static void
-cleanup_aug_close (void *ptr)
-{
-  augeas *aug = * (augeas **) ptr;
-
-  if (aug != NULL)
-    aug_close (aug);
-}
-
-#else
-#define CLEANUP_AUG_CLOSE
-#endif
-
 GUESTFSD_EXT_CMD(str_lvm, lvm);
 GUESTFSD_EXT_CMD(str_cp, cp);
 GUESTFSD_EXT_CMD(str_rm, rm);
-- 
1.9.3




More information about the Libguestfs mailing list