diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c index 0e7c17f..ffd38a4 100644 --- a/libfprint/fp-context.c +++ b/libfprint/fp-context.c @@ -131,8 +131,7 @@ 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); - g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); - FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); + g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); const FpIdEntry *entry; if (cls->type != FP_DEVICE_TYPE_USB) @@ -276,8 +275,7 @@ fp_context_init (FpContext *self) for (i = 0; i < priv->drivers->len;) { GType driver = g_array_index (priv->drivers, GType, i); - g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); - FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); + g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); if (!is_driver_allowed (cls->id)) g_array_remove_index (priv->drivers, i); @@ -351,8 +349,7 @@ fp_context_enumerate (FpContext *context) for (i = 0; i < priv->drivers->len; i++) { GType driver = g_array_index (priv->drivers, GType, i); - g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); - FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); + g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); const FpIdEntry *entry; if (cls->type != FP_DEVICE_TYPE_VIRTUAL) diff --git a/libfprint/fpi-compat.h b/libfprint/fpi-compat.h index fcf1600..0904ab2 100644 --- a/libfprint/fpi-compat.h +++ b/libfprint/fpi-compat.h @@ -31,3 +31,8 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref); #endif #define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void))(f)) + +#if !GLIB_CHECK_VERSION (2, 63, 3) +typedef struct _FpDeviceClass FpDeviceClass; +G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpDeviceClass, g_type_class_unref); +#endif diff --git a/libfprint/fprint-list-supported-devices.c b/libfprint/fprint-list-supported-devices.c index cb2803f..ae8cc11 100644 --- a/libfprint/fprint-list-supported-devices.c +++ b/libfprint/fprint-list-supported-devices.c @@ -38,8 +38,7 @@ insert_drivers (GList *list) for (i = 0; i < drivers->len; i++) { GType driver = g_array_index (drivers, GType, i); - g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); - FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); + g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); const FpIdEntry *entry; if (cls->type != FP_DEVICE_TYPE_USB) diff --git a/libfprint/fprint-list-udev-rules.c b/libfprint/fprint-list-udev-rules.c index ac50797..bd7c8a8 100644 --- a/libfprint/fprint-list-udev-rules.c +++ b/libfprint/fprint-list-udev-rules.c @@ -104,8 +104,7 @@ main (int argc, char **argv) for (i = 0; i < drivers->len; i++) { GType driver = g_array_index (drivers, GType, i); - g_autoptr(GTypeClass) type_class = g_type_class_ref (driver); - FpDeviceClass *cls = FP_DEVICE_CLASS (type_class); + g_autoptr(FpDeviceClass) cls = g_type_class_ref (driver); if (cls->type != FP_DEVICE_TYPE_USB) continue; diff --git a/tests/test-fpi-device.c b/tests/test-fpi-device.c index 9f1da2e..bfe383b 100644 --- a/tests/test-fpi-device.c +++ b/tests/test-fpi-device.c @@ -64,13 +64,13 @@ static FpAutoResetClass default_fake_dev_class = {0}; static FpAutoResetClass * auto_reset_device_class (void) { - g_autoptr(GTypeClass) type_class = NULL; + g_autoptr(FpDeviceClass) type_class = NULL; FpDeviceClass *dev_class = g_type_class_peek_static (FPI_TYPE_DEVICE_FAKE); if (!dev_class) { type_class = g_type_class_ref (FPI_TYPE_DEVICE_FAKE); - dev_class = (FpDeviceClass *) type_class; + dev_class = type_class; g_assert_nonnull (dev_class); }