daemon: make aug_close cleanup available for all

Just code motion, no behaviour changes.
This commit is contained in:
Pino Toscano
2014-09-03 17:38:32 +02:00
parent a935db30e5
commit de93b9060d
3 changed files with 14 additions and 16 deletions

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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);