main: Use g_autoptr(GError)

This does away with some cleanups.
This commit is contained in:
Guido Günther
2020-02-27 18:42:02 +01:00
parent cec37ef8f4
commit ba7a80dc93
4 changed files with 5 additions and 9 deletions

View File

@@ -43,7 +43,7 @@ light_changed (gpointer user_data)
LightReadings readings;
gdouble level;
char *contents;
GError *error = NULL;
g_autoptr(GError) error = NULL;
if (g_file_get_contents (drv_data->light_path, &contents, NULL, &error)) {
int light1, light2;
@@ -57,7 +57,6 @@ light_changed (gpointer user_data)
} else {
g_warning ("Failed to read input level at %s: %s",
drv_data->light_path, error->message);
g_error_free (error);
return G_SOURCE_CONTINUE;
}

View File

@@ -46,7 +46,7 @@ light_changed (gpointer user_data)
LightReadings readings;
gdouble level;
char *contents;
GError *error = NULL;
g_autoptr(GError) error = NULL;
if (g_file_get_contents (drv_data->input_path, &contents, NULL, &error)) {
level = g_ascii_strtod (contents, NULL);
@@ -54,7 +54,6 @@ light_changed (gpointer user_data)
} else {
g_warning ("Failed to read input level at %s: %s",
drv_data->input_path, error->message);
g_error_free (error);
return G_SOURCE_CONTINUE;
}
readings.level = level * drv_data->scale;

View File

@@ -586,14 +586,13 @@ iio_fixup_sampling_frequency (GUdevDevice *dev)
GDir *dir;
const char *device_dir;
const char *name;
GError *error = NULL;
g_autoptr(GError) error = NULL;
double sample_freq;
device_dir = g_udev_device_get_sysfs_path (dev);
dir = g_dir_open (g_udev_device_get_sysfs_path (dev), 0, &error);
if (!dir) {
g_warning ("Failed to open directory '%s': %s", device_dir, error->message);
g_error_free (error);
return FALSE;
}
@@ -626,14 +625,13 @@ enable_sensors (GUdevDevice *dev,
char *device_dir;
const char *name;
gboolean ret = FALSE;
GError *error = NULL;
g_autoptr(GError) error = NULL;
device_dir = g_build_filename (g_udev_device_get_sysfs_path (dev), "scan_elements", NULL);
dir = g_dir_open (device_dir, 0, &error);
if (!dir) {
g_warning ("Failed to open directory '%s': %s", device_dir, error->message);
g_free (device_dir);
g_error_free (error);
return FALSE;
}

View File

@@ -129,7 +129,7 @@ appeared_cb (GDBusConnection *connection,
const gchar *name_owner,
gpointer user_data)
{
g_autoptr(GError) error = NULL;
GError *error = NULL;
GVariant *ret = NULL;
g_print ("+++ iio-sensor-proxy appeared\n");