[Utopia] g-v-m: Fix hal_device_added() to work for all capabilities



Hi Jeffrey!

The CVS head/1.5.3 distribution loop in hal_device_added() is flawed
since "j" is only initialized to 0 in the outer loop (over i) and
never set back to 0. This means that only the first item in devices[]
(which happens to be the most popular "block" capability) is executed,
it does not work for all subsequent loops. 

Doing 1.5 loops in one for() construct is also a bit confusing, so I cleaned
this up a little and made it work for all devices[] entries. (Patch attached)

Thanks for considering,

Martin
-- 
Martin Pitt        http://www.piware.de
Ubuntu Developer   http://www.ubuntu.com
Debian Developer   http://www.debian.org

In a world without walls and fences, who needs Windows and Gates?
diff -ruN gnome-volume-manager-1.5.3-old/src/manager.c gnome-volume-manager-1.5.3/src/manager.c
--- gnome-volume-manager-1.5.3-old/src/manager.c	2005-10-19 12:01:11.000000000 +0200
+++ gnome-volume-manager-1.5.3/src/manager.c	2005-10-19 12:02:14.000000000 +0200
@@ -1890,8 +1890,9 @@
 	
 	qsort (capabilities, n, sizeof (char *), strptrcmp);
 	
-	for (i = 0, j = 0; i < G_N_ELEMENTS (devices) && j < n; i++) {
+	for (i = 0; i < G_N_ELEMENTS (devices); i++) {
 		int cmp = -1;
+                j = 0;
 
 		while (j < n && (cmp = strcmp (capabilities[j], devices[i].capability)) < 0)
 			j++;
@@ -1899,7 +1900,6 @@
 		if (cmp == 0) {
 			if (devices[i].handler (udi, capabilities[j]))
 				break;
-			j++;
 		}
 	}
 	

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]