hal/hald/linux2 coldplug.c,1.10,1.11 osspec.c,1.20,1.21

David Zeuthen david at freedesktop.org
Sun Feb 27 17:16:49 PST 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv8815/hald/linux2

Modified Files:
	coldplug.c osspec.c 
Log Message:
2005-02-27  David Zeuthen  <davidz at redhat.com>

	Played around with Valgrind on this slow Sunday :-). Before this
	patch options 'valgrind --show-reachable=yes --leak-check=yes
	--tool=memcheck ./hald --daemon=no --retain-privileges' - remember
	to set up environment variables as in run-hald.sh. Some of the
	output:

	497664 bytes in 486 blocks are still reachable in loss record 33 of 35
	     at 0x1B908984: malloc (vg_replace_malloc.c:131)
             by 0x4DE983: (within /usr/lib/libexpat.so.0.5.0)
             by 0x4E1729: XML_ParserCreate_MM (in /usr/lib/libexpat.so.0.5.0)
             by 0x4E17C1: XML_ParserCreate (in /usr/lib/libexpat.so.0.5.0)

	1003104 bytes in 972 blocks are still reachable in loss record 34 of 35
             at 0x1B908984: malloc (vg_replace_malloc.c:131)
             by 0x4DD4A2: (within /usr/lib/libexpat.so.0.5.0)
             by 0x4DD5F1: (within /usr/lib/libexpat.so.0.5.0)
             by 0x4E0596: (within /usr/lib/libexpat.so.0.5.0)

	2115584 bytes in 486 blocks are still reachable in loss record 35 of 35
             at 0x1B908984: malloc (vg_replace_malloc.c:131)
             by 0x4DC64E: XML_GetBuffer (in /usr/lib/libexpat.so.0.5.0)
             by 0x4DC91E: XML_Parse (in /usr/lib/libexpat.so.0.5.0)
             by 0x805093E: scan_fdi_files (device_info.c:1282)

	LEAK SUMMARY:
	   definitely lost: 20034 bytes in 769 blocks.
	   possibly lost:   1057 bytes in 21 blocks.
	   still reachable: 5289701 bytes in 19813 blocks.
	   suppressed: 0 bytes in 0 blocks.

	plus some illegal memory access errors. After this patch

	130613 bytes in 1 blocks are still reachable in loss record 23 of 24
	   at 0x1B908984: malloc (vg_replace_malloc.c:131)
	   by 0x80610E2: ids_init (ids.c:514)
	   by 0x8056A15: osspec_init (osspec.c:337)
	   by 0x8051DF8: main (hald.c:591)

	322003 bytes in 1 blocks are still reachable in loss record 24 of 24
	   at 0x1B908984: malloc (vg_replace_malloc.c:131)
	   by 0x806101D: ids_init (ids.c:292)
	   by 0x8056A15: osspec_init (osspec.c:337)
	   by 0x8051DF8: main (hald.c:591)

	LEAK SUMMARY:
	   definitely lost: 20884 bytes in 774 blocks.
	   possibly lost:   800 bytes in 20 blocks.
	   still reachable: 643659 bytes in 4499 blocks.

	which gives us a net saving of approx 4.5MB. Sweet. (yes, this
	ChangeLog is somewhat a weblog for me these days)

	* hald/device_info.c (process_fdi_file): Fix up error handling;
	remember to free the XML_Parser context which fixes a 4.5MB memory
	leak on my system.

	* hald/linux2/coldplug.c (coldplug_synthesize_events): Free strings
	to seal a leak

	* hald/util.h: Export hal_util_hexdump prototype

	* hald/util.c (hal_util_grep_string_elem_from_file): Yikes, make
	this a static buffer since we're returning a pointer to this
	variable.
	(hal_util_hexdump): New convenience function

	* hald/hald_dbus.c (device_add_capability): Fixup this function to
	actually work now that info.capabilities is a strlist

	* hald/hald.c (parent_wait_for_child): Fix unneeded char buf[1].



Index: coldplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/coldplug.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- coldplug.c	24 Feb 2005 17:33:03 -0000	1.10
+++ coldplug.c	28 Feb 2005 01:16:47 -0000	1.11
@@ -280,6 +280,9 @@
 		hotplug_event->sysfs.net_ifindex = -1;
 		
 		hotplug_event_enqueue (hotplug_event);
+
+		g_free (li->data);
+		g_free (li->next->data);
 	}
 	g_slist_free (sysfs_other_class_dev);
 
@@ -352,7 +355,7 @@
 		g_dir_close (dir1);		
 	}
 	g_dir_close (dir);
-
+       
 	return TRUE;
 error:
 	HAL_ERROR (("Error building the orderered list of sysfs paths"));
@@ -393,7 +396,6 @@
 		g_free (parent_sysfs_path);
 
 		hotplug_event->sysfs.device_file[0] = '\0';
-
 		hotplug_event_enqueue (hotplug_event);
 	}
 
@@ -421,7 +423,6 @@
 		else
 			hotplug_event->sysfs.wait_for_sysfs_path[0] = '\0';
 		hotplug_event->sysfs.net_ifindex = -1;
-		
 		hotplug_event_enqueue (hotplug_event);
 	}
 

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- osspec.c	25 Feb 2005 03:32:48 -0000	1.20
+++ osspec.c	28 Feb 2005 01:16:47 -0000	1.21
@@ -394,8 +394,6 @@
 	di_search_and_merge (root, DEVICE_INFO_TYPE_POLICY);
 
 	hal_util_callout_device_add (root, computer_callouts_add_done, NULL, NULL);
-
-	/*osspec_probe_done ();*/
 }
 
 DBusHandlerResult




More information about the hal-commit mailing list