summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2014-06-04 09:18:19 +0100
committerRichard Hughes <richard@hughsie.com>2014-06-04 09:43:16 +0100
commit937372355890d946d143402b870e487f0d4fedfb (patch)
tree73de3d113d3d3cda28241a8b2e2fb8c2281e101c /contrib
parentb6f7c4d117a06f059a6e852e2dce8c13a3bb1f2c (diff)
downloadcolord-937372355890d946d143402b870e487f0d4fedfb.tar.gz
trivial: Use systemd-style cleanup functions
There's no point creating yet another format...
Diffstat (limited to 'contrib')
-rw-r--r--contrib/colord-sane/Makefile.am1
-rw-r--r--contrib/colord-sane/cd-main.c20
-rw-r--r--contrib/session-helper/cd-main.c82
-rw-r--r--contrib/session-helper/cd-state.c2
4 files changed, 51 insertions, 54 deletions
diff --git a/contrib/colord-sane/Makefile.am b/contrib/colord-sane/Makefile.am
index e37abb4..4fd9465 100644
--- a/contrib/colord-sane/Makefile.am
+++ b/contrib/colord-sane/Makefile.am
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
$(DBUS_CFLAGS) \
-I$(top_srcdir) \
-I$(top_srcdir)/lib \
+ -I$(top_srcdir)/lib/colord \
-I$(top_builddir)/lib \
-DG_LOG_DOMAIN=\"CdSane\" \
-DLIBEXECDIR=\"$(libexecdir)\" \
diff --git a/contrib/colord-sane/cd-main.c b/contrib/colord-sane/cd-main.c
index 806f713..0a4d2fe 100644
--- a/contrib/colord-sane/cd-main.c
+++ b/contrib/colord-sane/cd-main.c
@@ -100,8 +100,8 @@ cd_main_colord_create_device_cb (GObject *source_object,
gpointer user_data)
{
CdClient *client = CD_CLIENT (source_object);
- _cleanup_free_error GError *error = NULL;
- _cleanup_unref_object CdDevice *device;
+ _cleanup_error_free_ GError *error = NULL;
+ _cleanup_object_unref_ CdDevice *device;
/* get result */
device = cd_client_create_device_finish (client, res, &error);
@@ -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_unref_hashtable GHashTable *properties = NULL;
+ _cleanup_free_ gchar *id = NULL;
+ _cleanup_free_ gchar *model = NULL;
+ _cleanup_free_ gchar *vendor = NULL;
+ _cleanup_hashtable_unref_ 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_free_error GError *error = NULL;
+ _cleanup_error_free_ 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_free_error GError *error = NULL;
+ _cleanup_error_free_ 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_free_error GError *error = NULL;
+ _cleanup_error_free_ 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_free_error GError *error = NULL;
+ _cleanup_error_free_ 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 7e5a77a..5cd81d9 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_unref_hashtable GHashTable *hash = NULL;
+ _cleanup_hashtable_unref_ 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_unref_ptrarray GPtrArray *old_array;
+ _cleanup_ptrarray_unref_ GPtrArray *old_array;
/* 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_free_string GString *error_str = NULL;
- _cleanup_unref_ptrarray GPtrArray *gamma_data = NULL;
- _cleanup_unref_ptrarray GPtrArray *vcgt_smoothed = NULL;
+ _cleanup_string_free_ GString *error_str = NULL;
+ _cleanup_ptrarray_unref_ GPtrArray *gamma_data = NULL;
+ _cleanup_ptrarray_unref_ 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;
- _cleanup_unref_object GFile *file;
+ _cleanup_free_ gchar *path;
+ _cleanup_object_unref_ GFile *file;
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;
+ _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;
/* build temp path */
priv->working_path = g_dir_make_tmp ("colord-session-XXXXXX", error);
@@ -939,7 +939,7 @@ cd_main_find_argyll_tool (const gchar *command,
GError **error)
{
gboolean ret;
- _cleanup_free gchar *filename;
+ _cleanup_free_ gchar *filename;
/* try the original argyllcms filename installed in /usr/local/bin */
filename = g_strdup_printf ("/usr/local/bin/%s", command);
@@ -976,9 +976,9 @@ static gboolean
cd_main_import_profile (CdMainPrivate *priv, GError **error)
{
gboolean ret = TRUE;
- _cleanup_free gchar *filename;
- _cleanup_free gchar *path;
- _cleanup_unref_object GFile *file;
+ _cleanup_free_ gchar *filename;
+ _cleanup_free_ gchar *path;
+ _cleanup_object_unref_ GFile *file;
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_free_error GError *error_local = NULL;
- _cleanup_free gchar *profile_fn = NULL;
- _cleanup_free gchar *profile_path = NULL;
- _cleanup_unref_object CdIcc *icc;
- _cleanup_unref_object GFile *file = NULL;
+ _cleanup_error_free_ GError *error_local = NULL;
+ _cleanup_free_ gchar *profile_fn = NULL;
+ _cleanup_free_ gchar *profile_path = NULL;
+ _cleanup_object_unref_ CdIcc *icc;
+ _cleanup_object_unref_ 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;
+ _cleanup_free_ 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;
- _cleanup_free gchar *stderr_data = NULL;
- _cleanup_unref_ptrarray GPtrArray *array = NULL;
+ _cleanup_free_ gchar *cmd_debug = NULL;
+ _cleanup_free_ gchar *command;
+ _cleanup_free_ gchar *stderr_data = NULL;
+ _cleanup_ptrarray_unref_ 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_unref_object GFile *file;
+ _cleanup_object_unref_ GFile *file;
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_close_dir GDir *dir;
+ _cleanup_dir_close_ GDir *dir;
/* 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_free_error GError *error_local = NULL;
+ _cleanup_error_free_ 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_free_error GError *error = NULL;
+ _cleanup_error_free_ GError *error = NULL;
/* reset the state */
cd_state_reset (priv->state);
@@ -1464,8 +1464,8 @@ cd_main_find_device (CdMainPrivate *priv,
GError **error)
{
gboolean ret;
- _cleanup_free_error GError *error_local = NULL;
- _cleanup_unref_object CdDevice *device_tmp;
+ _cleanup_error_free_ GError *error_local = NULL;
+ _cleanup_object_unref_ CdDevice *device_tmp;
device_tmp = cd_client_find_device_sync (priv->client,
device_id,
@@ -1514,8 +1514,8 @@ cd_main_find_sensor (CdMainPrivate *priv,
GError **error)
{
gboolean ret;
- _cleanup_free_error GError *error_local = NULL;
- _cleanup_unref_object CdSensor *sensor_tmp;
+ _cleanup_error_free_ GError *error_local = NULL;
+ _cleanup_object_unref_ CdSensor *sensor_tmp;
sensor_tmp = cd_client_find_sensor_sync (priv->client,
sensor_id,
@@ -1562,9 +1562,9 @@ static void
cd_main_set_basename (CdMainPrivate *priv)
{
const gchar *tmp;
- _cleanup_free gchar *date_str = NULL;
GDateTime *datetime;
GString *str;
+ _cleanup_free_ gchar *date_str = NULL;
str = g_string_new ("");
@@ -1633,9 +1633,9 @@ cd_main_daemon_method_call (GDBusConnection *connection,
const gchar *device_id;
const gchar *prop_key;
const gchar *sensor_id;
- GError *error = NULL;
GVariantIter *iter = NULL;
GVariant *prop_value;
+ _cleanup_error_free_ GError *error = NULL;
/* should be impossible */
if (g_strcmp0 (interface_name, "org.freedesktop.ColorHelper.Display") != 0) {
@@ -1751,7 +1751,6 @@ cd_main_daemon_method_call (GDBusConnection *connection,
if (priv->device == NULL) {
g_dbus_method_invocation_return_gerror (invocation,
error);
- g_error_free (error);
g_timeout_add (200, cd_main_finished_quit_cb, priv);
return;
}
@@ -1761,7 +1760,6 @@ cd_main_daemon_method_call (GDBusConnection *connection,
if (priv->sensor == NULL) {
g_dbus_method_invocation_return_gerror (invocation,
error);
- g_error_free (error);
g_timeout_add (200, cd_main_finished_quit_cb, priv);
return;
}
@@ -1924,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_unref_object GFile *file;
+ _cleanup_free_ gchar *data = NULL;
+ _cleanup_object_unref_ GFile *file;
/* load file */
file = g_file_new_for_path (filename);
@@ -1989,7 +1987,6 @@ main (int argc, char *argv[])
CdMainPrivate *priv;
gboolean ret;
gboolean timed_exit = FALSE;
- GError *error = NULL;
GOptionContext *context;
guint owner_id = 0;
guint retval = 1;
@@ -1998,6 +1995,7 @@ main (int argc, char *argv[])
"Exit after a small delay", NULL },
{ NULL}
};
+ _cleanup_error_free_ GError *error = NULL;
setlocale (LC_ALL, "");
@@ -2034,7 +2032,6 @@ main (int argc, char *argv[])
if (priv->introspection == NULL) {
g_warning ("CdMain: failed to load introspection: %s",
error->message);
- g_error_free (error);
goto out;
}
@@ -2043,7 +2040,6 @@ main (int argc, char *argv[])
ret = cd_client_connect_sync (priv->client, NULL, &error);
if (!ret) {
g_warning ("failed to contact colord: %s", error->message);
- g_error_free (error);
goto out;
}
diff --git a/contrib/session-helper/cd-state.c b/contrib/session-helper/cd-state.c
index 16dc351..0ff68e6 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_free_string GString *result;
+ _cleanup_string_free_ GString *result;
/* get the total time so we can work out the divisor */
for (i = 0; i < state->priv->steps; i++)