[Fingerforce-commits] [fprintd] 09/12: manager: Fix sorting in GetDevices() output

Didier Raboud odyx at moszumanska.debian.org
Sun Apr 12 13:12:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch master
in repository fprintd.

commit 4edc17ac997e696cbc0391b49647bfbbd8da3ca0
Author: Bastien Nocera <hadess at hadess.net>
Date:   Tue Feb 3 16:55:48 2015 +0100

    manager: Fix sorting in GetDevices() output
    
    Sort the devices by ID for the GetDevices() output.
---
 src/manager.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/manager.c b/src/manager.c
index f326ec6..0755160 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -159,15 +159,19 @@ static gboolean fprint_manager_get_devices(FprintManager *manager,
 	GPtrArray **devices, GError **error)
 {
 	FprintManagerPrivate *priv = FPRINT_MANAGER_GET_PRIVATE (manager);
-	GSList *elem = priv->dev_registry;
+	GSList *elem = g_slist_reverse(g_slist_copy(priv->dev_registry));
+	GSList *l;
 	int num_open = g_slist_length(elem);
 	GPtrArray *devs = g_ptr_array_sized_new(num_open);
 
-	if (num_open > 0)
-		do {
-			FprintDevice *rdev = elem->data;
+	if (num_open > 0) {
+		for (l = elem; l != NULL; l = l->next) {
+			FprintDevice *rdev = l->data;
 			g_ptr_array_add(devs, get_device_path(rdev));
-		} while ((elem = g_slist_next(elem)) != NULL);
+		}
+	}
+
+	g_slist_free(elem);
 
 	*devices = devs;
 	return TRUE;
@@ -181,7 +185,7 @@ static gboolean fprint_manager_get_default_device(FprintManager *manager,
 	int num_open = g_slist_length(elem);
 
 	if (num_open > 0) {
-		*device = get_device_path (elem->data);
+		*device = get_device_path (g_slist_last (elem)->data);
 		return TRUE;
 	} else {
 		g_set_error (error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_DEVICE,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/fingerforce/fprintd.git



More information about the Fingerforce-commits mailing list