Blame SOURCES/0112-fpi-context-Make-fpi_get_driver_types-to-return-an-a.patch

73b847
From 9fb75e8f9fa024bfc389bd7b76d7e217e607328f Mon Sep 17 00:00:00 2001
73b847
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
73b847
Date: Sat, 14 Dec 2019 16:56:15 +0100
73b847
Subject: [PATCH 112/181] fpi-context: Make fpi_get_driver_types to return an
73b847
 array
73b847
73b847
No need to create one all the times and the fill it with what we need.
73b847
---
73b847
 libfprint/fp-context.c                    |  3 +--
73b847
 libfprint/fpi-context.h                   |  5 +++--
73b847
 libfprint/fprint-list-supported-devices.c |  4 +---
73b847
 libfprint/fprint-list-udev-rules.c        |  4 +---
73b847
 meson.build                               | 11 +++++------
73b847
 5 files changed, 11 insertions(+), 16 deletions(-)
73b847
73b847
diff --git a/libfprint/fp-context.c b/libfprint/fp-context.c
73b847
index eed7847..3e47f03 100644
73b847
--- a/libfprint/fp-context.c
73b847
+++ b/libfprint/fp-context.c
73b847
@@ -243,8 +243,7 @@ fp_context_init (FpContext *self)
73b847
   g_autoptr(GError) error = NULL;
73b847
   FpContextPrivate *priv = fp_context_get_instance_private (self);
73b847
 
73b847
-  priv->drivers = g_array_new (TRUE, FALSE, sizeof (GType));
73b847
-  fpi_get_driver_types (priv->drivers);
73b847
+  priv->drivers = fpi_get_driver_types ();
73b847
 
73b847
   priv->devices = g_ptr_array_new_with_free_func (g_object_unref);
73b847
 
73b847
diff --git a/libfprint/fpi-context.h b/libfprint/fpi-context.h
73b847
index c5a1075..48fecb4 100644
73b847
--- a/libfprint/fpi-context.h
73b847
+++ b/libfprint/fpi-context.h
73b847
@@ -23,11 +23,12 @@
73b847
 
73b847
 /**
73b847
  * fpi_get_driver_types:
73b847
- * @drivers: #GArray to be filled with all driver types
73b847
  *
73b847
  * This function is purely for private used. It is solely part of the public
73b847
  * API as it is useful during build time.
73b847
  *
73b847
  * Stability: private
73b847
+ * Returns: (element-type GType) (transfer container): a #GArray filled with
73b847
+ *   all driver types
73b847
  */
73b847
-void fpi_get_driver_types (GArray *drivers);
73b847
+GArray *fpi_get_driver_types (void);
73b847
diff --git a/libfprint/fprint-list-supported-devices.c b/libfprint/fprint-list-supported-devices.c
73b847
index 124e9d9..55da252 100644
73b847
--- a/libfprint/fprint-list-supported-devices.c
73b847
+++ b/libfprint/fprint-list-supported-devices.c
73b847
@@ -31,11 +31,9 @@ GHashTable *printed = NULL;
73b847
 static GList *
73b847
 insert_drivers (GList *list)
73b847
 {
73b847
-  g_autoptr(GArray) drivers = g_array_new (FALSE, FALSE, sizeof (GType));
73b847
+  g_autoptr(GArray) drivers = fpi_get_driver_types ();
73b847
   gint i;
73b847
 
73b847
-  fpi_get_driver_types (drivers);
73b847
-
73b847
   /* Find the best driver to handle this USB device. */
73b847
   for (i = 0; i < drivers->len; i++)
73b847
     {
73b847
diff --git a/libfprint/fprint-list-udev-rules.c b/libfprint/fprint-list-udev-rules.c
73b847
index c0a3337..335c37b 100644
73b847
--- a/libfprint/fprint-list-udev-rules.c
73b847
+++ b/libfprint/fprint-list-udev-rules.c
73b847
@@ -96,11 +96,9 @@ print_driver (const FpDeviceClass *cls)
73b847
 int
73b847
 main (int argc, char **argv)
73b847
 {
73b847
-  g_autoptr(GArray) drivers = g_array_new (FALSE, FALSE, sizeof (GType));
73b847
+  g_autoptr(GArray) drivers = fpi_get_driver_types ();
73b847
   guint i;
73b847
 
73b847
-  fpi_get_driver_types (drivers);
73b847
-
73b847
   printed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
73b847
 
73b847
   for (i = 0; i < drivers->len; i++)
73b847
diff --git a/meson.build b/meson.build
73b847
index b7ba901..3f72118 100644
73b847
--- a/meson.build
73b847
+++ b/meson.build
73b847
@@ -151,21 +151,20 @@ drivers_type_func = []
73b847
 drivers_type_list += '#include <glib-object.h>'
73b847
 drivers_type_list += '#include "fpi-context.h"'
73b847
 drivers_type_list += ''
73b847
-drivers_type_func += 'void fpi_get_driver_types (GArray *drivers)'
73b847
+drivers_type_func += 'GArray *'
73b847
+drivers_type_func += 'fpi_get_driver_types (void)'
73b847
 drivers_type_func += '{'
73b847
+drivers_type_func += '  GArray *drivers = g_array_new (TRUE, FALSE, sizeof (GType));'
73b847
 drivers_type_func += '  GType t;'
73b847
 drivers_type_func += ''
73b847
-idx = 0
73b847
 foreach driver: drivers
73b847
     drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);'
73b847
     drivers_type_func += '  t = fpi_device_' + driver + '_get_type ();'
73b847
     drivers_type_func += '  g_array_append_val (drivers, t);'
73b847
-    if idx != drivers.length() - 1
73b847
-        drivers_type_func += ''
73b847
-        idx += 1
73b847
-    endif
73b847
+    drivers_type_func += ''
73b847
 endforeach
73b847
 drivers_type_list += ''
73b847
+drivers_type_func += '  return drivers;'
73b847
 drivers_type_func += '}'
73b847
 
73b847
 root_inc = include_directories('.')
73b847
-- 
73b847
2.24.1
73b847