diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c index 6764241..f64968d 100644 --- a/libfprint/fp-context.c +++ b/libfprint/fp-context.c @@ -131,14 +131,12 @@ usb_device_added_cb (FpContext *self, GUsbDevice *device, GUsbContext *usb_ctx) for (i = 0; i < priv->drivers->len; i++) { GType driver = g_array_index (priv->drivers, GType, i); - FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver)); + g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); + FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); const FpIdEntry *entry; if (cls->type != FP_DEVICE_TYPE_USB) - { - g_type_class_unref (cls); - continue; - } + continue; for (entry = cls->id_table; entry->pid; entry++) { @@ -158,8 +156,6 @@ usb_device_added_cb (FpContext *self, GUsbDevice *device, GUsbContext *usb_ctx) found_driver = driver; found_entry = entry; } - - g_type_class_unref (cls); } if (found_driver == G_TYPE_NONE) @@ -355,7 +351,8 @@ fp_context_enumerate (FpContext *context) for (i = 0; i < priv->drivers->len; i++) { GType driver = g_array_index (priv->drivers, GType, i); - FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver)); + g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); + FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); const FpIdEntry *entry; if (cls->type != FP_DEVICE_TYPE_VIRTUAL) @@ -381,8 +378,6 @@ fp_context_enumerate (FpContext *context) NULL); g_debug ("created"); } - - g_type_class_unref (cls); } while (priv->pending_devices) diff --git a/libfprint/fprint-list-supported-devices.c b/libfprint/fprint-list-supported-devices.c index 55da252..cb2803f 100644 --- a/libfprint/fprint-list-supported-devices.c +++ b/libfprint/fprint-list-supported-devices.c @@ -38,14 +38,12 @@ insert_drivers (GList *list) for (i = 0; i < drivers->len; i++) { GType driver = g_array_index (drivers, GType, i); - FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver)); + g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); + FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); const FpIdEntry *entry; if (cls->type != FP_DEVICE_TYPE_USB) - { - g_type_class_unref (cls); - continue; - } + continue; for (entry = cls->id_table; entry->vid; entry++) { @@ -63,8 +61,6 @@ insert_drivers (GList *list) list = g_list_prepend (list, g_strdup_printf ("%s | %s\n", key, cls->full_name)); } - - g_type_class_unref (cls); } return list; diff --git a/libfprint/fprint-list-udev-rules.c b/libfprint/fprint-list-udev-rules.c index 335c37b..ac50797 100644 --- a/libfprint/fprint-list-udev-rules.c +++ b/libfprint/fprint-list-udev-rules.c @@ -104,17 +104,13 @@ main (int argc, char **argv) for (i = 0; i < drivers->len; i++) { GType driver = g_array_index (drivers, GType, i); - FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver)); + g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); + FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); if (cls->type != FP_DEVICE_TYPE_USB) - { - g_type_class_unref (cls); - continue; - } + continue; print_driver (cls); - - g_type_class_unref (cls); } print_driver (&whitelist);