hal: Branch 'master' - 2 commits

David Zeuthen david at kemper.freedesktop.org
Mon Jan 8 10:15:29 PST 2007


 hald/linux/blockdev.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

New commits:
diff-tree ab61f8f2208163ccadc7e2d86cf7c561f77f874f (from 310e371ce3b2b5f01237b9f484ba50e8519c222d)
Author: David Zeuthen <davidz at redhat.com>
Date:   Mon Jan 8 13:15:25 2007 -0500

    fix up compile warnings after last patch

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 717b21d..0925698 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -638,7 +638,6 @@ hotplug_event_begin_add_blockdev (const 
 
 	/* OK, no parent... it might a device-mapper device => check slaves/ subdir in sysfs */
 	if (parent == NULL && !is_partition && !is_fakevolume) {
-		GError *err = NULL;
 		DIR * dir;
 		struct dirent *dp;
 		
@@ -664,7 +663,6 @@ hotplug_event_begin_add_blockdev (const 
 		if ((dir = opendir (path)) == NULL) {
 			HAL_WARNING (("Unable to open %s: %s", path, strerror(errno)));
 		} else {
-			const char *f;
 			while (((dp = readdir (dir)) != NULL) && (parent == NULL)) {
 				char *link;
 				char *target;
diff-tree 310e371ce3b2b5f01237b9f484ba50e8519c222d (from 158636d2efebe95d9129a5e2fcb7cc09899badc9)
Author: Sergey Lapin <slapinid at gmail.com>
Date:   Mon Jan 8 13:14:28 2007 -0500

    use POSIX readdir instead of g_dir_open
    
    As I see through the code, near line 660 of hald/linux/blockdev.c, if I
    set break point on a line with g_dir_open, on n770 device and probably
    others, you'll se memory consumption increase by 100K. So I think
    replacing this call with POSIX readdir would be useful.
    
    Please see attached patch. It will benefit at least when you use kernel
    2.6.16 on arm (nokia 770 is an example; you don't have loopX/slaves in
    sysfs).

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 7d11ad2..717b21d 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -32,6 +32,7 @@
 #include <mntent.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <dirent.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <syslog.h>
@@ -637,8 +638,10 @@ hotplug_event_begin_add_blockdev (const 
 
 	/* OK, no parent... it might a device-mapper device => check slaves/ subdir in sysfs */
 	if (parent == NULL && !is_partition && !is_fakevolume) {
-		GDir *dir;
 		GError *err = NULL;
+		DIR * dir;
+		struct dirent *dp;
+		
 		char path[HAL_PATH_MAX];
 
 
@@ -657,16 +660,16 @@ hotplug_event_begin_add_blockdev (const 
 
 		g_snprintf (path, HAL_PATH_MAX, "%s/slaves", sysfs_path);
 		HAL_INFO (("Looking in %s", path));
-		if ((dir = g_dir_open (path, 0, &err)) == NULL) {
-			HAL_WARNING (("Unable to open %s: %s", path, err->message));
-			g_error_free (err);
+
+		if ((dir = opendir (path)) == NULL) {
+			HAL_WARNING (("Unable to open %s: %s", path, strerror(errno)));
 		} else {
 			const char *f;
-			while (((f = g_dir_read_name (dir)) != NULL) && (parent == NULL)) {
+			while (((dp = readdir (dir)) != NULL) && (parent == NULL)) {
 				char *link;
 				char *target;
 
-				link = g_strdup_printf ("%s/%s", path, f);
+				link = g_strdup_printf ("%s/%s", path, dp->d_name);
 				target = resolve_symlink (link);
 				HAL_INFO ((" %s -> %s", link, target));
 
@@ -703,7 +706,7 @@ hotplug_event_begin_add_blockdev (const 
 				}
 				g_free (target);
 			}
-			g_dir_close (dir);
+			closedir(dir);
 			HAL_INFO (("Done looking in %s", path));
 		}
 		


More information about the hal-commit mailing list