diff --git a/daemon/daemon.h b/daemon/daemon.h index d90b3e73d..b9e74022f 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 321544f60..34a47ab11 100644 --- a/daemon/guestfsd.c +++ b/daemon/guestfsd.c @@ -47,6 +47,8 @@ # include #endif +#include + #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 3bab9bf0a..3b117c505 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);