main: Use g_autoptr(GError)
This does away with some cleanups.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user