On Monday, 19 June 2017 15:31:29 CEST Richard W.M. Jones wrote:
After the previous refactoring, we are able to link the daemon to
common/utils, and also remove some of the "duplicate" functions that
the daemon carried ("duplicate" in quotes because they were often not
exact duplicates).
Also this removes the duplicate reimplementation of (most) cleanup
functions in the daemon, since those are provided by libutils now.
It also allows us in future (but not in this commit) to move utility
functions from the daemon into libutils.
---
daemon/Makefile.am | 8 +++++--
daemon/augeas.c | 2 +-
daemon/btrfs.c | 18 +++++++--------
daemon/cleanups.c | 49 +---------------------------------------
daemon/cleanups.h | 51 -----------------------------------------
daemon/daemon.h | 31 ++++++++++++++++---------
daemon/debug.c | 4 ++--
daemon/echo-daemon.c | 2 +-
daemon/guestfsd.c | 64 ----------------------------------------------------
daemon/ldm.c | 2 +-
daemon/lvm.c | 4 ++--
daemon/md.c | 8 ++++---
daemon/stat.c | 2 +-
docs/C_SOURCE_FILES | 1 -
generator/daemon.ml | 8 +++----
15 files changed, 53 insertions(+), 201 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 0d3dde516..db19594b8 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -49,6 +49,8 @@ endif
guestfsd_SOURCES = \
../common/errnostring/errnostring.h \
../common/protocol/guestfs_protocol.h \
+ ../common/utils/cleanups.h \
+ ../common/utils/utils.h \
Should this be guestfs-utils.h?
diff --git a/daemon/cleanups.h b/daemon/cleanups.h
deleted file mode 100644
index a791244cb..000000000
--- a/daemon/cleanups.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* libguestfs - the guestfsd daemon
- * Copyright (C) 2009-2015 Red Hat Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef GUESTFSD_CLEANUPS_H
-#define GUESTFSD_CLEANUPS_H
-
-/* These functions are used internally by the CLEANUP_* macros.
- * Don't call them directly.
- */
-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_fclose (void *ptr);
-extern void cleanup_aug_close (void *ptr);
-extern void cleanup_free_stringsbuf (void *ptr);
-
-#ifdef HAVE_ATTRIBUTE_CLEANUP
-#define CLEANUP_FREE __attribute__((cleanup(cleanup_free)))
-#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)))
-#define CLEANUP_FCLOSE __attribute__((cleanup(cleanup_fclose)))
-#define CLEANUP_AUG_CLOSE __attribute__((cleanup(cleanup_aug_close)))
-#define CLEANUP_FREE_STRINGSBUF __attribute__((cleanup(cleanup_free_stringsbuf)))
-#else
-#define CLEANUP_FREE
-#define CLEANUP_FREE_STRING_LIST
-#define CLEANUP_UNLINK_FREE
-#define CLEANUP_CLOSE
-#define CLEANUP_AUG_CLOSE
-#define CLEANUP_FREE_STRINGSBUF
-#endif
-
-#endif /* GUESTFSD_CLEANUPS_H */
Considering cleanups.c is still there, I'd leave this too, even if with
much smaller content.
--
Pino Toscano