Merge pull request #86 from cgwalters/cleanup-cleanup-again

Cleanup cleanup again
This commit is contained in:
Colin Walters 2015-01-06 15:03:19 -05:00
commit d6b692660b
5 changed files with 6 additions and 31 deletions

View File

@ -61,8 +61,8 @@ rpmostree_builtin_rebase (int argc,
gboolean changed; gboolean changed;
GSConsole *console = NULL; GSConsole *console = NULL;
gboolean in_status_line = FALSE; gboolean in_status_line = FALSE;
_cleanup_gkeyfile_ GKeyFile *old_origin = NULL; gs_unref_keyfile GKeyFile *old_origin = NULL;
_cleanup_gkeyfile_ GKeyFile *new_origin = NULL; gs_unref_keyfile GKeyFile *new_origin = NULL;
if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, error)) if (!rpmostree_option_context_parse (context, option_entries, &argc, &argv, error))
goto out; goto out;

View File

@ -35,28 +35,11 @@
#include "libgsystem.h" #include "libgsystem.h"
/* This one is in libgsystem git master, but not 2014.2 */
GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, _cleanup_g_key_file_unref, g_key_file_unref);
#define _cleanup_gkeyfile_ __attribute__((cleanup(_cleanup_g_key_file_unref)))
GS_DEFINE_CLEANUP_FUNCTION0(HySack, _cleanup_hy_sack_free, hy_sack_free); GS_DEFINE_CLEANUP_FUNCTION0(HySack, _cleanup_hy_sack_free, hy_sack_free);
GS_DEFINE_CLEANUP_FUNCTION0(HyQuery, _cleanup_hy_query_free, hy_query_free); GS_DEFINE_CLEANUP_FUNCTION0(HyQuery, _cleanup_hy_query_free, hy_query_free);
GS_DEFINE_CLEANUP_FUNCTION0(HyPackageList, _cleanup_hy_packagelist_free, hy_packagelist_free); GS_DEFINE_CLEANUP_FUNCTION0(HyPackageList, _cleanup_hy_packagelist_free, hy_packagelist_free);
GS_DEFINE_CLEANUP_FUNCTION0(HyStringArray, _cleanup_hy_stringarray_free, hy_stringarray_free); GS_DEFINE_CLEANUP_FUNCTION0(HyStringArray, _cleanup_hy_stringarray_free, hy_stringarray_free);
static inline void
cleanup_closep (int *fdp)
{
int fd;
g_assert (fdp);
fd = *fdp;
if (fd != -1)
(void) close (fd);
}
#define _cleanup_close_ __attribute__((cleanup(cleanup_closep)))
#define _cleanup_hysack_ __attribute__((cleanup(_cleanup_hy_sack_free))) #define _cleanup_hysack_ __attribute__((cleanup(_cleanup_hy_sack_free)))
#define _cleanup_hyquery_ __attribute__((cleanup(_cleanup_hy_query_free))) #define _cleanup_hyquery_ __attribute__((cleanup(_cleanup_hy_query_free)))
#define _cleanup_hypackagelist_ __attribute__((cleanup(_cleanup_hy_packagelist_free))) #define _cleanup_hypackagelist_ __attribute__((cleanup(_cleanup_hy_packagelist_free)))

View File

@ -132,14 +132,6 @@ yum_context_free (YumContext *yumctx)
g_free (yumctx); g_free (yumctx);
} }
static inline
void cleanup_keyfile_unref (void *loc)
{
GKeyFile *locp = *((GKeyFile**)loc);
if (locp)
g_key_file_unref (locp);
}
static gboolean static gboolean
append_repo_and_cache_opts (RpmOstreeTreeComposeContext *self, append_repo_and_cache_opts (RpmOstreeTreeComposeContext *self,
JsonObject *treedata, JsonObject *treedata,
@ -202,7 +194,7 @@ append_repo_and_cache_opts (RpmOstreeTreeComposeContext *self,
gs_free char *baseurl = g_strconcat ("file://", repodir, NULL); gs_free char *baseurl = g_strconcat ("file://", repodir, NULL);
gs_free char *tmprepo_filename = g_strconcat (reponame, ".repo", NULL); gs_free char *tmprepo_filename = g_strconcat (reponame, ".repo", NULL);
gs_unref_object GFile *tmprepo_path = g_file_get_child (repos_tmpdir, tmprepo_filename); gs_unref_object GFile *tmprepo_path = g_file_get_child (repos_tmpdir, tmprepo_filename);
__attribute__ ((cleanup(cleanup_keyfile_unref))) GKeyFile *keyfile = NULL; gs_unref_keyfile GKeyFile *keyfile = NULL;
gs_free char *data = NULL; gs_free char *data = NULL;
gsize len; gsize len;

View File

@ -136,8 +136,8 @@ _rpmostree_libcontainer_make_api_mounts (const char *dest)
int int
_rpmostree_libcontainer_prep_dev (const char *dest_devdir) _rpmostree_libcontainer_prep_dev (const char *dest_devdir)
{ {
_cleanup_close_ int src_fd = -1; gs_fd_close int src_fd = -1;
_cleanup_close_ int dest_fd = -1; gs_fd_close int dest_fd = -1;
struct stat stbuf; struct stat stbuf;
guint i; guint i;
static const char *const devnodes[] = { "null", "zero", "full", "random", "urandom", "tty" }; static const char *const devnodes[] = { "null", "zero", "full", "random", "urandom", "tty" };

View File

@ -1514,7 +1514,7 @@ rpmostree_commit (GFile *rootfs,
gs_free char *new_revision = NULL; gs_free char *new_revision = NULL;
gs_unref_object GFile *root_tree = NULL; gs_unref_object GFile *root_tree = NULL;
gs_unref_object OstreeSePolicy *sepolicy = NULL; gs_unref_object OstreeSePolicy *sepolicy = NULL;
_cleanup_close_ int rootfs_fd = -1; gs_fd_close int rootfs_fd = -1;
/* hardcode targeted policy for now */ /* hardcode targeted policy for now */
if (enable_selinux) if (enable_selinux)