diff options
author | Richard Hughes <richard@hughsie.com> | 2015-10-13 13:40:25 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2015-10-13 16:23:22 +0100 |
commit | 7999005038cbeaa35221bc7053b74c6cd1daca1b (patch) | |
tree | b2380fcaf4ebf83fd980b1d494ff68879e70d895 | |
parent | 0b7f570b5de671f8d1f7855bb01c0f991ba33752 (diff) | |
download | colord-7999005038cbeaa35221bc7053b74c6cd1daca1b.tar.gz |
Port to g_autoptr()
48 files changed, 570 insertions, 618 deletions
diff --git a/client/cd-create-profile.c b/client/cd-create-profile.c index 1251518..974f03b 100644 --- a/client/cd-create-profile.c +++ b/client/cd-create-profile.c @@ -96,15 +96,15 @@ cd_util_create_colprof (CdUtilPrivate *priv, gdouble tlimit; gint exit_status = 0; gsize len = 0; - _cleanup_free_ gchar *cmdline = NULL; - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *debug_stderr = NULL; - _cleanup_free_ gchar *debug_stdout = NULL; - _cleanup_free_ gchar *output_fn = NULL; - _cleanup_free_ gchar *ti3_fn = NULL; - _cleanup_object_unref_ GFile *output_file = NULL; - _cleanup_object_unref_ GFile *ti3_file = NULL; - _cleanup_ptrarray_unref_ GPtrArray *argv = NULL; + g_autofree gchar *cmdline = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *debug_stderr = NULL; + g_autofree gchar *debug_stdout = NULL; + g_autofree gchar *output_fn = NULL; + g_autofree gchar *ti3_fn = NULL; + g_autoptr(GFile) output_file = NULL; + g_autoptr(GFile) ti3_file = NULL; + g_autoptr(GPtrArray) argv = NULL; #ifndef TOOL_COLPROF /* no support */ @@ -664,7 +664,7 @@ cd_util_icc_set_metadata_coverage (CdIcc *icc, GError **error) { const gchar *tmp; gdouble coverage = 0.0f; - _cleanup_free_ gchar *coverage_tmp = NULL; + g_autofree gchar *coverage_tmp = NULL; _cleanup_object_unref_ CdIcc *icc_srgb = NULL; /* is sRGB? */ @@ -700,7 +700,7 @@ cd_util_create_from_xml (CdUtilPrivate *priv, gboolean ret = TRUE; GHashTable *hash; gssize data_len = -1; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; _cleanup_object_unref_ CdDom *dom = NULL; /* parse the XML into DOM */ @@ -802,10 +802,10 @@ main (int argc, char **argv) CdUtilPrivate *priv; gboolean ret; guint retval = EXIT_FAILURE; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *cmd_descriptions = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *cmd_descriptions = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; const GOptionEntry options[] = { { "output", 'o', 0, G_OPTION_ARG_STRING, &filename, /* TRANSLATORS: command line option */ diff --git a/client/cd-fix-profile.c b/client/cd-fix-profile.c index 136d8c7..e71143e 100644 --- a/client/cd-fix-profile.c +++ b/client/cd-fix-profile.c @@ -79,7 +79,7 @@ cd_util_add (GPtrArray *array, const gchar *name, const gchar *description, CdUt { CdUtilItem *item; guint i; - _cleanup_strv_free_ gchar **names = NULL; + g_auto(GStrv) names = NULL; /* add each one */ names = g_strsplit (name, ",", -1); @@ -151,7 +151,7 @@ cd_util_run (CdUtilPrivate *priv, const gchar *command, gchar **values, GError * { CdUtilItem *item; guint i; - _cleanup_string_free_ GString *string = NULL; + g_autoptr(GString) string = NULL; /* find command */ for (i = 0; i < priv->cmd_array->len; i++) { @@ -258,7 +258,7 @@ cd_util_set_model (CdUtilPrivate *priv, gchar **values, GError **error) static gboolean cd_util_clear_metadata (CdUtilPrivate *priv, gchar **values, GError **error) { - _cleanup_hashtable_unref_ GHashTable *md = NULL; + g_autoptr(GHashTable) md = NULL; md = cd_icc_get_metadata (priv->icc); if (md == NULL) return TRUE; @@ -413,8 +413,8 @@ static gboolean cd_util_export_tag_data (CdUtilPrivate *priv, gchar **values, GError **error) { gboolean ret; - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *out_fn = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *out_fn = NULL; /* check arguments */ if (g_strv_length (values) != 2) { @@ -637,10 +637,10 @@ main (int argc, char *argv[]) gboolean ret = TRUE; gboolean verbose = FALSE; guint retval = 1; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *cmd_descriptions = NULL; - _cleanup_free_ gchar *locale = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *cmd_descriptions = NULL; + g_autofree gchar *locale = NULL; + g_autoptr(GFile) file = NULL; const GOptionEntry options[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, /* TRANSLATORS: command line option */ diff --git a/client/cd-iccdump.c b/client/cd-iccdump.c index 43e411d..484201a 100644 --- a/client/cd-iccdump.c +++ b/client/cd-iccdump.c @@ -53,9 +53,9 @@ cd_fix_profile_error_cb (cmsContext ContextID, static gboolean cd_iccdump_print_file (const gchar *filename, GError **error) { - _cleanup_free_ gchar *str = NULL; + g_autofree gchar *str = NULL; _cleanup_object_unref_ CdIcc *icc = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; /* load the profile */ icc = cd_icc_new (); @@ -79,7 +79,7 @@ main (int argc, char **argv) GOptionContext *context; gint i; guint retval = EXIT_FAILURE; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; setlocale (LC_ALL, ""); diff --git a/client/cd-it8.c b/client/cd-it8.c index 4927368..2cacc09 100644 --- a/client/cd-it8.c +++ b/client/cd-it8.c @@ -83,7 +83,7 @@ cd_util_add (GPtrArray *array, { guint i; CdUtilItem *item; - _cleanup_strv_free_ gchar **names = NULL; + g_auto(GStrv) names = NULL; g_return_if_fail (name != NULL); g_return_if_fail (description != NULL); @@ -161,7 +161,7 @@ cd_util_run (CdUtilPrivate *priv, const gchar *command, gchar **values, GError * { guint i; CdUtilItem *item; - _cleanup_string_free_ GString *string = NULL; + g_autoptr(GString) string = NULL; /* find command */ for (i = 0; i < priv->cmd_array->len; i++) { @@ -213,12 +213,12 @@ cd_util_create_cmf (CdUtilPrivate *priv, gchar *dot; guint i; gdouble norm; - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *title = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *title = NULL; _cleanup_object_unref_ CdIt8 *cmf = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GPtrArray) array = NULL; + g_auto(GStrv) lines = NULL; if (g_strv_length (values) != 3) { g_set_error_literal (error, @@ -238,7 +238,7 @@ cd_util_create_cmf (CdUtilPrivate *priv, array = g_ptr_array_new_with_free_func ((GDestroyNotify) cd_csv2cmf_data_free); lines = g_strsplit (data, "\n", -1); for (i = 0; lines[i] != NULL; i++) { - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; if (lines[i][0] == '\0') continue; if (lines[i][0] == '#') @@ -328,13 +328,13 @@ cd_util_calculate_ccmx (CdUtilPrivate *priv, GError **error) { gchar *tmp; - _cleanup_free_ gchar *basename = NULL; + g_autofree gchar *basename = NULL; _cleanup_object_unref_ CdIt8 *it8_ccmx = NULL; _cleanup_object_unref_ CdIt8 *it8_meas = NULL; _cleanup_object_unref_ CdIt8 *it8_ref = NULL; - _cleanup_object_unref_ GFile *file_ccmx = NULL; - _cleanup_object_unref_ GFile *file_meas = NULL; - _cleanup_object_unref_ GFile *file_ref = NULL; + g_autoptr(GFile) file_ccmx = NULL; + g_autoptr(GFile) file_meas = NULL; + g_autoptr(GFile) file_ref = NULL; /* check args */ if (g_strv_length (values) != 3) { @@ -389,12 +389,12 @@ cd_util_create_sp (CdUtilPrivate *priv, gchar *dot; gdouble norm; guint i; - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *title = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *title = NULL; _cleanup_object_unref_ CdIt8 *cmf = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GPtrArray) array = NULL; + g_auto(GStrv) lines = NULL; if (g_strv_length (values) < 1) { g_set_error_literal (error, @@ -413,7 +413,7 @@ cd_util_create_sp (CdUtilPrivate *priv, lines = g_strsplit (data, "\n", -1); norm = g_strtod (values[2], NULL); for (i = 0; lines[i] != NULL; i++) { - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; if (lines[i][0] == '\0') continue; if (lines[i][0] == '#') @@ -498,8 +498,8 @@ main (int argc, char *argv[]) gboolean ret; gboolean verbose = FALSE; guint retval = 1; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *cmd_descriptions = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *cmd_descriptions = NULL; const GOptionEntry options[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, /* TRANSLATORS: command line option */ diff --git a/client/cd-util.c b/client/cd-util.c index b097ab9..93eefd4 100644 --- a/client/cd-util.c +++ b/client/cd-util.c @@ -124,7 +124,7 @@ cd_util_print_field_time (const gchar *title, gint64 usecs) { GDateTime *datetime; - _cleanup_free_ gchar *str = NULL; + g_autofree gchar *str = NULL; datetime = g_date_time_new_from_unix_utc (usecs / G_USEC_PER_SEC); /* TRANSLATORS: this is the profile creation date strftime format */ @@ -145,7 +145,7 @@ cd_util_show_owner (CdUtilPrivate *priv, guint uid) /* TRANSLATORS: profile owner */ cd_util_print_field (_("Owner"), "owner", priv, pw->pw_name); #else - _cleanup_free_ gchar *str = NULL; + g_autofree gchar *str = NULL; str = g_strdup_printf ("%u", uid); /* TRANSLATORS: profile UID */ cd_util_print_field (_("Owner"), "owner", priv, str); @@ -167,8 +167,8 @@ cd_util_show_profile (CdUtilPrivate *priv, CdProfile *profile) GList *l; guint i; guint size; - _cleanup_hashtable_unref_ GHashTable *metadata = NULL; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GHashTable) metadata = NULL; + g_autoptr(GList) list = NULL; /* TRANSLATORS: the internal DBus path */ cd_util_print_field (_("Object Path"), @@ -273,8 +273,8 @@ cd_util_show_device (CdUtilPrivate *priv, CdDevice *device) GList *l; GPtrArray *profiles; guint i; - _cleanup_hashtable_unref_ GHashTable *metadata = NULL; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GHashTable) metadata = NULL; + g_autoptr(GList) list = NULL; /* TRANSLATORS: the internal DBus path */ cd_util_print_field (_("Object Path"), @@ -513,11 +513,11 @@ cd_util_show_sensor (CdUtilPrivate *priv, CdSensor *sensor) guint caps; guint i; GVariant *value_tmp; - _cleanup_error_free_ GError *error = NULL; - _cleanup_hashtable_unref_ GHashTable *metadata = NULL; - _cleanup_hashtable_unref_ GHashTable *options = NULL; - _cleanup_list_free_ GList *list = NULL; - _cleanup_string_free_ GString *caps_str = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GHashTable) metadata = NULL; + g_autoptr(GHashTable) options = NULL; + g_autoptr(GList) list = NULL; + g_autoptr(GString) caps_str = NULL; /* TRANSLATORS: the internal DBus path */ cd_util_print_field (_("Object Path"), @@ -692,7 +692,7 @@ cd_util_add (GPtrArray *array, { guint i; CdUtilItem *item; - _cleanup_strv_free_ gchar **names = NULL; + g_auto(GStrv) names = NULL; g_return_if_fail (name != NULL); g_return_if_fail (description != NULL); @@ -770,7 +770,7 @@ cd_util_run (CdUtilPrivate *priv, const gchar *command, gchar **values, GError * { guint i; CdUtilItem *item; - _cleanup_string_free_ GString *string = NULL; + g_autoptr(GString) string = NULL; /* find command */ for (i = 0; i < priv->cmd_array->len; i++) { @@ -808,10 +808,10 @@ cd_util_dump (CdUtilPrivate *priv, gchar **values, GError **error) GDateTime *dt; GError *error_local = NULL; guint i; - _cleanup_free_ gchar *mapping_db = NULL; - _cleanup_ptrarray_unref_ GPtrArray *devices = NULL; - _cleanup_ptrarray_unref_ GPtrArray *profiles = NULL; - _cleanup_string_free_ GString *str = NULL; + g_autofree gchar *mapping_db = NULL; + g_autoptr(GPtrArray) devices = NULL; + g_autoptr(GPtrArray) profiles = NULL; + g_autoptr(GString) str = NULL; /* header */ str = g_string_new (""); @@ -913,7 +913,7 @@ cd_util_get_devices (CdUtilPrivate *priv, gchar **values, GError **error) { CdDevice *device; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* execute sync method */ array = cd_client_get_devices_sync (priv->client, NULL, error); @@ -938,7 +938,7 @@ cd_util_get_devices_by_kind (CdUtilPrivate *priv, gchar **values, GError **error { CdDevice *device; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; if (g_strv_length (values) < 1) { g_set_error_literal (error, @@ -976,7 +976,7 @@ cd_util_get_profiles (CdUtilPrivate *priv, gchar **values, GError **error) { CdProfile *profile; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* execute sync method */ array = cd_client_get_profiles_sync (priv->client, NULL, error); @@ -1001,7 +1001,7 @@ cd_util_get_sensors (CdUtilPrivate *priv, gchar **values, GError **error) { CdSensor *sensor; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* execute sync method */ array = cd_client_get_sensors_sync (priv->client, NULL, error); @@ -1033,7 +1033,7 @@ cd_util_sensor_lock (CdUtilPrivate *priv, gchar **values, GError **error) CdSensor *sensor; GMainLoop *loop = NULL; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* execute sync method */ array = cd_client_get_sensors_sync (priv->client, NULL, error); @@ -1075,7 +1075,7 @@ cd_util_get_sensor_reading (CdUtilPrivate *priv, gchar **values, GError **error) GError *error_local = NULL; guint i; guint j; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; if (g_strv_length (values) < 1) { g_set_error_literal (error, @@ -1186,8 +1186,8 @@ cd_util_sensor_set_options (CdUtilPrivate *priv, gchar **values, GError **error) gchar *endptr = NULL; gdouble val; guint i; - _cleanup_hashtable_unref_ GHashTable *options = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GHashTable) options = NULL; + g_autoptr(GPtrArray) array = NULL; if (g_strv_length (values) < 2) { g_set_error_literal (error, @@ -1257,7 +1257,7 @@ static gboolean cd_util_create_device (CdUtilPrivate *priv, gchar **values, GError **error) { guint mask; - _cleanup_hashtable_unref_ GHashTable *device_props = NULL; + g_autoptr(GHashTable) device_props = NULL; _cleanup_object_unref_ CdDevice *device = NULL; if (g_strv_length (values) < 3) { @@ -1977,7 +1977,7 @@ cd_util_import_profile (CdUtilPrivate *priv, GError **error) { _cleanup_object_unref_ CdProfile *profile = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; if (g_strv_length (values) < 1) { g_set_error_literal (error, @@ -2022,9 +2022,9 @@ main (int argc, char *argv[]) gboolean verbose = FALSE; gboolean version = FALSE; guint retval = 1; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *cmd_descriptions = NULL; - _cleanup_free_ gchar *filter = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *cmd_descriptions = NULL; + g_autofree gchar *filter = NULL; const GOptionEntry options[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, /* TRANSLATORS: command line option */ @@ -2287,7 +2287,7 @@ main (int argc, char *argv[]) ret = cd_util_run (priv, argv[1], (gchar**) &argv[2], &error); if (!ret) { if (g_error_matches (error, CD_ERROR, CD_ERROR_NO_SUCH_CMD)) { - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; tmp = g_option_context_get_help (priv->context, TRUE, NULL); g_print ("%s", tmp); } else { diff --git a/contrib/colord-sane/cd-main.c b/contrib/colord-sane/cd-main.c index 41402f2..51c2c4e 100644 --- a/contrib/colord-sane/cd-main.c +++ b/contrib/colord-sane/cd-main.c @@ -100,7 +100,7 @@ cd_main_colord_create_device_cb (GObject *source_object, gpointer user_data) { CdClient *client = CD_CLIENT (source_object); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; _cleanup_object_unref_ CdDevice *device = NULL; /* get result */ @@ -116,10 +116,10 @@ static void cd_sane_client_add (CdMainPrivate *priv, const SANE_Device *sane_device) { CdMainDev *dev; - _cleanup_free_ gchar *id = NULL; - _cleanup_free_ gchar *model = NULL; - _cleanup_free_ gchar *vendor = NULL; - _cleanup_hashtable_unref_ GHashTable *properties = NULL; + g_autofree gchar *id = NULL; + g_autofree gchar *model = NULL; + g_autofree gchar *vendor = NULL; + g_autoptr(GHashTable) properties = NULL; /* ignore noname, no support devices */ if (g_strcmp0 (sane_device->vendor, "Noname") == 0) { @@ -188,7 +188,7 @@ cd_main_colord_delete_device_cb (GObject *source_object, gpointer user_data) { CdClient *client = CD_CLIENT (source_object); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get result */ if (!cd_client_delete_device_finish (client, res, &error)) @@ -267,7 +267,7 @@ cd_sane_add_device_if_from_colord_sane (gpointer data, CdMainPrivate *priv = (CdMainPrivate *) user_data; const gchar *cmdline; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; ret = cd_device_connect_sync (device, NULL, &error); @@ -298,7 +298,7 @@ cd_sane_populate_existing_devices_cb (GObject *source_object, { CdMainPrivate *priv = (CdMainPrivate *) user_data; GPtrArray *devices; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; devices = cd_client_get_devices_by_kind_finish (priv->client, res, &error); if (error != NULL) { @@ -324,7 +324,7 @@ cd_main_colord_connect_cb (GObject *source_object, { CdMainPrivate *priv = (CdMainPrivate *) user_data; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get result */ ret = cd_client_connect_finish (priv->client, res, &error); diff --git a/contrib/session-helper/cd-main.c b/contrib/session-helper/cd-main.c index 0f93697..c0dafa9 100644 --- a/contrib/session-helper/cd-main.c +++ b/contrib/session-helper/cd-main.c @@ -158,7 +158,7 @@ cd_main_emit_update_sample (CdMainPrivate *priv, CdColorRGB *color, GError **error) { - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GHashTable) hash = NULL; /* emit signal */ g_debug ("CdMain: Emitting UpdateSample(%f,%f,%f)", @@ -616,7 +616,7 @@ cd_main_calib_interpolate_up (CdMainPrivate *priv, gboolean ret = TRUE; gdouble mix; guint i; - _cleanup_ptrarray_unref_ GPtrArray *old_array = NULL; + g_autoptr(GPtrArray) old_array = NULL; /* make a deep copy */ old_array = g_ptr_array_new_with_free_func (g_free); @@ -667,9 +667,9 @@ cd_main_calib_process (CdMainPrivate *priv, gdouble temp; guint i; guint precision_steps = 0; - _cleanup_string_free_ GString *error_str = NULL; - _cleanup_ptrarray_unref_ GPtrArray *gamma_data = NULL; - _cleanup_ptrarray_unref_ GPtrArray *vcgt_smoothed = NULL; + g_autoptr(GString) error_str = NULL; + g_autoptr(GPtrArray) gamma_data = NULL; + g_autoptr(GPtrArray) vcgt_smoothed = NULL; /* reset the state */ ret = cd_state_set_steps (state, @@ -859,8 +859,8 @@ static gboolean cd_main_load_samples (CdMainPrivate *priv, GError **error) { const gchar *filename; - _cleanup_free_ gchar *path = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *path = NULL; + g_autoptr(GFile) file = NULL; filename = cd_main_get_display_ti1 (priv->quality); path = g_build_filename (DATADIR, @@ -881,11 +881,11 @@ static gboolean cd_main_write_colprof_files (CdMainPrivate *priv, GError **error) { gboolean ret = TRUE; - _cleanup_free_ gchar *data_cal = NULL; - _cleanup_free_ gchar *data = NULL; - _cleanup_free_ gchar *data_ti3 = NULL; - _cleanup_free_ gchar *filename_ti3 = NULL; - _cleanup_free_ gchar *path_ti3 = NULL; + g_autofree gchar *data_cal = NULL; + g_autofree gchar *data = NULL; + g_autofree gchar *data_ti3 = NULL; + g_autofree gchar *filename_ti3 = NULL; + g_autofree gchar *path_ti3 = NULL; /* build temp path */ priv->working_path = g_dir_make_tmp ("colord-session-XXXXXX", error); @@ -976,9 +976,9 @@ static gboolean cd_main_import_profile (CdMainPrivate *priv, GError **error) { gboolean ret = TRUE; - _cleanup_free_ gchar *filename = NULL; - _cleanup_free_ gchar *path = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *filename = NULL; + g_autofree gchar *path = NULL; + g_autoptr(GFile) file = NULL; filename = g_strdup_printf ("%s.icc", priv->basename); path = g_build_filename (priv->working_path, @@ -1026,11 +1026,11 @@ static gboolean cd_main_set_profile_metadata (CdMainPrivate *priv, GError **error) { gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *profile_fn = NULL; - _cleanup_free_ gchar *profile_path = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *profile_fn = NULL; + g_autofree gchar *profile_path = NULL; _cleanup_object_unref_ CdIcc *icc = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; /* get profile */ profile_fn = g_strdup_printf ("%s.icc", priv->basename); @@ -1075,7 +1075,7 @@ cd_main_set_profile_metadata (CdMainPrivate *priv, GError **error) CD_PROFILE_METADATA_MEASUREMENT_DEVICE, cd_sensor_kind_to_string (cd_sensor_get_kind (priv->sensor))); if (priv->screen_brightness > 0) { - _cleanup_free_ gchar *brightness_str = NULL; + g_autofree gchar *brightness_str = NULL; brightness_str = g_strdup_printf ("%u", priv->screen_brightness); cd_icc_add_metadata (icc, CD_PROFILE_METADATA_SCREEN_BRIGHTNESS, @@ -1107,10 +1107,10 @@ cd_main_generate_profile (CdMainPrivate *priv, GError **error) { gboolean ret; gint exit_status = 0; - _cleanup_free_ gchar *cmd_debug = NULL; - _cleanup_free_ gchar *command = NULL; - _cleanup_free_ gchar *stderr_data = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autofree gchar *cmd_debug = NULL; + g_autofree gchar *command = NULL; + g_autofree gchar *stderr_data = NULL; + g_autoptr(GPtrArray) array = NULL; /* get correct name of the command */ command = cd_main_find_argyll_tool ("colprof", error); @@ -1278,7 +1278,7 @@ cd_main_remove_temp_file (const gchar *filename, GCancellable *cancellable, GError **error) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; g_debug ("removing %s", filename); file = g_file_new_for_path (filename); @@ -1294,7 +1294,7 @@ cd_main_remove_temp_files (CdMainPrivate *priv, GError **error) const gchar *filename; gboolean ret; gchar *src; - _cleanup_dir_close_ GDir *dir = NULL; + g_autoptr(GDir) dir = NULL; /* try to open */ dir = g_dir_open (priv->working_path, 0, error); @@ -1330,7 +1330,7 @@ cd_main_start_calibration (CdMainPrivate *priv, { CdState *state_local; gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; /* reset the state */ ret = cd_state_set_steps (state, @@ -1395,7 +1395,7 @@ static gboolean cd_main_start_calibration_cb (gpointer user_data) { CdMainPrivate *priv = (CdMainPrivate *) user_data; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* reset the state */ cd_state_reset (priv->state); @@ -1464,7 +1464,7 @@ cd_main_find_device (CdMainPrivate *priv, GError **error) { gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; _cleanup_object_unref_ CdDevice *device_tmp = NULL; device_tmp = cd_client_find_device_sync (priv->client, @@ -1514,7 +1514,7 @@ cd_main_find_sensor (CdMainPrivate *priv, GError **error) { gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; _cleanup_object_unref_ CdSensor *sensor_tmp = NULL; sensor_tmp = cd_client_find_sensor_sync (priv->client, @@ -1564,7 +1564,7 @@ cd_main_set_basename (CdMainPrivate *priv) const gchar *tmp; GDateTime *datetime; GString *str; - _cleanup_free_ gchar *date_str = NULL; + g_autofree gchar *date_str = NULL; str = g_string_new (""); @@ -1635,7 +1635,7 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sensor_id; GVariantIter *iter = NULL; GVariant *prop_value; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* should be impossible */ if (g_strcmp0 (interface_name, "org.freedesktop.ColorHelper.Display") != 0) { @@ -1922,8 +1922,8 @@ cd_main_timed_exit_cb (gpointer user_data) static GDBusNodeInfo * cd_main_load_introspection (const gchar *filename, GError **error) { - _cleanup_free_ gchar *data = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *data = NULL; + g_autoptr(GFile) file = NULL; /* load file */ file = g_file_new_for_path (filename); @@ -1995,7 +1995,7 @@ main (int argc, char *argv[]) "Exit after a small delay", NULL }, { NULL} }; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; setlocale (LC_ALL, ""); diff --git a/contrib/session-helper/cd-state.c b/contrib/session-helper/cd-state.c index e0b2a06..0fac698 100644 --- a/contrib/session-helper/cd-state.c +++ b/contrib/session-helper/cd-state.c @@ -470,7 +470,7 @@ cd_state_show_profile (CdState *state) gdouble total_time = 0.0f; guint i; guint uncumalitive = 0; - _cleanup_string_free_ GString *result = NULL; + g_autoptr(GString) result = NULL; /* get the total time so we can work out the divisor */ for (i = 0; i < state->priv->steps; i++) diff --git a/lib/colord/cd-cleanup.h b/lib/colord/cd-cleanup.h index 214232e..1276ff3 100644 --- a/lib/colord/cd-cleanup.h +++ b/lib/colord/cd-cleanup.h @@ -27,12 +27,6 @@ G_BEGIN_DECLS -#define GS_DEFINE_CLEANUP_FUNCTION(Type, name, func) \ - static inline void name (void *v) \ - { \ - func (*(Type*)v); \ - } - #define GS_DEFINE_CLEANUP_FUNCTION0(Type, name, func) \ static inline void name (void *v) \ { \ @@ -40,51 +34,9 @@ G_BEGIN_DECLS func (*(Type*)v); \ } -#define GS_DEFINE_CLEANUP_FUNCTIONt(Type, name, func) \ - static inline void name (void *v) \ - { \ - if (*(Type*)v) \ - func (*(Type*)v, TRUE); \ - } - -GS_DEFINE_CLEANUP_FUNCTION0(GArray*, gs_local_array_unref, g_array_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GBytes*, gs_local_bytes_unref, g_bytes_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GChecksum*, gs_local_checksum_free, g_checksum_free) -GS_DEFINE_CLEANUP_FUNCTION0(GDir*, gs_local_dir_close, g_dir_close) -GS_DEFINE_CLEANUP_FUNCTION0(GError*, gs_local_free_error, g_error_free) -GS_DEFINE_CLEANUP_FUNCTION0(GHashTable*, gs_local_hashtable_unref, g_hash_table_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GKeyFile*, gs_local_keyfile_unref, g_key_file_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GMarkupParseContext*, gs_local_markup_parse_context_unref, g_markup_parse_context_unref) GS_DEFINE_CLEANUP_FUNCTION0(GObject*, gs_local_obj_unref, g_object_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GPtrArray*, gs_local_ptrarray_unref, g_ptr_array_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GTimer*, gs_local_destroy_timer, g_timer_destroy) -GS_DEFINE_CLEANUP_FUNCTION0(GVariantBuilder*, gs_local_variant_builder_unref, g_variant_builder_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GVariant*, gs_local_variant_unref, g_variant_unref) -GS_DEFINE_CLEANUP_FUNCTION0(GVariantIter*, gs_local_variant_iter_free, g_variant_iter_free) - -GS_DEFINE_CLEANUP_FUNCTIONt(GString*, gs_local_free_string, g_string_free) - -GS_DEFINE_CLEANUP_FUNCTION(char**, gs_local_strfreev, g_strfreev) -GS_DEFINE_CLEANUP_FUNCTION(GList*, gs_local_free_list, g_list_free) -GS_DEFINE_CLEANUP_FUNCTION(void*, gs_local_free, g_free) -#define _cleanup_dir_close_ __attribute__ ((cleanup(gs_local_dir_close))) -#define _cleanup_timer_destroy_ __attribute__ ((cleanup(gs_local_destroy_timer))) -#define _cleanup_free_ __attribute__ ((cleanup(gs_local_free))) -#define _cleanup_checksum_free_ __attribute__ ((cleanup(gs_local_checksum_free))) -#define _cleanup_error_free_ __attribute__ ((cleanup(gs_local_free_error))) -#define _cleanup_list_free_ __attribute__ ((cleanup(gs_local_free_list))) -#define _cleanup_string_free_ __attribute__ ((cleanup(gs_local_free_string))) -#define _cleanup_strv_free_ __attribute__ ((cleanup(gs_local_strfreev))) -#define _cleanup_variant_iter_free_ __attribute__ ((cleanup(gs_local_variant_iter_free))) -#define _cleanup_array_unref_ __attribute__ ((cleanup(gs_local_array_unref))) -#define _cleanup_bytes_unref_ __attribute__ ((cleanup(gs_local_bytes_unref))) -#define _cleanup_hashtable_unref_ __attribute__ ((cleanup(gs_local_hashtable_unref))) -#define _cleanup_keyfile_unref_ __attribute__ ((cleanup(gs_local_keyfile_unref))) -#define _cleanup_markup_parse_context_unref_ __attribute__ ((cleanup(gs_local_markup_parse_context_unref))) #define _cleanup_object_unref_ __attribute__ ((cleanup(gs_local_obj_unref))) -#define _cleanup_ptrarray_unref_ __attribute__ ((cleanup(gs_local_ptrarray_unref))) -#define _cleanup_variant_unref_ __attribute__ ((cleanup(gs_local_variant_unref))) G_END_DECLS diff --git a/lib/colord/cd-client.c b/lib/colord/cd-client.c index 04a3f07..b5ff2cf 100644 --- a/lib/colord/cd-client.c +++ b/lib/colord/cd-client.c @@ -215,8 +215,8 @@ cd_client_get_connected (CdClient *client) gboolean cd_client_get_has_server (CdClient *client) { - _cleanup_free_ gchar *name_owner = NULL; - _cleanup_object_unref_ GDBusProxy *proxy = NULL; + g_autofree gchar *name_owner = NULL; + g_autoptr(GDBusProxy) proxy = NULL; g_return_val_if_fail (CD_IS_CLIENT (client), FALSE); @@ -251,7 +251,7 @@ cd_client_dbus_signal_cb (GDBusProxy *proxy, GVariant *parameters, CdClient *client) { - _cleanup_free_ gchar *object_path_tmp = NULL; + g_autofree gchar *object_path_tmp = NULL; _cleanup_object_unref_ CdDevice *device = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; _cleanup_object_unref_ CdSensor *sensor = NULL; @@ -357,11 +357,11 @@ cd_client_connect_cb (GObject *source_object, gpointer user_data) { CdClient *client = CD_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (user_data))); - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *daemon_version = NULL; - _cleanup_variant_unref_ GVariant *system_model = NULL; - _cleanup_variant_unref_ GVariant *system_vendor = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) daemon_version = NULL; + g_autoptr(GVariant) system_model = NULL; + g_autoptr(GVariant) system_vendor = NULL; /* get result */ client->priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error); @@ -500,7 +500,7 @@ cd_client_create_device_finish (CdClient *client, static void cd_client_fixup_dbus_error (GError *error) { - _cleanup_free_ gchar *name = NULL; + g_autofree gchar *name = NULL; g_return_if_fail (error != NULL); @@ -521,10 +521,10 @@ cd_client_create_device_cb (GObject *source_object, gpointer user_data) { CdDevice *device; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -658,10 +658,10 @@ cd_client_create_profile_cb (GObject *source_object, gpointer user_data) { CdProfile *profile; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GDBusMessage *reply = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GDBusMessage) reply = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); reply = g_dbus_connection_send_message_with_reply_finish (G_DBUS_CONNECTION (source_object), res, @@ -725,8 +725,8 @@ cd_client_create_profile (CdClient *client, GVariant *body; GVariantBuilder builder; GSimpleAsyncResult *res; - _cleanup_object_unref_ GDBusMessage *request = NULL; - _cleanup_object_unref_ GUnixFDList *fd_list = NULL; + g_autoptr(GDBusMessage) request = NULL; + g_autoptr(GUnixFDList) fd_list = NULL; g_return_if_fail (CD_IS_CLIENT (client)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); @@ -839,8 +839,8 @@ cd_client_create_profile_for_icc (CdClient *client, { const gchar *checksum; const gchar *filename; - _cleanup_free_ gchar *profile_id = NULL; - _cleanup_hashtable_unref_ GHashTable *profile_props = NULL; + g_autofree gchar *profile_id = NULL; + g_autoptr(GHashTable) profile_props = NULL; g_return_if_fail (CD_IS_CLIENT (client)); g_return_if_fail (CD_IS_ICC (icc)); @@ -896,8 +896,8 @@ cd_client_create_profile_for_icc_finish (CdClient *client, static GFile * cd_client_import_get_profile_destination (GFile *file) { - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *destination = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *destination = NULL; g_return_val_if_fail (file != NULL, NULL); @@ -916,7 +916,7 @@ cd_client_import_mkdir_and_copy (GFile *source, GCancellable *cancellable, GError **error) { - _cleanup_object_unref_ GFile *parent = NULL; + g_autoptr(GFile) parent = NULL; g_return_val_if_fail (source != NULL, FALSE); g_return_val_if_fail (destination != NULL, FALSE); @@ -1028,7 +1028,7 @@ cd_client_import_profile_find_filename_cb (GObject *source_object, { CdClientImportHelper *helper = (CdClientImportHelper *) user_data; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; /* does the profile already exist */ @@ -1036,7 +1036,7 @@ cd_client_import_profile_find_filename_cb (GObject *source_object, res, &error); if (profile != NULL) { - _cleanup_free_ gchar *filename = NULL; + g_autofree gchar *filename = NULL; filename = g_file_get_path (helper->dest); g_simple_async_result_set_error (helper->res, CD_CLIENT_ERROR, @@ -1092,9 +1092,9 @@ cd_client_import_profile_query_info_cb (GObject *source_object, { CdClientImportHelper *helper = (CdClientImportHelper *) user_data; const gchar *type; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFileInfo) info = NULL; /* get the file info */ filename = g_file_get_path (helper->dest); @@ -1220,9 +1220,9 @@ cd_client_delete_device_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1317,9 +1317,9 @@ cd_client_delete_profile_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1415,10 +1415,10 @@ cd_client_find_device_cb (GObject *source_object, gpointer user_data) { CdDevice *device; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1521,10 +1521,10 @@ cd_client_find_device_by_property_cb (GObject *source_object, gpointer user_data) { CdDevice *device; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1629,10 +1629,10 @@ cd_client_find_profile_cb (GObject *source_object, gpointer user_data) { CdProfile *profile; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1735,10 +1735,10 @@ cd_client_find_profile_by_filename_cb (GObject *source_object, gpointer user_data) { CdProfile *profile; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1841,10 +1841,10 @@ cd_client_get_standard_space_cb (GObject *source_object, gpointer user_data) { CdProfile *profile; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1923,14 +1923,14 @@ cd_client_get_device_array_from_variant (CdClient *client, GVariantIter iter; guint i; guint len; - _cleanup_variant_unref_ GVariant *child = NULL; + g_autoptr(GVariant) child = NULL; /* add each device */ array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); child = g_variant_get_child_value (result, 0); len = g_variant_iter_init (&iter, child); for (i = 0; i < len; i++) { - _cleanup_free_ gchar *object_path_tmp = NULL; + g_autofree gchar *object_path_tmp = NULL; g_variant_get_child (child, i, "o", &object_path_tmp); device = cd_device_new_with_object_path (object_path_tmp); @@ -1976,10 +1976,10 @@ cd_client_get_devices_cb (GObject *source_object, { CdClient *client; GPtrArray *array; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; client = CD_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (res_source))); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), @@ -2078,10 +2078,10 @@ cd_client_get_devices_by_kind_cb (GObject *source_object, { CdClient *client; GPtrArray *array; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; client = CD_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (res_source))); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), @@ -2158,14 +2158,14 @@ cd_client_get_profile_array_from_variant (CdClient *client, GVariantIter iter; guint i; guint len; - _cleanup_variant_unref_ GVariant *child = NULL; + g_autoptr(GVariant) child = NULL; /* add each profile */ array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); child = g_variant_get_child_value (result, 0); len = g_variant_iter_init (&iter, child); for (i = 0; i < len; i++) { - _cleanup_free_ gchar *object_path_tmp = NULL; + g_autofree gchar *object_path_tmp = NULL; g_variant_get_child (child, i, "o", &object_path_tmp); profile = cd_profile_new_with_object_path (object_path_tmp); @@ -2211,10 +2211,10 @@ cd_client_get_profiles_cb (GObject *source_object, { CdClient *client; GPtrArray *array; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; client = CD_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (res_source))); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), @@ -2288,14 +2288,14 @@ cd_client_get_sensor_array_from_variant (CdClient *client, GVariantIter iter; guint i; guint len; - _cleanup_variant_unref_ GVariant *child = NULL; + g_autoptr(GVariant) child = NULL; /* add each sensor */ array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); child = g_variant_get_child_value (result, 0); len = g_variant_iter_init (&iter, child); for (i = 0; i < len; i++) { - _cleanup_free_ gchar *object_path_tmp = NULL; + g_autofree gchar *object_path_tmp = NULL; g_variant_get_child (child, i, "o", &object_path_tmp); sensor = cd_sensor_new_with_object_path (object_path_tmp); @@ -2341,10 +2341,10 @@ cd_client_get_sensors_cb (GObject *source_object, { CdClient *client; GPtrArray *array; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; client = CD_CLIENT (g_async_result_get_source_object (G_ASYNC_RESULT (res_source))); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), @@ -2442,10 +2442,10 @@ cd_client_find_profile_by_property_cb (GObject *source_object, gpointer user_data) { CdProfile *profile; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -2550,10 +2550,10 @@ cd_client_find_sensor_cb (GObject *source_object, gpointer user_data) { CdSensor *sensor; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *object_path = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, diff --git a/lib/colord/cd-device.c b/lib/colord/cd-device.c index 6906cd3..2252400 100644 --- a/lib/colord/cd-device.c +++ b/lib/colord/cd-device.c @@ -496,7 +496,7 @@ cd_device_set_profiles_array_from_variant (CdDevice *device, return; len = g_variant_n_children (profiles); for (i = 0; i < len; i++) { - _cleanup_free_ gchar *object_path_tmp = NULL; + g_autofree gchar *object_path_tmp = NULL; g_variant_get_child (profiles, i, "o", &object_path_tmp); profile_tmp = cd_profile_new_with_object_path (object_path_tmp); @@ -720,26 +720,26 @@ cd_device_connect_cb (GObject *source_object, gpointer user_data) { CdDevice *device; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *colorspace = NULL; - _cleanup_variant_unref_ GVariant *created = NULL; - _cleanup_variant_unref_ GVariant *embedded = NULL; - _cleanup_variant_unref_ GVariant *enabled = NULL; - _cleanup_variant_unref_ GVariant *format = NULL; - _cleanup_variant_unref_ GVariant *id = NULL; - _cleanup_variant_unref_ GVariant *kind = NULL; - _cleanup_variant_unref_ GVariant *metadata = NULL; - _cleanup_variant_unref_ GVariant *model = NULL; - _cleanup_variant_unref_ GVariant *mode = NULL; - _cleanup_variant_unref_ GVariant *modified = NULL; - _cleanup_variant_unref_ GVariant *owner = NULL; - _cleanup_variant_unref_ GVariant *profiles = NULL; - _cleanup_variant_unref_ GVariant *profiling_inhibitors = NULL; - _cleanup_variant_unref_ GVariant *scope = NULL; - _cleanup_variant_unref_ GVariant *seat = NULL; - _cleanup_variant_unref_ GVariant *serial = NULL; - _cleanup_variant_unref_ GVariant *vendor = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) colorspace = NULL; + g_autoptr(GVariant) created = NULL; + g_autoptr(GVariant) embedded = NULL; + g_autoptr(GVariant) enabled = NULL; + g_autoptr(GVariant) format = NULL; + g_autoptr(GVariant) id = NULL; + g_autoptr(GVariant) kind = NULL; + g_autoptr(GVariant) metadata = NULL; + g_autoptr(GVariant) model = NULL; + g_autoptr(GVariant) mode = NULL; + g_autoptr(GVariant) modified = NULL; + g_autoptr(GVariant) owner = NULL; + g_autoptr(GVariant) profiles = NULL; + g_autoptr(GVariant) profiling_inhibitors = NULL; + g_autoptr(GVariant) scope = NULL; + g_autoptr(GVariant) seat = NULL; + g_autoptr(GVariant) serial = NULL; + g_autoptr(GVariant) vendor = NULL; device = CD_DEVICE (g_async_result_get_source_object (G_ASYNC_RESULT (user_data))); device->priv->proxy = g_dbus_proxy_new_for_bus_finish (res, @@ -977,7 +977,7 @@ cd_device_set_property_finish (CdDevice *device, static void cd_device_fixup_dbus_error (GError *error) { - _cleanup_free_ gchar *name = NULL; + g_autofree gchar *name = NULL; g_return_if_fail (error != NULL); @@ -997,9 +997,9 @@ cd_device_set_property_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1097,9 +1097,9 @@ cd_device_add_profile_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1197,9 +1197,9 @@ cd_device_remove_profile_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1294,9 +1294,9 @@ cd_device_make_profile_default_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1391,9 +1391,9 @@ cd_device_profiling_inhibit_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1485,9 +1485,9 @@ cd_device_profiling_uninhibit_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_variant_unref_ GVariant *result = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GError) error = NULL; + g_autoptr(GVariant) result = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1579,11 +1579,11 @@ cd_device_get_profile_for_qualifiers_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GVariant) result = NULL; CdProfile *profile; gchar *object_path = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1694,10 +1694,10 @@ cd_device_get_profile_relation_cb (GObject *source_object, gpointer user_data) { CdDeviceRelation relation; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *relation_string = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *relation_string = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1796,9 +1796,9 @@ cd_device_set_enabled_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, diff --git a/lib/colord/cd-dom.c b/lib/colord/cd-dom.c index 4936323..dce2e8f 100644 --- a/lib/colord/cd-dom.c +++ b/lib/colord/cd-dom.c @@ -222,7 +222,7 @@ cd_dom_parse_xml_data (CdDom *dom, gssize data_len, GError **error) { - _cleanup_markup_parse_context_unref_ GMarkupParseContext *ctx = NULL; + g_autoptr(GMarkupParseContext) ctx = NULL; const GMarkupParser parser = { cd_dom_start_element_cb, cd_dom_end_element_cb, @@ -408,7 +408,7 @@ cd_dom_get_node (CdDom *dom, const GNode *root, const gchar *path) { const GNode *node; guint i; - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; g_return_val_if_fail (CD_IS_DOM (dom), NULL); g_return_val_if_fail (path != NULL, NULL); diff --git a/lib/colord/cd-edid.c b/lib/colord/cd-edid.c index 61e9cff..5c4f68f 100644 --- a/lib/colord/cd-edid.c +++ b/lib/colord/cd-edid.c @@ -117,7 +117,7 @@ cd_edid_convert_pnp_id_to_string (const gchar *pnp_id) struct udev_list_entry *e; struct udev_list_entry *v; struct udev *udev; - _cleanup_free_ gchar *modalias = NULL; + g_autofree gchar *modalias = NULL; /* connect to the hwdb */ udev = udev_new (); @@ -155,7 +155,7 @@ out: "/usr/share/misc/pnp.ids", "/usr/share/libgnome-desktop/pnp.ids", NULL }; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; for (i = 0; pnp_ids[i] != NULL; i++) { ret = g_file_get_contents (pnp_ids[i], &data, NULL, NULL); diff --git a/lib/colord/cd-icc-store.c b/lib/colord/cd-icc-store.c index c902a72..5a7c3f1 100644 --- a/lib/colord/cd-icc-store.c +++ b/lib/colord/cd-icc-store.c @@ -194,8 +194,8 @@ static gboolean cd_icc_store_add_icc (CdIccStore *store, GFile *file, GError **error) { CdIccStorePrivate *priv = store->priv; - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *filename = NULL; _cleanup_object_unref_ CdIcc *icc = NULL; _cleanup_object_unref_ CdIcc *icc_tmp = NULL; @@ -204,7 +204,7 @@ cd_icc_store_add_icc (CdIccStore *store, GFile *file, GError **error) filename = g_file_get_path (file); if (store->priv->cache != NULL) { if (g_str_has_prefix (filename, "/usr/share/color/icc/colord/")) { - _cleanup_free_ gchar *cache_key = NULL; + g_autofree gchar *cache_key = NULL; cache_key = g_build_filename ("/org/freedesktop/colord", "profiles", filename + 28, @@ -218,7 +218,7 @@ cd_icc_store_add_icc (CdIccStore *store, GFile *file, GError **error) /* parse new icc object */ if (data != NULL) { - _cleanup_free_ gchar *basename = NULL; + g_autofree gchar *basename = NULL; basename = g_path_get_basename (filename); g_debug ("Using built-in %s", basename); cd_icc_set_filename (icc, filename); @@ -269,10 +269,10 @@ cd_icc_store_created_query_info_cb (GObject *source_object, CdIccStore *store = CD_ICC_STORE (user_data); GFile *file = G_FILE (source_object); gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *path = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; - _cleanup_object_unref_ GFile *parent = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *path = NULL; + g_autoptr(GFileInfo) info = NULL; + g_autoptr(GFile) parent = NULL; info = g_file_query_info_finish (file, res, NULL); if (info == NULL) @@ -318,7 +318,7 @@ cd_icc_store_file_monitor_changed_cb (GFileMonitor *monitor, { CdIcc *tmp; CdIccStoreDirHelper *helper; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; /* icc was deleted */ if (event_type == G_FILE_MONITOR_EVENT_DELETED) { @@ -379,8 +379,8 @@ cd_icc_store_search_path_child (CdIccStore *store, { const gchar *name; const gchar *type; - _cleanup_free_ gchar *full_path = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *full_path = NULL; + g_autoptr(GFile) file = NULL; /* further down the worm-hole */ name = g_file_info_get_name (info); @@ -424,9 +424,9 @@ cd_icc_store_search_path (CdIccStore *store, CdIccStoreDirHelper *helper; GError *error_local = NULL; gboolean ret = TRUE; - _cleanup_object_unref_ GFileEnumerator *enumerator = NULL; - _cleanup_object_unref_ GFile *file = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; + g_autoptr(GFileEnumerator) enumerator = NULL; + g_autoptr(GFile) file = NULL; + g_autoptr(GFileInfo) info = NULL; /* check sanity */ if (depth > CD_ICC_STORE_MAX_RECURSION_LEVELS) { @@ -597,7 +597,7 @@ cd_icc_store_search_kind (CdIccStore *store, { gchar *tmp; guint i; - _cleanup_ptrarray_unref_ GPtrArray *locations = NULL; + g_autoptr(GPtrArray) locations = NULL; g_return_val_if_fail (CD_IS_ICC_STORE (store), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -661,7 +661,7 @@ cd_icc_store_search_location (CdIccStore *store, GCancellable *cancellable, GError **error) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; g_return_val_if_fail (CD_IS_ICC_STORE (store), FALSE); g_return_val_if_fail (location != NULL, FALSE); diff --git a/lib/colord/cd-icc-utils.c b/lib/colord/cd-icc-utils.c index 8611206..31915f7 100644 --- a/lib/colord/cd-icc-utils.c +++ b/lib/colord/cd-icc-utils.c @@ -72,8 +72,8 @@ cd_icc_utils_get_coverage_calc (CdIcc *icc, guint cnt = 0; guint data_len = cube_size * cube_size * cube_size; guint i; - _cleanup_free_ cmsFloat32Number *data = NULL; - _cleanup_free_ cmsUInt16Number *alarm_codes = NULL; + g_autofree cmsFloat32Number *data = NULL; + g_autofree cmsUInt16Number *alarm_codes = NULL; /* create a proofing transform with gamut check */ profile_null = cmsCreateNULLProfileTHR (cd_icc_get_context (icc)); diff --git a/lib/colord/cd-icc.c b/lib/colord/cd-icc.c index 1eedf9e..4bce0f5 100644 --- a/lib/colord/cd-icc.c +++ b/lib/colord/cd-icc.c @@ -292,7 +292,7 @@ cd_icc_to_string (CdIcc *icc) /* date and time */ created = cd_icc_get_created (icc); if (created != NULL) { - _cleanup_free_ gchar *created_str = NULL; + g_autofree gchar *created_str = NULL; created_str = g_date_time_format (created, "%F, %T"); g_string_append_printf (str, " Date, Time\t= %s\n", created_str); g_date_time_unref (created); @@ -410,9 +410,9 @@ cd_icc_to_string (CdIcc *icc) gchar country_code[3] = "\0\0\0"; gchar language_code[3] = "\0\0\0"; guint32 text_size; - _cleanup_free_ gchar *text_buffer = NULL; - _cleanup_free_ gunichar *wtext = NULL; - _cleanup_error_free_ GError *error = NULL; + g_autofree gchar *text_buffer = NULL; + g_autofree gunichar *wtext = NULL; + g_autoptr(GError) error = NULL; ret = cmsMLUtranslationsCodes (mlu, j, @@ -548,8 +548,8 @@ cd_icc_to_string (CdIcc *icc) for (entry = cmsDictGetEntryList (dict); entry != NULL; entry = cmsDictNextEntry (entry)) { - _cleanup_free_ gchar *ascii_name = NULL; - _cleanup_free_ gchar *ascii_value = NULL; + g_autofree gchar *ascii_name = NULL; + g_autofree gchar *ascii_value = NULL; /* convert from wchar_t to UTF-8 */ ascii_name = g_ucs4_to_utf8 ((gunichar *) entry->Name, -1, @@ -604,7 +604,7 @@ cd_icc_to_string (CdIcc *icc) continue; } for (j = 0; j < tmp; j++) { - _cleanup_string_free_ GString *string = NULL; + g_autoptr(GString) string = NULL; /* parse title */ string = g_string_new (""); @@ -1043,9 +1043,9 @@ cd_icc_load_metadata_item (CdIcc *icc, const gunichar *value, GError **error) { - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *ascii_name = NULL; - _cleanup_free_ gchar *ascii_value = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *ascii_name = NULL; + g_autofree gchar *ascii_value = NULL; /* parse name */ ascii_name = g_ucs4_to_utf8 (name, -1, NULL, NULL, &error_local); @@ -1254,8 +1254,8 @@ cd_util_write_dict_entry (cmsHANDLE dict, GError **error) { gboolean ret = FALSE; - _cleanup_free_ gunichar *mb_key = NULL; - _cleanup_free_ gunichar *mb_value = NULL; + g_autofree gunichar *mb_key = NULL; + g_autofree gunichar *mb_value = NULL; mb_key = g_utf8_to_ucs4 (key, -1, NULL, NULL, error); if (mb_key == NULL) @@ -1307,8 +1307,8 @@ cd_util_mlu_object_parse (const gchar *locale, CdMluObject *obj = NULL; guint type; gunichar *wtext; - _cleanup_free_ gchar *key = NULL; - _cleanup_strv_free_ gchar **split = NULL; + g_autofree gchar *key = NULL; + g_auto(GStrv) split = NULL; /* untranslated version */ if (locale == NULL || locale[0] == '\0') { @@ -1438,8 +1438,8 @@ cd_util_write_tag_localized (CdIcc *icc, const gchar *value; gboolean ret = TRUE; guint i; - _cleanup_list_free_ GList *keys = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GList) keys = NULL; + g_autoptr(GPtrArray) array = NULL; /* convert all the hash entries into CdMluObject's */ keys = g_hash_table_get_keys (hash); @@ -1513,7 +1513,7 @@ out: static gboolean cd_icc_save_file_mkdir_parents (GFile *file, GError **error) { - _cleanup_object_unref_ GFile *parent_dir = NULL; + g_autoptr(GFile) parent_dir = NULL; /* get parent directory */ parent_dir = g_file_get_parent (file); @@ -1542,7 +1542,7 @@ cd_icc_serialize_profile (CdIcc *icc, GError **error) CdIccPrivate *priv = icc->priv; cmsUInt32Number length = 0; gboolean ret; - _cleanup_free_ gchar *data_tmp = NULL; + g_autofree gchar *data_tmp = NULL; /* get size of profile */ ret = cmsSaveProfileToMem (priv->lcms_profile, @@ -1607,7 +1607,7 @@ cd_icc_save_data (CdIcc *icc, GBytes *data = NULL; GList *l; guint i; - _cleanup_list_free_ GList *md_keys = NULL; + g_autoptr(GList) md_keys = NULL; g_return_val_if_fail (CD_IS_ICC (icc), FALSE); @@ -1807,8 +1807,8 @@ cd_icc_save_file (CdIcc *icc, GError **error) { gboolean ret; - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GBytes) data = NULL; + g_autoptr(GError) error_local = NULL; g_return_val_if_fail (CD_IS_ICC (icc), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); @@ -1863,9 +1863,9 @@ cd_icc_save_default (CdIcc *icc, GError **error) { const gchar *root = "edid"; /* TODO: only for cd_icc_create_from_edid() */ - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file = NULL; g_return_val_if_fail (CD_IS_ICC (icc), FALSE); @@ -1915,9 +1915,9 @@ cd_icc_load_file (CdIcc *icc, CdIccPrivate *priv = icc->priv; gboolean ret = FALSE; gsize length; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *data = NULL; - _cleanup_object_unref_ GFileInfo *info = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *data = NULL; + g_autoptr(GFileInfo) info = NULL; g_return_val_if_fail (CD_IS_ICC (icc), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); @@ -2510,9 +2510,9 @@ cd_icc_get_mluc_data (CdIcc *icc, gchar *tmp; guint32 text_size; guint i; - _cleanup_free_ gchar *locale_key = NULL; - _cleanup_free_ gchar *text_buffer = NULL; - _cleanup_free_ gunichar *wtext = NULL; + g_autofree gchar *locale_key = NULL; + g_autofree gchar *text_buffer = NULL; + g_autofree gunichar *wtext = NULL; g_return_val_if_fail (CD_IS_ICC (icc), NULL); @@ -2745,7 +2745,7 @@ cd_icc_set_description_items (CdIcc *icc, GHashTable *values) GList *l; const gchar *key; const gchar *value; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; g_return_if_fail (CD_IS_ICC (icc)); @@ -2793,7 +2793,7 @@ cd_icc_set_copyright_items (CdIcc *icc, GHashTable *values) const gchar *key; const gchar *value; GList *l; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; g_return_if_fail (CD_IS_ICC (icc)); @@ -2841,7 +2841,7 @@ cd_icc_set_manufacturer_items (CdIcc *icc, GHashTable *values) const gchar *key; const gchar *value; GList *l; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; g_return_if_fail (CD_IS_ICC (icc)); @@ -2889,7 +2889,7 @@ cd_icc_set_model_items (CdIcc *icc, GHashTable *values) const gchar *key; const gchar *value; GList *l; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; g_return_if_fail (CD_IS_ICC (icc)); @@ -3281,8 +3281,8 @@ cd_icc_get_response (CdIcc *icc, guint size, GError **error) gfloat divamount; GPtrArray *array = NULL; guint i; - _cleanup_free_ gdouble *values_in = NULL; - _cleanup_free_ gdouble *values_out = NULL; + g_autofree gdouble *values_in = NULL; + g_autofree gdouble *values_out = NULL; /* run through the icc */ colorspace = cd_icc_get_colorspace (icc); @@ -3377,9 +3377,9 @@ cd_icc_set_vcgt (CdIcc *icc, GPtrArray *vcgt, GError **error) cmsToneCurve *curve[3]; gboolean ret; guint i; - _cleanup_free_ guint16 *blue = NULL; - _cleanup_free_ guint16 *green = NULL; - _cleanup_free_ guint16 *red = NULL; + g_autofree guint16 *blue = NULL; + g_autofree guint16 *green = NULL; + g_autofree guint16 *red = NULL; g_return_val_if_fail (CD_IS_ICC (icc), FALSE); g_return_val_if_fail (icc->priv->lcms_profile != NULL, FALSE); diff --git a/lib/colord/cd-interp-akima.c b/lib/colord/cd-interp-akima.c index 2a581fa..980069a 100644 --- a/lib/colord/cd-interp-akima.c +++ b/lib/colord/cd-interp-akima.c @@ -69,9 +69,9 @@ cd_interp_akima_prepare (CdInterp *interp, GError **error) gint n; GArray *array_x; GArray *array_y; - _cleanup_free_ gdouble *dx = NULL; - _cleanup_free_ gdouble *dy = NULL; - _cleanup_free_ gdouble *slope_m = NULL; + g_autofree gdouble *dx = NULL; + g_autofree gdouble *dy = NULL; + g_autofree gdouble *slope_m = NULL; /* only add the points if they are going to be used */ if (cd_interp_get_size (interp) <= 2) diff --git a/lib/colord/cd-it8-utils.c b/lib/colord/cd-it8-utils.c index dc2786b..7931a29 100644 --- a/lib/colord/cd-it8-utils.c +++ b/lib/colord/cd-it8-utils.c @@ -194,7 +194,7 @@ cd_it8_utils_calculate_ccmx (CdIt8 *it8_reference, gdouble m_lumi = 0.0f; gdouble n_lumi = 0.0f; guint i; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; /* read reference matrix */ if (!ch_it8_utils_4color_decompose (it8_reference, &n_rgb, &n_lumi, error)) @@ -494,7 +494,7 @@ cd_it8_utils_calculate_gamma (CdIt8 *it8, gdouble *gamma_y, GError **error) guint cnt = 0; guint i; gdouble gamma_tmp = 0.f; - _cleanup_free_ cmsFloat32Number *data_y = NULL; + g_autofree cmsFloat32Number *data_y = NULL; /* find the grey gamma ramp */ len = cd_it8_get_data_size (it8); @@ -537,7 +537,7 @@ cd_it8_utils_calculate_gamma (CdIt8 *it8, gdouble *gamma_y, GError **error) curve = cmsBuildTabulatedToneCurveFloat (NULL, cnt, data_y); gamma_tmp = cmsEstimateGamma (curve, 0.1); if (gamma_tmp < 0) { - _cleanup_string_free_ GString *str = NULL; + g_autoptr(GString) str = NULL; str = g_string_new ("Unable to calculate gamma from: "); for (i = 0; i < cnt; i++) g_string_append_printf (str, "%f, ", data_y[i]); diff --git a/lib/colord/cd-it8.c b/lib/colord/cd-it8.c index a941a88..7265b52 100644 --- a/lib/colord/cd-it8.c +++ b/lib/colord/cd-it8.c @@ -286,7 +286,7 @@ cd_it8_get_kind (CdIt8 *it8) static gboolean cd_it8_parse_luminance (const gchar *text, CdColorXYZ *xyz, GError **error) { - _cleanup_strv_free_ gchar **split = NULL; + g_auto(GStrv) split = NULL; split = g_strsplit (text, " ", -1); if (g_strv_length (split) != 3) { @@ -687,7 +687,7 @@ cd_it8_load_ccss_spect (CdIt8 *it8, cmsHANDLE it8_lcms, GError **error) cd_spectrum_set_id (spectrum, cmsIT8GetDataRowCol(it8_lcms, j, 0)); } else { - _cleanup_free_ gchar *label = NULL; + g_autofree gchar *label = NULL; label = g_strdup_printf ("%i", j + 1); cd_spectrum_set_id (spectrum, label); } @@ -861,7 +861,7 @@ cd_it8_load_from_data (CdIt8 *it8, gboolean ret = TRUE; gchar **props = NULL; guint i; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; g_return_val_if_fail (CD_IS_IT8 (it8), FALSE); g_return_val_if_fail (data != NULL, FALSE); @@ -983,7 +983,7 @@ gboolean cd_it8_load_from_file (CdIt8 *it8, GFile *file, GError **error) { gsize size = 0; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; g_return_val_if_fail (CD_IS_IT8 (it8), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); @@ -1039,7 +1039,7 @@ cd_it8_save_to_file_ti1_ti3 (CdIt8 *it8, cmsHANDLE it8_lcms, GError **error) gdouble normalize = 0.0f; guint i; guint luminance_samples = 0; - _cleanup_free_ gchar *lumi_str = NULL; + g_autofree gchar *lumi_str = NULL; /* calculate the absolute XYZ in candelas per meter squared */ cd_color_xyz_clear (&lumi_xyz); @@ -1253,7 +1253,7 @@ cd_it8_save_to_file_cmf (CdIt8 *it8, cmsHANDLE it8_lcms, GError **error) /* set DATA_FORMAT (using an ID if there are more than one spectra */ spectrum = g_ptr_array_index (it8->priv->array_spectra, 0); for (i = 0; i < spectral_bands; i++) { - _cleanup_free_ gchar *label = NULL; + g_autofree gchar *label = NULL; label = g_strdup_printf ("SPEC_%.0f", cd_spectrum_get_wavelength (spectrum, i)); cmsIT8SetDataFormat (it8_lcms, i, label); @@ -1336,7 +1336,7 @@ cd_it8_save_to_file_ccss_sp (CdIt8 *it8, cmsHANDLE it8_lcms, GError **error) cmsIT8SetDataFormat (it8_lcms, 0, "SAMPLE_ID"); spectrum = g_ptr_array_index (it8->priv->array_spectra, 0); for (i = 0; i < spectral_bands; i++) { - _cleanup_free_ gchar *label = NULL; + g_autofree gchar *label = NULL; /* there are more spectral bands than integers between the * start and stop wavelengths */ if ((cd_spectrum_get_end (spectrum) - @@ -1396,8 +1396,8 @@ cd_it8_save_to_data (CdIt8 *it8, GDateTime *datetime = NULL; cmsUInt32Number size_tmp = 0; guint i; - _cleanup_free_ gchar *data_tmp = NULL; - _cleanup_free_ gchar *date_str = NULL; + g_autofree gchar *data_tmp = NULL; + g_autofree gchar *date_str = NULL; g_return_val_if_fail (CD_IS_IT8 (it8), FALSE); @@ -1501,7 +1501,7 @@ gboolean cd_it8_save_to_file (CdIt8 *it8, GFile *file, GError **error) { gsize size = 0; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; g_return_val_if_fail (CD_IS_IT8 (it8), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); diff --git a/lib/colord/cd-profile.c b/lib/colord/cd-profile.c index 8687714..0a4a305 100644 --- a/lib/colord/cd-profile.c +++ b/lib/colord/cd-profile.c @@ -620,7 +620,7 @@ cd_profile_connect_finish (CdProfile *profile, static void cd_profile_fixup_dbus_error (GError *error) { - _cleanup_free_ gchar *name = NULL; + g_autofree gchar *name = NULL; g_return_if_fail (error != NULL); @@ -641,22 +641,22 @@ cd_profile_connect_cb (GObject *source_object, gpointer user_data) { CdProfile *profile; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *colorspace = NULL; - _cleanup_variant_unref_ GVariant *created = NULL; - _cleanup_variant_unref_ GVariant *filename = NULL; - _cleanup_variant_unref_ GVariant *format = NULL; - _cleanup_variant_unref_ GVariant *has_vcgt = NULL; - _cleanup_variant_unref_ GVariant *id = NULL; - _cleanup_variant_unref_ GVariant *is_system_wide = NULL; - _cleanup_variant_unref_ GVariant *kind = NULL; - _cleanup_variant_unref_ GVariant *metadata = NULL; - _cleanup_variant_unref_ GVariant *owner = NULL; - _cleanup_variant_unref_ GVariant *qualifier = NULL; - _cleanup_variant_unref_ GVariant *scope = NULL; - _cleanup_variant_unref_ GVariant *title = NULL; - _cleanup_variant_unref_ GVariant *warnings = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) colorspace = NULL; + g_autoptr(GVariant) created = NULL; + g_autoptr(GVariant) filename = NULL; + g_autoptr(GVariant) format = NULL; + g_autoptr(GVariant) has_vcgt = NULL; + g_autoptr(GVariant) id = NULL; + g_autoptr(GVariant) is_system_wide = NULL; + g_autoptr(GVariant) kind = NULL; + g_autoptr(GVariant) metadata = NULL; + g_autoptr(GVariant) owner = NULL; + g_autoptr(GVariant) qualifier = NULL; + g_autoptr(GVariant) scope = NULL; + g_autoptr(GVariant) title = NULL; + g_autoptr(GVariant) warnings = NULL; profile = CD_PROFILE (g_async_result_get_source_object (G_ASYNC_RESULT (user_data))); profile->priv->proxy = g_dbus_proxy_new_for_bus_finish (res, @@ -866,9 +866,9 @@ cd_profile_set_property_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -970,9 +970,9 @@ cd_profile_install_system_wide_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1128,7 +1128,7 @@ cd_profile_load_icc (CdProfile *profile, GError **error) { _cleanup_object_unref_ CdIcc *icc = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; g_return_val_if_fail (CD_IS_PROFILE (profile), NULL); diff --git a/lib/colord/cd-sensor.c b/lib/colord/cd-sensor.c index c4cb38f..62288d8 100644 --- a/lib/colord/cd-sensor.c +++ b/lib/colord/cd-sensor.c @@ -500,20 +500,20 @@ cd_sensor_connect_cb (GObject *source_object, gpointer user_data) { CdSensor *sensor = CD_SENSOR (g_async_result_get_source_object (G_ASYNC_RESULT (user_data))); - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *caps = NULL; - _cleanup_variant_unref_ GVariant *embedded = NULL; - _cleanup_variant_unref_ GVariant *id = NULL; - _cleanup_variant_unref_ GVariant *kind = NULL; - _cleanup_variant_unref_ GVariant *locked = NULL; - _cleanup_variant_unref_ GVariant *metadata = NULL; - _cleanup_variant_unref_ GVariant *model = NULL; - _cleanup_variant_unref_ GVariant *mode = NULL; - _cleanup_variant_unref_ GVariant *native = NULL; - _cleanup_variant_unref_ GVariant *serial = NULL; - _cleanup_variant_unref_ GVariant *state = NULL; - _cleanup_variant_unref_ GVariant *vendor = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) caps = NULL; + g_autoptr(GVariant) embedded = NULL; + g_autoptr(GVariant) id = NULL; + g_autoptr(GVariant) kind = NULL; + g_autoptr(GVariant) locked = NULL; + g_autoptr(GVariant) metadata = NULL; + g_autoptr(GVariant) model = NULL; + g_autoptr(GVariant) mode = NULL; + g_autoptr(GVariant) native = NULL; + g_autoptr(GVariant) serial = NULL; + g_autoptr(GVariant) state = NULL; + g_autoptr(GVariant) vendor = NULL; /* get result */ sensor->priv->proxy = g_dbus_proxy_new_for_bus_finish (res, &error); @@ -736,7 +736,7 @@ cd_sensor_lock_finish (CdSensor *sensor, static void cd_sensor_fixup_dbus_error (GError *error) { - _cleanup_free_ gchar *name = NULL; + g_autofree gchar *name = NULL; g_return_if_fail (error != NULL); @@ -756,9 +756,9 @@ cd_sensor_lock_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -849,9 +849,9 @@ cd_sensor_unlock_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -942,9 +942,9 @@ cd_sensor_set_options_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, @@ -1054,9 +1054,9 @@ cd_sensor_get_sample_cb (GObject *source_object, gpointer user_data) { CdColorXYZ *xyz; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GSimpleAsyncResult *res_source = G_SIMPLE_ASYNC_RESULT (user_data); - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GSimpleAsyncResult) res_source = G_SIMPLE_ASYNC_RESULT (user_data); + g_autoptr(GVariant) result = NULL; result = g_dbus_proxy_call_finish (G_DBUS_PROXY (source_object), res, diff --git a/lib/colord/cd-test-daemon.c b/lib/colord/cd-test-daemon.c index 603792c..cd6c1db 100644 --- a/lib/colord/cd-test-daemon.c +++ b/lib/colord/cd-test-daemon.c @@ -1653,7 +1653,7 @@ colord_device_async_func (void) GHashTable *device_props; const gchar *device_name = "device_async_dave"; struct passwd *user_details; - _cleanup_free_ gchar *device_path = NULL; + g_autofree gchar *device_path = NULL; _cleanup_object_unref_ CdClient *client = NULL; /* no running colord to use */ diff --git a/lib/colord/cd-test-shared.c b/lib/colord/cd-test-shared.c index 2f5d067..a77ef97 100644 --- a/lib/colord/cd-test-shared.c +++ b/lib/colord/cd-test-shared.c @@ -37,7 +37,7 @@ cd_test_get_filename (const gchar *filename) { gchar *tmp; char full_tmp[PATH_MAX]; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; /* running in the installed system */ if (g_getenv ("INSTALLED_TESTS") != NULL) { diff --git a/lib/colord/cd-transform.c b/lib/colord/cd-transform.c index ce1b132..6a48c15 100644 --- a/lib/colord/cd-transform.c +++ b/lib/colord/cd-transform.c @@ -459,7 +459,7 @@ cd_transform_setup (CdTransform *transform, GError **error) gboolean ret = TRUE; gint lcms_intent = -1; guint i; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; /* find native rendering intent */ for (i = 0; map_rendering_intent[i].colord != CD_RENDERING_INTENT_LAST; i++) { @@ -592,7 +592,7 @@ static gboolean cd_transform_set_max_threads_default (CdTransform *transform, GError **error) { gchar *tmp; - _cleanup_free_ gchar *data = NULL; + g_autofree gchar *data = NULL; /* use "cpu cores" to work out best number of threads */ if (!g_file_get_contents ("/proc/cpuinfo", &data, NULL, error)) diff --git a/lib/colorhug/ch-device-queue.c b/lib/colorhug/ch-device-queue.c index 9ca2782..f5bb403 100644 --- a/lib/colorhug/ch-device-queue.c +++ b/lib/colorhug/ch-device-queue.c @@ -214,7 +214,7 @@ ch_device_queue_process_write_command_cb (GObject *source, guint pending_commands; ChError last_error_code = 0; GUsbDevice *device = G_USB_DEVICE (source); - _cleanup_free_ gchar *error_msg = NULL; + g_autofree gchar *error_msg = NULL; /* mark it as not in use */ device_id = g_usb_device_get_platform_id (device); diff --git a/lib/colorhug/ch-inhx32.c b/lib/colorhug/ch-inhx32.c index 0b7827e..567866a 100644 --- a/lib/colorhug/ch-inhx32.c +++ b/lib/colorhug/ch-inhx32.c @@ -82,7 +82,7 @@ ch_inhx32_to_bin_full (const gchar *in_buffer, guint j; guint len_tmp; guint type; - _cleanup_string_free_ GString *string = NULL; + g_autoptr(GString) string = NULL; g_return_val_if_fail (in_buffer != NULL, FALSE); g_return_val_if_fail (runcode_addr > 0, FALSE); diff --git a/lib/compat/cd-compat-edid.c b/lib/compat/cd-compat-edid.c index 8de1cb6..44b04df 100644 --- a/lib/compat/cd-compat-edid.c +++ b/lib/compat/cd-compat-edid.c @@ -56,12 +56,12 @@ cd_edid_install_profile (unsigned char *edid, char *profile_fn) { gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *md5 = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *md5 = NULL; _cleanup_object_unref_ CdClient *client = NULL; _cleanup_object_unref_ CdDevice *device = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; g_return_val_if_fail (profile_fn != NULL, CD_EDID_ERROR_RESOURCE); @@ -192,12 +192,12 @@ cd_edid_remove_profile (unsigned char *edid, char *profile_fn) { gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *md5 = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *md5 = NULL; _cleanup_object_unref_ CdClient *client = NULL; _cleanup_object_unref_ CdDevice *device = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; g_return_val_if_fail (profile_fn != NULL, CD_EDID_ERROR_RESOURCE); @@ -289,8 +289,8 @@ cd_edid_get_profile (unsigned char *edid, { const gchar *filename; gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *md5 = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *md5 = NULL; _cleanup_object_unref_ CdClient *client = NULL; _cleanup_object_unref_ CdDevice *device = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; diff --git a/lib/ospark/osp-device.c b/lib/ospark/osp-device.c index 8dff30f..8a9438d 100644 --- a/lib/ospark/osp-device.c +++ b/lib/ospark/osp-device.c @@ -93,9 +93,9 @@ osp_device_query (GUsbDevice *device, OspCmd cmd, gsize offset_rd = 0; gsize offset_wr = 0; guint i; - _cleanup_checksum_free_ GChecksum *csum = NULL; - _cleanup_free_ guint8 *buffer_in = NULL; - _cleanup_free_ guint8 *buffer_out = NULL; + g_autoptr(GChecksum) csum = NULL; + g_autofree guint8 *buffer_in = NULL; + g_autofree guint8 *buffer_out = NULL; g_return_val_if_fail (G_USB_IS_DEVICE (device), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -237,7 +237,7 @@ gchar * osp_device_get_serial (GUsbDevice *device, GError **error) { gsize data_len; - _cleanup_free_ guint8 *data = NULL; + g_autofree guint8 *data = NULL; g_return_val_if_fail (G_USB_IS_DEVICE (device), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -269,7 +269,7 @@ gchar * osp_device_get_fw_version (GUsbDevice *device, GError **error) { gsize data_len; - _cleanup_free_ guint8 *data = NULL; + g_autofree guint8 *data = NULL; g_return_val_if_fail (G_USB_IS_DEVICE (device), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -306,7 +306,7 @@ osp_device_take_spectrum (GUsbDevice *device, GError **error) guint32 sample_duration = 100000; /* us */ guint8 bin_factor = 0; guint i; - _cleanup_free_ guint8 *data = NULL; + g_autofree guint8 *data = NULL; g_return_val_if_fail (G_USB_IS_DEVICE (device), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); diff --git a/lib/ospark/osp-self-test.c b/lib/ospark/osp-self-test.c index f367e22..0010651 100644 --- a/lib/ospark/osp-self-test.c +++ b/lib/ospark/osp-self-test.c @@ -36,7 +36,7 @@ static GUsbDevice * osp_client_get_default (GError **error) { _cleanup_object_unref_ GUsbContext *usb_ctx = NULL; - _cleanup_object_unref_ GUsbDevice *device = NULL; + g_autoptr(GUsbDevice) device = NULL; g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -70,9 +70,9 @@ osp_test_protocol_func (void) guint8 cmd[4]; guint i; guint j; - _cleanup_strv_free_ gchar **lines = NULL; - _cleanup_free_ gchar *data = NULL; - _cleanup_error_free_ GError *error = NULL; + g_auto(GStrv) lines = NULL; + g_autofree gchar *data = NULL; + g_autoptr(GError) error = NULL; if (!g_file_test ("protocol-dump.csv", G_FILE_TEST_EXISTS)) return; @@ -81,7 +81,7 @@ osp_test_protocol_func (void) lines = g_strsplit (data, "\n", -1); for (i = 0; lines[i] != NULL; i++) { - _cleanup_strv_free_ gchar **tokens = NULL; + g_auto(GStrv) tokens = NULL; tmp = g_strstr_len (lines[i], -1, "OUT txn"); if (tmp == NULL) continue; @@ -98,10 +98,10 @@ osp_test_reading_xyz_func (void) { CdSpectrum *sp; guint i, j; - _cleanup_error_free_ GError *error = NULL; - _cleanup_object_unref_ GUsbDevice *device = NULL; - _cleanup_free_ gchar *serial = NULL; - _cleanup_free_ gchar *fwver = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GUsbDevice) device = NULL; + g_autofree gchar *serial = NULL; + g_autofree gchar *fwver = NULL; /* load the device */ device = osp_client_get_default (&error); diff --git a/src/cd-common.c b/src/cd-common.c index c806e92..bc86a8d 100644 --- a/src/cd-common.c +++ b/src/cd-common.c @@ -74,7 +74,7 @@ cd_main_get_sender_uid (GDBusConnection *connection, GError **error) { guint uid = G_MAXUINT; - _cleanup_variant_unref_ GVariant *value = NULL; + g_autoptr(GVariant) value = NULL; /* call into DBus to get the user ID that issued the request */ value = g_dbus_connection_call_sync (connection, @@ -103,7 +103,7 @@ cd_main_get_sender_pid (GDBusConnection *connection, GError **error) { guint pid = G_MAXUINT; - _cleanup_variant_unref_ GVariant *value = NULL; + g_autoptr(GVariant) value = NULL; /* call into DBus to get the user ID that issued the request */ value = g_dbus_connection_call_sync (connection, @@ -133,7 +133,7 @@ cd_main_sender_authenticated (GDBusConnection *connection, GError **error) { guint uid; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; #ifdef USE_POLKIT _cleanup_object_unref_ PolkitAuthority *authority = NULL; _cleanup_object_unref_ PolkitAuthorizationResult *result = NULL; @@ -223,7 +223,7 @@ cd_main_mkdir_with_parents (const gchar *filename, GError **error) { /* ensure desination exists */ if (!g_file_test (filename, G_FILE_TEST_EXISTS)) { - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; file = g_file_new_for_path (filename); return g_file_make_directory_with_parents (file, NULL, error); } diff --git a/src/cd-device-db.c b/src/cd-device-db.c index 6c369cf..f07a131 100644 --- a/src/cd-device-db.c +++ b/src/cd-device-db.c @@ -53,7 +53,7 @@ cd_device_db_load (CdDeviceDb *ddb, const gchar *statement; gchar *error_msg = NULL; gint rc; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; g_return_val_if_fail (CD_IS_DEVICE_DB (ddb), FALSE); g_return_val_if_fail (ddb->priv->db == NULL, FALSE); @@ -297,7 +297,7 @@ cd_device_db_get_property (CdDeviceDb *ddb, gchar *statement; gint rc; gchar *value = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_tmp = NULL; + g_autoptr(GPtrArray) array_tmp = NULL; g_return_val_if_fail (CD_IS_DEVICE_DB (ddb), NULL); g_return_val_if_fail (ddb->priv->db != NULL, NULL); @@ -353,7 +353,7 @@ cd_device_db_get_devices (CdDeviceDb *ddb, gchar *statement; gint rc; GPtrArray *array = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_tmp = NULL; + g_autoptr(GPtrArray) array_tmp = NULL; g_return_val_if_fail (CD_IS_DEVICE_DB (ddb), NULL); g_return_val_if_fail (ddb->priv->db != NULL, NULL); @@ -396,7 +396,7 @@ cd_device_db_get_properties (CdDeviceDb *ddb, gchar *statement; gint rc; GPtrArray *array = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_tmp = NULL; + g_autoptr(GPtrArray) array_tmp = NULL; g_return_val_if_fail (CD_IS_DEVICE_DB (ddb), NULL); g_return_val_if_fail (ddb->priv->db != NULL, NULL); diff --git a/src/cd-device.c b/src/cd-device.c index 9367baf..d170565 100644 --- a/src/cd-device.c +++ b/src/cd-device.c @@ -289,8 +289,8 @@ cd_device_set_object_path (CdDevice *device) #ifdef HAVE_PWD_H struct passwd *pw; #endif - _cleanup_free_ gchar *path_owner = NULL; - _cleanup_free_ gchar *path_tmp = NULL; + g_autofree gchar *path_owner = NULL; + g_autofree gchar *path_tmp = NULL; /* append the uid to the object path */ #ifdef HAVE_PWD_H @@ -328,7 +328,7 @@ cd_device_set_object_path (CdDevice *device) void cd_device_set_id (CdDevice *device, const gchar *id) { - _cleanup_free_ gchar *enabled_str = NULL; + g_autofree gchar *enabled_str = NULL; g_return_if_fail (CD_IS_DEVICE (device)); @@ -445,8 +445,8 @@ static gboolean cd_device_match_qualifier (const gchar *qual1, const gchar *qual2) { guint i; - _cleanup_strv_free_ gchar **split1 = NULL; - _cleanup_strv_free_ gchar **split2 = NULL; + g_auto(GStrv) split1 = NULL; + g_auto(GStrv) split2 = NULL; /* split into substring */ split1 = g_strsplit (qual1, ".", 3); @@ -551,7 +551,7 @@ cd_device_get_profiles_as_variant (CdDevice *device) const gchar *tmp; guint i; guint idx = 0; - _cleanup_free_ GVariant **profiles = NULL; + g_autofree GVariant **profiles = NULL; /* Object paths are assembled in this order: * @@ -789,7 +789,7 @@ cd_device_set_property_to_db (CdDevice *device, const gchar *value) { gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; if (device->priv->object_scope != CD_OBJECT_SCOPE_DISK) return; @@ -813,7 +813,7 @@ cd_device_get_metadata_as_variant (CdDevice *device) { GList *l; GVariantBuilder builder; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GList) list = NULL; /* do not try to build an empty array */ if (g_hash_table_size (device->priv->metadata) == 0) @@ -1069,7 +1069,7 @@ cd_device_set_enabled (CdDevice *device, { CdDevicePrivate *priv = device->priv; gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; /* device is already the correct state */ if (priv->enabled == enabled) @@ -1126,7 +1126,7 @@ cd_device_dbus_method_call (GDBusConnection *connection, const gchar *sender, const gchar *property_value = NULL; gboolean ret; guint i = 0; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* return '' */ if (g_strcmp0 (method_name, "AddProfile") == 0) { @@ -1277,7 +1277,7 @@ cd_device_dbus_method_call (GDBusConnection *connection, const gchar *sender, /* return 'o' */ if (g_strcmp0 (method_name, "GetProfileForQualifiers") == 0) { gchar **regexes = NULL; - _cleanup_free_ gchar *strv_debug = NULL; + g_autofree gchar *strv_debug = NULL; /* find the profile by the qualifier search string */ g_variant_get (parameters, "(^a&s)", ®exes); @@ -1537,7 +1537,7 @@ cd_device_dbus_get_property (GDBusConnection *connection_, const gchar *sender, { CdDevice *device = CD_DEVICE (user_data); CdDevicePrivate *priv = device->priv; - _cleanup_strv_free_ gchar **bus_names = NULL; + g_auto(GStrv) bus_names = NULL; if (g_strcmp0 (property_name, CD_DEVICE_PROPERTY_CREATED) == 0) return g_variant_new_uint64 (priv->created); @@ -1596,7 +1596,7 @@ cd_device_register_object (CdDevice *device, GDBusInterfaceInfo *info, GError **error) { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; static const GDBusInterfaceVTable interface_vtable = { cd_device_dbus_method_call, diff --git a/src/cd-inhibit.c b/src/cd-inhibit.c index bc660aa..9ff7746 100644 --- a/src/cd-inhibit.c +++ b/src/cd-inhibit.c @@ -161,7 +161,7 @@ cd_inhibit_name_vanished_cb (GDBusConnection *connection, gpointer user_data) { CdInhibit *inhibit = CD_INHIBIT (user_data); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* just remove */ if (!cd_inhibit_remove (inhibit, name, &error)) { diff --git a/src/cd-main.c b/src/cd-main.c index 37817e3..4ab2eec 100644 --- a/src/cd-main.c +++ b/src/cd-main.c @@ -82,8 +82,8 @@ cd_main_profile_removed (CdMainPrivate *priv, CdProfile *profile) CdDevice *device_tmp; gboolean ret; guint i; - _cleanup_free_ gchar *object_path_tmp = NULL; - _cleanup_ptrarray_unref_ GPtrArray *devices = NULL; + g_autofree gchar *object_path_tmp = NULL; + g_autoptr(GPtrArray) devices = NULL; /* remove from the array before emitting */ object_path_tmp = g_strdup (cd_profile_get_object_path (profile)); @@ -141,7 +141,7 @@ cd_main_device_removed (CdMainPrivate *priv, CdDevice *device) { GError *error = NULL; gboolean ret; - _cleanup_free_ gchar *object_path_tmp = NULL; + g_autofree gchar *object_path_tmp = NULL; /* remove from the array before emitting */ object_path_tmp = g_strdup (cd_device_get_object_path (device)); @@ -276,7 +276,7 @@ cd_main_auto_add_from_md (CdMainPrivate *priv, const gchar **warnings; gboolean ret; guint64 timestamp; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* check device and profile hasn't been manually removed */ profile_id = cd_profile_get_id (profile); @@ -332,7 +332,7 @@ cd_main_auto_add_from_db (CdMainPrivate *priv, { gboolean ret; guint64 timestamp; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; g_debug ("CdMain: Automatically DB add %s to %s", cd_profile_get_id (profile), @@ -371,7 +371,7 @@ cd_main_device_auto_add_from_md (CdMainPrivate *priv, { CdProfile *profile_tmp; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* get all the profiles, and check to see if any of them contain * MAPPING_device_id that matches the device */ @@ -396,8 +396,8 @@ cd_main_device_auto_add_from_db (CdMainPrivate *priv, CdDevice *device) const gchar *object_id_tmp; guint64 timestamp; guint i; - _cleanup_error_free_ GError *error = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GPtrArray) array = NULL; /* get data */ array = cd_mapping_db_get_profiles (priv->mapping_db, @@ -568,7 +568,7 @@ cd_main_create_device (CdMainPrivate *priv, CdDeviceMode mode, GError **error) { - _cleanup_free_ gchar *seat = NULL; + g_autofree gchar *seat = NULL; _cleanup_object_unref_ CdDevice *device_tmp = NULL; g_assert (priv->connection != NULL); @@ -605,7 +605,7 @@ cd_main_device_array_to_variant (GPtrArray *array, guint uid) CdDevice *device; guint i; guint length = 0; - _cleanup_free_ GVariant **variant_array = NULL; + g_autofree GVariant **variant_array = NULL; /* copy the object paths */ variant_array = g_new0 (GVariant *, array->len + 1); @@ -641,7 +641,7 @@ cd_main_profile_array_to_variant (GPtrArray *array) CdProfile *profile; guint i; guint length = 0; - _cleanup_free_ GVariant **variant_array = NULL; + g_autofree GVariant **variant_array = NULL; /* copy the object paths */ variant_array = g_new0 (GVariant *, array->len + 1); @@ -667,7 +667,7 @@ cd_main_sensor_array_to_variant (GPtrArray *array) CdSensor *sensor; guint i; guint length = 0; - _cleanup_free_ GVariant **variant_array = NULL; + g_autofree GVariant **variant_array = NULL; /* copy the object paths */ variant_array = g_new0 (GVariant *, array->len + 1); @@ -692,8 +692,8 @@ cd_main_profile_auto_add_from_db (CdMainPrivate *priv, CdProfile *profile) { guint i; - _cleanup_error_free_ GError *error = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GPtrArray) array = NULL; /* get data */ array = cd_mapping_db_get_devices (priv->mapping_db, @@ -819,7 +819,7 @@ cd_main_get_standard_space_metadata (CdMainPrivate *priv, guint i; guint score_best = 0; guint score_tmp; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* get all the profiles with this metadata */ array = cd_profile_array_get_by_metadata (priv->profiles_array, @@ -877,8 +877,8 @@ cd_main_get_cmdline_for_pid (guint pid) gchar *cmdline = NULL; gsize len = 0; guint i; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *proc_path = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *proc_path = NULL; /* just read the link */ proc_path = g_strdup_printf ("/proc/%i/cmdline", pid); @@ -927,15 +927,15 @@ cd_main_daemon_method_call (GDBusConnection *connection, const gchar *sender, guint i; guint pid; guint uid; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *cmdline = NULL; - _cleanup_free_ gchar *device_id_fallback = NULL; - _cleanup_free_ gchar *filename = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *cmdline = NULL; + g_autofree gchar *device_id_fallback = NULL; + g_autofree gchar *filename = NULL; _cleanup_object_unref_ CdDevice *device = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; - _cleanup_variant_iter_free_ GVariantIter *iter = NULL; - _cleanup_variant_unref_ GVariant *dict = NULL; + g_autoptr(GPtrArray) array = NULL; + g_autoptr(GVariantIter) iter = NULL; + g_autoptr(GVariant) dict = NULL; /* get the owner of the message */ uid = cd_main_get_sender_uid (connection, sender, &error); @@ -1712,8 +1712,8 @@ cd_main_icc_store_added_cb (CdIccStore *icc_store, const gchar *checksum; const gchar *filename; gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *profile_id = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *profile_id = NULL; _cleanup_object_unref_ CdProfile *profile = NULL; /* create profile */ @@ -1790,9 +1790,9 @@ cd_main_add_disk_device (CdMainPrivate *priv, const gchar *device_id) const gchar *property; gboolean ret; guint i; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; _cleanup_object_unref_ CdDevice *device = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_properties = NULL; + g_autoptr(GPtrArray) array_properties = NULL; device = cd_main_create_device (priv, NULL, @@ -1821,7 +1821,7 @@ cd_main_add_disk_device (CdMainPrivate *priv, const gchar *device_id) return; } for (i = 0; i < array_properties->len; i++) { - _cleanup_free_ gchar *value = NULL; + g_autofree gchar *value = NULL; property = g_ptr_array_index (array_properties, i); value = cd_device_db_get_property (priv->device_db, device_id, @@ -1893,7 +1893,7 @@ cd_main_add_sensor (CdMainPrivate *priv, CdSensor *sensor) { const gchar *id; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; id = cd_sensor_get_id (sensor); if (id == NULL) { @@ -1973,9 +1973,9 @@ cd_main_on_name_acquired_cb (GDBusConnection *connection, const gchar *device_id; gboolean ret; guint i; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; _cleanup_object_unref_ CdSensor *sensor = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_devices = NULL; + g_autoptr(GPtrArray) array_devices = NULL; g_debug ("CdMain: acquired name: %s", name); @@ -2117,8 +2117,8 @@ cd_main_timed_exit_cb (gpointer user_data) static GDBusNodeInfo * cd_main_load_introspection (const gchar *filename, GError **error) { - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_free_ gchar *path = NULL; + g_autoptr(GBytes) data = NULL; + g_autofree gchar *path = NULL; /* lookup data */ path = g_build_filename ("/org/freedesktop/colord", filename, NULL); @@ -2154,7 +2154,7 @@ cd_main_plugin_device_added_cb (CdPlugin *plugin, { CdMainPrivate *priv = (CdMainPrivate *) user_data; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; cd_device_set_mode (device, CD_DEVICE_MODE_PHYSICAL); ret = cd_main_device_add (priv, device, NULL, &error); @@ -2260,9 +2260,9 @@ cd_main_load_plugins (CdMainPrivate *priv) { const gchar *filename_tmp; gboolean ret; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *path = NULL; + g_autoptr(GDir) dir = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *path = NULL; /* search in the plugin directory for plugins */ path = g_build_filename (LIBDIR, "colord-plugins", NULL); @@ -2276,7 +2276,7 @@ cd_main_load_plugins (CdMainPrivate *priv) /* try to open each plugin */ g_debug ("searching for plugins in %s", path); do { - _cleanup_free_ gchar *filename_plugin = NULL; + g_autofree gchar *filename_plugin = NULL; filename_tmp = g_dir_read_name (dir); if (filename_tmp == NULL) break; @@ -2311,12 +2311,12 @@ cd_main_get_edid_for_output (const gchar *output_name) { gboolean ret; gsize len = 0; - _cleanup_bytes_unref_ GBytes *data = NULL; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *edid_data = NULL; - _cleanup_free_ gchar *edid_fn = NULL; - _cleanup_free_ gchar *enabled_data = NULL; - _cleanup_free_ gchar *enabled_fn = NULL; + g_autoptr(GBytes) data = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *edid_data = NULL; + g_autofree gchar *edid_fn = NULL; + g_autofree gchar *enabled_data = NULL; + g_autofree gchar *enabled_fn = NULL; _cleanup_object_unref_ CdEdid *edid = NULL; /* check output is actually an output */ @@ -2385,8 +2385,8 @@ cd_main_check_duplicate_edids (void) { const gchar *fn; gboolean use_xrandr_mode = FALSE; - _cleanup_dir_close_ GDir *dir = NULL; - _cleanup_hashtable_unref_ GHashTable *hash = NULL; + g_autoptr(GDir) dir = NULL; + g_autoptr(GHashTable) hash = NULL; dir = g_dir_open ("/sys/class/drm", 0, NULL); if (dir == NULL) @@ -2423,7 +2423,7 @@ cd_main_dmi_get_from_filename (const gchar *filename) { gboolean ret; gchar *data = NULL; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get the contents */ ret = g_file_get_contents (filename, &data, NULL, &error); @@ -2479,7 +2479,7 @@ cd_main_dmi_get_vendor (void) "/sys/class/dmi/id/chassis_vendor", "/sys/class/dmi/id/board_vendor", NULL}; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; /* get vendor name */ tmp = cd_main_dmi_get_from_filenames (sysfs_vendor); @@ -2498,7 +2498,7 @@ cd_main_dmi_get_model (void) "/sys/class/dmi/id/board_name", NULL}; gchar *model; - _cleanup_free_ gchar *tmp = NULL; + g_autofree gchar *tmp = NULL; /* thinkpad puts the common name in the version field, urgh */ tmp = cd_main_dmi_get_from_filename ("/sys/class/dmi/id/product_version"); @@ -2548,7 +2548,7 @@ main (int argc, char *argv[]) _("Create a dummy sensor for testing"), NULL }, { NULL} }; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; setlocale (LC_ALL, ""); diff --git a/src/cd-mapping-db.c b/src/cd-mapping-db.c index 90fc059..d1d0dd5 100644 --- a/src/cd-mapping-db.c +++ b/src/cd-mapping-db.c @@ -72,7 +72,7 @@ cd_mapping_db_load (CdMappingDb *mdb, const gchar *statement; gchar *error_msg = NULL; gint rc; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; g_return_val_if_fail (CD_IS_MAPPING_DB (mdb), FALSE); g_return_val_if_fail (mdb->priv->db == NULL, FALSE); @@ -360,7 +360,7 @@ cd_mapping_db_get_profiles (CdMappingDb *mdb, gchar *statement; gint rc; GPtrArray *array = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_tmp = NULL; + g_autoptr(GPtrArray) array_tmp = NULL; g_return_val_if_fail (CD_IS_MAPPING_DB (mdb), NULL); g_return_val_if_fail (mdb->priv->db != NULL, NULL); @@ -409,7 +409,7 @@ cd_mapping_db_get_devices (CdMappingDb *mdb, gchar *statement; gint rc; GPtrArray *array = NULL; - _cleanup_ptrarray_unref_ GPtrArray *array_tmp = NULL; + g_autoptr(GPtrArray) array_tmp = NULL; g_return_val_if_fail (CD_IS_MAPPING_DB (mdb), NULL); g_return_val_if_fail (mdb->priv->db != NULL, NULL); diff --git a/src/cd-profile-db.c b/src/cd-profile-db.c index ae6cb0f..0b652ea 100644 --- a/src/cd-profile-db.c +++ b/src/cd-profile-db.c @@ -53,7 +53,7 @@ cd_profile_db_load (CdProfileDb *pdb, const gchar *statement; gchar *error_msg = NULL; gint rc; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *path = NULL; g_return_val_if_fail (CD_IS_PROFILE_DB (pdb), FALSE); g_return_val_if_fail (pdb->priv->db == NULL, FALSE); diff --git a/src/cd-profile.c b/src/cd-profile.c index e4d6a34..42645b0 100644 --- a/src/cd-profile.c +++ b/src/cd-profile.c @@ -203,8 +203,8 @@ cd_profile_set_object_path (CdProfile *profile) #ifdef HAVE_PWD_H struct passwd *pw; #endif - _cleanup_free_ gchar *path_tmp = NULL; - _cleanup_free_ gchar *path_owner = NULL; + g_autofree gchar *path_tmp = NULL; + g_autofree gchar *path_owner = NULL; /* append the uid to the object path */ #ifdef HAVE_PWD_H @@ -406,11 +406,11 @@ cd_profile_install_system_wide (CdProfile *profile, GError **error) { CdProfilePrivate *priv = profile->priv; gboolean ret = TRUE; - _cleanup_error_free_ GError *error_local = NULL; - _cleanup_free_ gchar *basename = NULL; - _cleanup_free_ gchar *filename = NULL; - _cleanup_object_unref_ GFile *file_dest = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GError) error_local = NULL; + g_autofree gchar *basename = NULL; + g_autofree gchar *filename = NULL; + g_autoptr(GFile) file_dest = NULL; + g_autoptr(GFile) file = NULL; /* is icc filename set? */ if (priv->filename == NULL) { @@ -495,7 +495,7 @@ cd_profile_get_metadata_as_variant (CdProfile *profile) { GList *l; GVariantBuilder builder; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GList) list = NULL; /* do not try to build an empty array */ if (g_hash_table_size (profile->priv->metadata) == 0) @@ -633,7 +633,7 @@ cd_profile_dbus_method_call (GDBusConnection *connection, const gchar *sender, guint uid; const gchar *property_name = NULL; const gchar *property_value = NULL; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* return '' */ if (g_strcmp0 (method_name, "SetProperty") == 0) { @@ -738,7 +738,7 @@ cd_profile_dbus_get_property (GDBusConnection *connection, const gchar *sender, if (g_strcmp0 (property_name, CD_PROFILE_PROPERTY_TITLE) == 0) { guint uid; - _cleanup_free_ gchar *title_db = NULL; + g_autofree gchar *title_db = NULL; uid = cd_main_get_sender_uid (connection, sender, error); if (uid == G_MAXUINT) @@ -802,7 +802,7 @@ cd_profile_register_object (CdProfile *profile, GDBusInterfaceInfo *info, GError **error) { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; static const GDBusInterfaceVTable interface_vtable = { cd_profile_dbus_method_call, @@ -884,9 +884,9 @@ cd_profile_set_from_profile (CdProfile *profile, CdIcc *icc, GError **error) gboolean ret = FALSE; guint i; struct tm created; - _cleanup_array_unref_ GArray *flags = NULL; - _cleanup_hashtable_unref_ GHashTable *metadata = NULL; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GArray) flags = NULL; + g_autoptr(GHashTable) metadata = NULL; + g_autoptr(GList) keys = NULL; /* get the description as the title */ value = cd_icc_get_description (icc, NULL, error); @@ -1034,7 +1034,7 @@ cd_profile_load_from_fd (CdProfile *profile, { CdProfilePrivate *priv = profile->priv; gboolean ret; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; _cleanup_object_unref_ CdIcc *icc = NULL; g_return_val_if_fail (CD_IS_PROFILE (profile), FALSE); @@ -1090,9 +1090,9 @@ cd_profile_load_from_filename (CdProfile *profile, const gchar *filename, GError { CdProfilePrivate *priv = profile->priv; gboolean ret = FALSE; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; _cleanup_object_unref_ CdIcc *icc = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; g_return_val_if_fail (CD_IS_PROFILE (profile), FALSE); diff --git a/src/cd-sensor.c b/src/cd-sensor.c index 42ca3e2..9667e48 100644 --- a/src/cd-sensor.c +++ b/src/cd-sensor.c @@ -172,7 +172,7 @@ cd_sensor_get_id (CdSensor *sensor) static void cd_sensor_set_id (CdSensor *sensor, const gchar *id) { - _cleanup_free_ gchar *id_tmp = NULL; + g_autofree gchar *id_tmp = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); g_free (sensor->priv->id); @@ -303,9 +303,9 @@ cd_sensor_load (CdSensor *sensor, GError **error) CdSensorIface *desc; GModule *handle; const gchar *module_name; - _cleanup_free_ gchar *backend_name = NULL; - _cleanup_free_ gchar *path_fallback = NULL; - _cleanup_free_ gchar *path = NULL; + g_autofree gchar *backend_name = NULL; + g_autofree gchar *path_fallback = NULL; + g_autofree gchar *path = NULL; /* no module */ if (sensor->priv->kind == CD_SENSOR_KIND_UNKNOWN) @@ -558,7 +558,7 @@ cd_sensor_set_options_cb (GObject *source_object, gboolean ret; CdSensor *sensor = CD_SENSOR (source_object); GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get the result */ ret = sensor->priv->desc->set_options_finish (sensor, res, &error); @@ -580,7 +580,7 @@ cd_sensor_lock_cb (GObject *source_object, CdSensor *sensor = CD_SENSOR (source_object); GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get the result */ ret = sensor->priv->desc->lock_finish (sensor, res, &error); @@ -607,7 +607,7 @@ cd_sensor_unlock_cb (GObject *source_object, CdSensor *sensor = CD_SENSOR (source_object); GDBusMethodInvocation *invocation = (GDBusMethodInvocation *) user_data; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get the result */ if (sensor->priv->desc != NULL && @@ -636,7 +636,7 @@ cd_sensor_unlock_quietly_cb (GObject *source_object, { CdSensor *sensor = CD_SENSOR (source_object); gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get the result */ if (sensor->priv->desc != NULL && @@ -695,7 +695,7 @@ cd_sensor_dbus_method_call (GDBusConnection *connection, const gchar *sender, const gchar *cap_tmp = NULL; gboolean ret; gchar *key; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* return '' */ if (g_strcmp0 (method_name, "Lock") == 0) { @@ -855,8 +855,8 @@ cd_sensor_dbus_method_call (GDBusConnection *connection, const gchar *sender, /* return '' */ if (g_strcmp0 (method_name, "SetOptions") == 0) { - _cleanup_hashtable_unref_ GHashTable *options = NULL; - _cleanup_variant_unref_ GVariant *result = NULL; + g_autoptr(GHashTable) options = NULL; + g_autoptr(GVariant) result = NULL; g_debug ("CdSensor %s:SetOptions()", sender); @@ -918,7 +918,7 @@ cd_sensor_get_options_as_variant (CdSensor *sensor) { GList *l; GVariantBuilder builder; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GList) list = NULL; /* do not try to build an empty array */ if (g_hash_table_size (sensor->priv->options) == 0) @@ -945,7 +945,7 @@ cd_sensor_get_metadata_as_variant (CdSensor *sensor) { GList *l; GVariantBuilder builder; - _cleanup_list_free_ GList *list = NULL; + g_autoptr(GList) list = NULL; /* we always must have at least one bit of metadata */ if (g_hash_table_size (sensor->priv->metadata) == 0) @@ -1051,7 +1051,7 @@ cd_sensor_register_object (CdSensor *sensor, GDBusInterfaceInfo *info, GError **error) { - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; static const GDBusInterfaceVTable interface_vtable = { cd_sensor_dbus_method_call, @@ -1109,7 +1109,7 @@ cd_sensor_open_usb_device (CdSensor *sensor, CdSensorPrivate *priv = sensor->priv; guint8 busnum; guint8 devnum; - _cleanup_object_unref_ GUsbDevice *device = NULL; + g_autoptr(GUsbDevice) device = NULL; /* convert from GUdevDevice to GUsbDevice */ busnum = g_udev_device_get_sysfs_attr_as_int (priv->device, "busnum"); @@ -1287,7 +1287,7 @@ void cd_sensor_set_index (CdSensor *sensor, guint idx) { - _cleanup_free_ gchar *id = NULL; + g_autofree gchar *id = NULL; id = g_strdup_printf ("%s-%02i", cd_sensor_kind_to_string (sensor->priv->kind), idx); diff --git a/src/plugins/cd-plugin-camera.c b/src/plugins/cd-plugin-camera.c index 1bc03ce..193daad 100644 --- a/src/plugins/cd-plugin-camera.c +++ b/src/plugins/cd-plugin-camera.c @@ -79,7 +79,7 @@ cd_plugin_is_device_embedded (GUdevDevice *device) const gchar *removable; gboolean embedded = FALSE; guint i; - _cleanup_ptrarray_unref_ GPtrArray *array = NULL; + g_autoptr(GPtrArray) array = NULL; /* get a chain of all the parent devices */ array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref); @@ -110,9 +110,9 @@ static void cd_plugin_add (CdPlugin *plugin, GUdevDevice *udev_device) { const gchar *seat; - _cleanup_free_ gchar *id = NULL; - _cleanup_free_ gchar *model = NULL; - _cleanup_free_ gchar *vendor = NULL; + g_autofree gchar *id = NULL; + g_autofree gchar *model = NULL; + g_autofree gchar *vendor = NULL; _cleanup_object_unref_ CdDevice *device = NULL; /* is a proper camera and not a webcam */ diff --git a/src/plugins/cd-plugin-sane.c b/src/plugins/cd-plugin-sane.c index 97d042a..093c531 100644 --- a/src/plugins/cd-plugin-sane.c +++ b/src/plugins/cd-plugin-sane.c @@ -75,7 +75,7 @@ cd_plugin_config_enabled_sane_devices(CdPluginPrivate *priv) { const gchar *argv[] = {COLORD_SANE_BINARY, NULL}; GPid colord_sane_pid; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; if (priv->scan_in_progress) return; diff --git a/src/plugins/cd-plugin-scanner.c b/src/plugins/cd-plugin-scanner.c index f551e98..b8c5209 100644 --- a/src/plugins/cd-plugin-scanner.c +++ b/src/plugins/cd-plugin-scanner.c @@ -89,9 +89,9 @@ cd_plugin_add (CdPlugin *plugin, GUdevDevice *udev_device) { const gchar *devclass; const gchar *seat; - _cleanup_free_ gchar *id = NULL; - _cleanup_free_ gchar *model = NULL; - _cleanup_free_ gchar *vendor = NULL; + g_autofree gchar *id = NULL; + g_autofree gchar *model = NULL; + g_autofree gchar *vendor = NULL; _cleanup_object_unref_ CdDevice *device = NULL; /* is a scanner? */ diff --git a/src/sensors/cd-sensor-argyll.c b/src/sensors/cd-sensor-argyll.c index 6e094bf..8700f3d 100644 --- a/src/sensors/cd-sensor-argyll.c +++ b/src/sensors/cd-sensor-argyll.c @@ -123,8 +123,8 @@ static void cd_sensor_get_sample_stdout_cb (CdSpawn *spawn, const gchar *line, CdSensorAsyncState *state) { CdSensorArgyllPrivate *priv = cd_sensor_argyll_get_private (state->sensor); - _cleanup_error_free_ GError *error = NULL; - _cleanup_strv_free_ gchar **parts = NULL; + g_autoptr(GError) error = NULL; + g_auto(GStrv) parts = NULL; g_debug ("line='%s'", line); @@ -238,8 +238,8 @@ cd_sensor_get_sample_async (CdSensor *sensor, CdSensorAsyncState *state; const gchar *envp[] = { "ARGYLL_NOT_INTERACTIVE=1", NULL }; gboolean ret; - _cleanup_error_free_ GError *error = NULL; - _cleanup_ptrarray_unref_ GPtrArray *argv = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GPtrArray) argv = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); @@ -384,8 +384,8 @@ cd_sensor_find_device_details (CdSensor *sensor, GError **error) gboolean ret; guint i; guint listno = 0; - _cleanup_free_ gchar *stdout = NULL; - _cleanup_strv_free_ gchar **lines = NULL; + g_autofree gchar *stdout = NULL; + g_auto(GStrv) lines = NULL; /* spawn the --help output to parse the comm-port */ ret = g_spawn_sync (NULL, @@ -478,7 +478,7 @@ cd_sensor_unlock_exit_cb (CdSpawn *spawn, state->ret = TRUE; cd_sensor_unlock_state_finish (state, NULL); } else { - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; error = g_error_new (CD_SENSOR_ERROR, CD_SENSOR_ERROR_INTERNAL, "exited without sigquit"); @@ -512,7 +512,7 @@ cd_sensor_unlock_async (CdSensor *sensor, state); /* kill spotread */ if (!cd_spawn_kill (priv->spawn)) { - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; g_set_error (&error, CD_SENSOR_ERROR, CD_SENSOR_ERROR_INTERNAL, diff --git a/src/sensors/cd-sensor-colorhug.c b/src/sensors/cd-sensor-colorhug.c index 9925afd..8085464 100644 --- a/src/sensors/cd-sensor-colorhug.c +++ b/src/sensors/cd-sensor-colorhug.c @@ -99,7 +99,7 @@ cd_sensor_colorhug_get_sample_cb (GObject *object, gboolean ret = FALSE; ChDeviceQueue *device_queue = CH_DEVICE_QUEUE (object); CdSensorAsyncState *state = (CdSensorAsyncState *) user_data; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get data */ ret = ch_device_queue_process_finish (device_queue, res, &error); @@ -127,7 +127,7 @@ cd_sensor_get_sample_async (CdSensor *sensor, guint16 calibration_index; CdSensorAsyncState *state; CdSensorColorhugPrivate *priv = cd_sensor_colorhug_get_private (sensor); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); @@ -244,7 +244,7 @@ cd_sensor_colorhug_get_remote_hash_cb (GObject *object, gboolean ret; gchar *sha1; ChDeviceQueue *device_queue = CH_DEVICE_QUEUE (object); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get data, although don't fail if it does not exist */ ret = ch_device_queue_process_finish (device_queue, res, &error); @@ -272,8 +272,8 @@ cd_sensor_colorhug_startup_cb (GObject *object, gboolean ret; ChDeviceQueue *device_queue = CH_DEVICE_QUEUE (object); CdSensorColorhugPrivate *priv = cd_sensor_colorhug_get_private (state->sensor); - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *serial_number_tmp = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *serial_number_tmp = NULL; /* get data */ ret = ch_device_queue_process_finish (device_queue, res, &error); @@ -319,7 +319,7 @@ cd_sensor_lock_async (CdSensor *sensor, { CdSensorAsyncState *state; CdSensorColorhugPrivate *priv = cd_sensor_colorhug_get_private (sensor); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); @@ -397,7 +397,7 @@ cd_sensor_unlock_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorColorhugPrivate *priv = cd_sensor_colorhug_get_private (sensor); gboolean ret = FALSE; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* close */ if (priv->device != NULL) { @@ -493,7 +493,7 @@ cd_sensor_colorhug_set_options_cb (GObject *object, gboolean ret = FALSE; ChDeviceQueue *device_queue = CH_DEVICE_QUEUE (object); CdSensorAsyncState *state = (CdSensorAsyncState *) user_data; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get data */ ret = ch_device_queue_process_finish (device_queue, res, &error); @@ -514,7 +514,7 @@ cd_sensor_colorhug_write_eeprom_cb (GObject *object, gboolean ret = FALSE; ChDeviceQueue *device_queue = CH_DEVICE_QUEUE (object); CdSensorAsyncState *state = (CdSensorAsyncState *) user_data; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* get data */ ret = ch_device_queue_process_finish (device_queue, res, &error); @@ -537,8 +537,8 @@ cd_sensor_set_next_option (CdSensorAsyncState *state) const gchar *magic = "Un1c0rn2"; gboolean ret; GVariant *value; - _cleanup_error_free_ GError *error = NULL; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GError) error = NULL; + g_autoptr(GList) keys = NULL; /* write eeprom to preserve settings */ keys = g_hash_table_get_keys (state->options); diff --git a/src/sensors/cd-sensor-dtp94.c b/src/sensors/cd-sensor-dtp94.c index cfb18bb..9102b4b 100644 --- a/src/sensors/cd-sensor-dtp94.c +++ b/src/sensors/cd-sensor-dtp94.c @@ -98,7 +98,7 @@ cd_sensor_dtp94_sample_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorAsyncState *state = (CdSensorAsyncState *) g_object_get_data (G_OBJECT (cancellable), "state"); CdSensorDtp94Private *priv = cd_sensor_dtp94_get_private (sensor); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* take a measurement from the sensor */ cd_sensor_set_state (sensor, CD_SENSOR_STATE_MEASURING); @@ -179,8 +179,8 @@ cd_sensor_dtp94_lock_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorDtp94Private *priv = cd_sensor_dtp94_get_private (sensor); gboolean ret = FALSE; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *serial = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *serial = NULL; /* try to find the USB device */ priv->device = cd_sensor_open_usb_device (sensor, @@ -264,7 +264,7 @@ cd_sensor_unlock_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorDtp94Private *priv = cd_sensor_dtp94_get_private (sensor); gboolean ret = FALSE; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* close */ if (priv->device != NULL) { diff --git a/src/sensors/cd-sensor-dummy.c b/src/sensors/cd-sensor-dummy.c index ded3bd9..957b896 100644 --- a/src/sensors/cd-sensor-dummy.c +++ b/src/sensors/cd-sensor-dummy.c @@ -93,7 +93,7 @@ static gboolean cd_sensor_get_sample_wait_cb (CdSensorAsyncState *state) { CdSensorDummyPrivate *priv = cd_sensor_dummy_get_private (state->sensor); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* never setup */ if (priv->transform_fake == NULL) { @@ -202,7 +202,7 @@ cd_sensor_set_options_async (CdSensor *sensor, gboolean ret = TRUE; const gchar *key_name; GVariant *value; - _cleanup_list_free_ GList *keys = NULL; + g_autoptr(GList) keys = NULL; g_return_if_fail (CD_IS_SENSOR (sensor)); diff --git a/src/sensors/cd-sensor-huey.c b/src/sensors/cd-sensor-huey.c index 877d9fb..41ccc9f 100644 --- a/src/sensors/cd-sensor-huey.c +++ b/src/sensors/cd-sensor-huey.c @@ -125,7 +125,7 @@ cd_sensor_huey_sample_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorAsyncState *state = (CdSensorAsyncState *) g_object_get_data (G_OBJECT (cancellable), "state"); CdSensorHueyPrivate *priv = cd_sensor_huey_get_private (sensor); - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* measure */ cd_sensor_set_state (sensor, CD_SENSOR_STATE_MEASURING); @@ -216,8 +216,8 @@ cd_sensor_huey_lock_thread_cb (GSimpleAsyncResult *res, const guint8 spin_leds[] = { 0x0, 0x1, 0x2, 0x4, 0x8, 0x4, 0x2, 0x1, 0x0, 0xff }; gboolean ret = FALSE; guint i; - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *serial_number_tmp = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *serial_number_tmp = NULL; /* try to find the USB device */ priv->device = cd_sensor_open_usb_device (sensor, @@ -318,7 +318,7 @@ cd_sensor_unlock_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorHueyPrivate *priv = cd_sensor_huey_get_private (sensor); gboolean ret = FALSE; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* close */ if (priv->device != NULL) { diff --git a/src/sensors/cd-sensor-spark.c b/src/sensors/cd-sensor-spark.c index 5a45818..96ea975 100644 --- a/src/sensors/cd-sensor-spark.c +++ b/src/sensors/cd-sensor-spark.c @@ -112,9 +112,9 @@ cd_sensor_spark_sample_thread_cb (GSimpleAsyncResult *res, CdSpectrum *sp = NULL; CdSpectrum *unity = NULL; gboolean ret; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; _cleanup_object_unref_ CdIt8 *cmf = NULL; - _cleanup_object_unref_ GFile *file = NULL; + g_autoptr(GFile) file = NULL; /* measure */ cd_sensor_set_state (sensor, CD_SENSOR_STATE_MEASURING); @@ -245,8 +245,8 @@ cd_sensor_spark_lock_thread_cb (GSimpleAsyncResult *res, { CdSensor *sensor = CD_SENSOR (object); CdSensorSparkPrivate *priv = cd_sensor_spark_get_private (sensor); - _cleanup_error_free_ GError *error = NULL; - _cleanup_free_ gchar *serial_number_tmp = NULL; + g_autoptr(GError) error = NULL; + g_autofree gchar *serial_number_tmp = NULL; /* try to find the USB device */ priv->device = cd_sensor_open_usb_device (sensor, @@ -322,7 +322,7 @@ cd_sensor_unlock_thread_cb (GSimpleAsyncResult *res, CdSensor *sensor = CD_SENSOR (object); CdSensorSparkPrivate *priv = cd_sensor_spark_get_private (sensor); gboolean ret = FALSE; - _cleanup_error_free_ GError *error = NULL; + g_autoptr(GError) error = NULL; /* close */ if (priv->device != NULL) { diff --git a/src/sensors/cd-spawn.c b/src/sensors/cd-spawn.c index 36ed0cc..5d90dcd 100644 --- a/src/sensors/cd-spawn.c +++ b/src/sensors/cd-spawn.c @@ -102,7 +102,7 @@ cd_spawn_emit_whole_lines (CdSpawn *spawn, GString *string) guint i; guint size; guint bytes_processed; - _cleanup_strv_free_ gchar **lines = NULL; + g_auto(GStrv) lines = NULL; /* if nothing then don't emit */ if (string->len == 0) @@ -366,7 +366,7 @@ cd_spawn_send_stdin (CdSpawn *spawn, const gchar *command) { gint wrote; gint length; - _cleanup_free_ gchar *buffer = NULL; + g_autofree gchar *buffer = NULL; g_return_val_if_fail (CD_IS_SPAWN (spawn), FALSE); @@ -408,7 +408,7 @@ cd_spawn_argv (CdSpawn *spawn, gchar **argv, gchar **envp, GError **error) guint i; guint len; gint rc; - _cleanup_error_free_ GError *error_local = NULL; + g_autoptr(GError) error_local = NULL; g_return_val_if_fail (CD_IS_SPAWN (spawn), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); |