hal: Branch 'master' - 8 commits

Danny Kukawka dkukawka at kemper.freedesktop.org
Sat Feb 21 03:00:10 PST 2009


 hald/create_cache.c                |    2 ++
 hald/device_info.c                 |    1 +
 hald/hald_dbus.c                   |    6 +++++-
 hald/linux/addons/addon-cpufreq.c  |   10 ++++++----
 hald/linux/addons/addon-hid-ups.c  |    3 ++-
 hald/linux/addons/addon-input.c    |    2 ++
 hald/linux/addons/addon-storage.c  |    3 +--
 hald/linux/blockdev.c              |    4 ++--
 hald/linux/device.c                |    3 ---
 hald/linux/osspec.c                |    6 +++---
 hald/linux/probing/probe-storage.c |    3 +--
 hald/linux/probing/probe-volume.c  |    2 ++
 libhal-storage/libhal-storage.c    |    2 ++
 libhal/libhal.c                    |    6 ++++--
 partutil/partutil.c                |    4 +++-
 15 files changed, 36 insertions(+), 21 deletions(-)

New commits:
commit 1d1abc2d4116071c579de502aa2ee8254e222cfe
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:56:24 2009 +0100

    make Magneto-Optical devices visible
    
    Made Magneto-Optical devices visible. Add missing breaks when
    probing MO volume types, so that the volume.disc.type do not
    get shadowed by the CD-ROM case.
    
    And when computing the volume display name, do not overwrite it just
    after having handled the MO cases. This also fixes a memory leak.

diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index d298db2..8ce557e 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -476,8 +476,10 @@ main (int argc, char *argv[])
 			case 0x05: /* Advance Storage – Magneto-Optical */
 				libhal_changeset_set_property_string (cs, "volume.disc.type", "mo");
 				libhal_changeset_set_property_bool (cs, "volume.disc.is_rewritable", TRUE);
+				break;
 			case 0x04: /* Magneto Optical write once */
 				libhal_changeset_set_property_string (cs, "volume.disc.type", "mo");
+				break;
 			case 0x08: /* CD-ROM */
 				libhal_changeset_set_property_string (cs, "volume.disc.type", "cd_rom");
 				break;
diff --git a/libhal-storage/libhal-storage.c b/libhal-storage/libhal-storage.c
index 8b9e1b8..f3fe989 100644
--- a/libhal-storage/libhal-storage.c
+++ b/libhal-storage/libhal-storage.c
@@ -500,6 +500,8 @@ libhal_volume_policy_compute_display_name (LibHalDrive *drive, LibHalVolume *vol
 			else
 				name = strdup (_("Magneto Optical"));
 		}
+		
+		goto out;
 	}
 
 	/* Fallback: size of media */
commit a61f1e9756dd4f0d069ebce1654fd31d897745b0
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:50:36 2009 +0100

    remove unused call to hal_util_get_last_element
    
    Remoced unused call to hal_util_get_last_element in memstick_add().

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 21b9176..e3108e9 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1346,7 +1346,6 @@ static HalDevice *
 memstick_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
-	const gchar *bus_id;
 
 	if (parent_dev == NULL) {
 		d = NULL;
@@ -1359,8 +1358,6 @@ memstick_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
-	bus_id = hal_util_get_last_element (sysfs_path);
-	
 	hal_util_set_string_from_file (d, "info.product", sysfs_path, "attr_modelname");
 	
 out:
commit 246f467e1ed21b6f4f882c6d93415222c821fe1e
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:49:04 2009 +0100

    do not call property_set_lookup before checking param validity
    
    Fixed libhal: do not call property_set_lookup before checking
    param validity.

diff --git a/libhal/libhal.c b/libhal/libhal.c
index 855b9dc..9e4b99f 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -657,7 +657,7 @@ property_set_lookup (const LibHalPropertySet *set, const char *key)
 LibHalPropertyType
 libhal_ps_get_type (const LibHalPropertySet *set, const char *key)
 {
-	LibHalProperty *p = property_set_lookup (set, key);
+	LibHalProperty *p;
 
 	LIBHAL_CHECK_PARAM_VALID(set, "*set", LIBHAL_PROPERTY_TYPE_INVALID);
 	LIBHAL_CHECK_PARAM_VALID(key, "*key", LIBHAL_PROPERTY_TYPE_INVALID);
commit 297024565738204bc5988e61b833b0763906814c
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:47:53 2009 +0100

    remove unused pointer to struct mntent returned from getmntent_r
    
    Removed remove unused pointer to struct mntent returned from
    getmntent_r() .

diff --git a/hald/linux/addons/addon-storage.c b/hald/linux/addons/addon-storage.c
index fff22d6..383b9b8 100644
--- a/hald/linux/addons/addon-storage.c
+++ b/hald/linux/addons/addon-storage.c
@@ -250,7 +250,6 @@ is_mounted (const char *device_file)
 	FILE *f;
 	dbus_bool_t rc;
 	struct mntent mnt;
-	struct mntent *mnte;
 	char buf[512];
 
 	rc = FALSE;
@@ -258,7 +257,7 @@ is_mounted (const char *device_file)
 	if ((f = setmntent ("/etc/mtab", "r")) == NULL)
 		goto out;
 
-	while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
+	while (getmntent_r (f, &mnt, buf, sizeof(buf)) != NULL) {
 		if (strcmp (device_file, mnt.mnt_fsname) == 0) {
 			rc = TRUE;
 			goto out1;
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 3fbb51a..f343e75 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -205,7 +205,6 @@ blockdev_refresh_mount_state (HalDevice *d)
 {
 	FILE *f;
 	struct mntent mnt;
-	struct mntent *mnte;
 	char buf[1024];
 	GSList *volumes = NULL;
 	GSList *volume;
@@ -226,7 +225,7 @@ blockdev_refresh_mount_state (HalDevice *d)
 		goto exit;
 
 	/* loop over /proc/mounts */
-	while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
+	while (getmntent_r (f, &mnt, buf, sizeof(buf)) != NULL) {
 		struct stat statbuf;
 		dev_t devt;
 
diff --git a/hald/linux/probing/probe-storage.c b/hald/linux/probing/probe-storage.c
index 46f2531..dd5681c 100644
--- a/hald/linux/probing/probe-storage.c
+++ b/hald/linux/probing/probe-storage.c
@@ -78,7 +78,6 @@ is_mounted (const char *device_file)
 	FILE *f;
 	dbus_bool_t rc;
 	struct mntent mnt;
-	struct mntent *mnte;
 	char buf[512];
 
 	rc = FALSE;
@@ -86,7 +85,7 @@ is_mounted (const char *device_file)
 	if ((f = setmntent ("/etc/mtab", "r")) == NULL)
 		goto out;
 
-	while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
+	while (getmntent_r (f, &mnt, buf, sizeof(buf)) != NULL) {
 		if (strcmp (device_file, mnt.mnt_fsname) == 0) {
 			rc = TRUE;
 			goto out1;
commit d7270f9096ae249b2e318ade8dc2bc92c9c4ced5
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:44:37 2009 +0100

    fix some memory leaks on normal operation
    
    Fixed some memory leaks on normal operation. Some pointers were
    being lost when being overwritten by new values, others were just
    not being freed.

diff --git a/hald/create_cache.c b/hald/create_cache.c
index f2e5917..ed42b7f 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -703,6 +703,7 @@ di_rules_init (void)
 		HAL_INFO (("Generating rules done (occupying %d bytes)", header.all_rules_size));
 	}
 
+	g_free (cachename_temp);
 	return num_skipped_fdi_files;
 error:
 	HAL_ERROR (("Error generating fdi cache"));
diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index 697fb75..c0cb8c2 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -4158,8 +4158,12 @@ hald_exec_method_cb (HalDevice *d, guint32 exit_type,
 		dbus_message_unref (reply);
 	} else if (exp_name != NULL && exp_detail != NULL) {
 		if (!is_valid_interface_name (exp_name)) {
-			exp_detail = g_strconcat (exp_name, " \n ", exp_detail, NULL);
+			gchar *old_detail = exp_detail;
+
+			exp_detail = g_strconcat (exp_name, " \n ", old_detail, NULL);
 			exp_name = "org.freedesktop.Hal.Device.UnknownError";
+
+			g_free (old_detail);
 		}
 		reply = dbus_message_new_error (message, exp_name, exp_detail);
                 if (reply == NULL) {
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index ec4e405..3fbb51a 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -967,6 +967,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					link = g_strdup_printf ("%s/%s", path, dp->d_name);
 					target = resolve_symlink (link);
 					HAL_INFO ((" %s -> %s", link, target));
+					g_free (link);
 
 					if (target != NULL) {
 						HalDevice *slave_volume;
diff --git a/partutil/partutil.c b/partutil/partutil.c
index 42280af..3f0ec61 100644
--- a/partutil/partutil.c
+++ b/partutil/partutil.c
@@ -719,8 +719,10 @@ part_table_parse_gpt (int fd, guint64 offset, guint64 size)
 
 		partition_type_guid = get_le_guid (gpt_part_entry.partition_type_guid);
 
-		if (strcmp (partition_type_guid, GPT_PART_TYPE_GUID_EMPTY) == 0)
+		if (strcmp (partition_type_guid, GPT_PART_TYPE_GUID_EMPTY) == 0) {
+			g_free (partition_type_guid);
 			continue;
+		}
 
 		pe = part_entry_new (NULL,
 				     (guint8*) &gpt_part_entry,
commit 92e7f2e8b2a1a36d3ec2b371424719e7078d91da
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:43:15 2009 +0100

    do not leak on error conditions
    
    Fixed leaks on error conditions.

diff --git a/hald/create_cache.c b/hald/create_cache.c
index 232fe98..f2e5917 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -479,6 +479,7 @@ rules_add_fdi_file (const char *filename, int fd)
 	parser = XML_ParserCreate (NULL);
 	if (parser == NULL) {
 		HAL_ERROR (("Couldn't allocate memory for parser"));
+		g_free (fdi_ctx);
 		goto out;
 	}
 	XML_SetUserData (parser, fdi_ctx);
diff --git a/hald/device_info.c b/hald/device_info.c
index e378a2e..6444b54 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -852,6 +852,7 @@ handle_merge (struct rule *rule, HalDevice *d)
 
 					if (d == NULL) {
 						HAL_ERROR (("Could not find device with udi '%s'", udi_to_merge));
+						g_free (key);
 						return FALSE;
 					}
 				}
diff --git a/hald/linux/addons/addon-hid-ups.c b/hald/linux/addons/addon-hid-ups.c
index 31f3803..b18e1bc 100644
--- a/hald/linux/addons/addon-hid-ups.c
+++ b/hald/linux/addons/addon-hid-ups.c
@@ -274,7 +274,6 @@ ups_get_static (LibHalContext *ctx, const char *udi, int fd,
 
 	dbus_error_init (&error);
 	libhal_device_commit_changeset (ctx, cs, &error);
-	libhal_device_free_changeset (cs);
 
 	dbus_error_init (&error);
 	libhal_device_add_capability (ctx, udi, "battery", &error);
@@ -282,6 +281,8 @@ ups_get_static (LibHalContext *ctx, const char *udi, int fd,
 	ret = TRUE;
 
 out:
+	libhal_device_free_changeset (cs);
+
 	return ret;
 }
 
diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 5704f82..f6935d3 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -357,6 +357,7 @@ add_device (LibHalContext *ctx,
 
 	if ((device_file = libhal_ps_get_string (properties, "input.device")) == NULL) {
 		HAL_ERROR(("%s has no property input.device", udi));
+		g_free (data);
 		return;
 	}
 
@@ -369,6 +370,7 @@ add_device (LibHalContext *ctx,
 	eventfp = open(device_file, O_RDONLY | O_NONBLOCK);
 	if (!eventfp) {
 		HAL_ERROR(("Unable to open %s for reading", device_file));
+		g_free (data);
 		return;
 	}
 
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 08c5481..855b9dc 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -476,8 +476,10 @@ get_property_set (DBusMessageIter *iter)
 
 		p->type = (LibHalPropertyType) dbus_message_iter_get_arg_type (&var_iter);
 
-		if(!libhal_property_fill_value_from_variant (p, &var_iter))
+		if (!libhal_property_fill_value_from_variant (p, &var_iter)) {
+			free (p);
 			goto oom;
+		}
 
                 HASH_ADD_KEYPTR (hh, result->properties, p->key, strlen (p->key), p);
 
commit 0b50c9561267f78ce7af24eaee690e0b4dffb0eb
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:40:38 2009 +0100

    addon-cpufreq: do not leak va_arg on error condition
    
    Fixed addon-cpufreq: do not leak va_arg on error condition.

diff --git a/hald/linux/addons/addon-cpufreq.c b/hald/linux/addons/addon-cpufreq.c
index 8f9567c..f8d29ab 100644
--- a/hald/linux/addons/addon-cpufreq.c
+++ b/hald/linux/addons/addon-cpufreq.c
@@ -127,6 +127,7 @@ gboolean write_line(const char *filename, const char *fmt, ...)
 {
 	va_list	ap;
 	FILE	*fp;
+	int	l;
 
 	fp = fopen(filename, "w+");
 	if (!fp) {
@@ -136,15 +137,16 @@ gboolean write_line(const char *filename, const char *fmt, ...)
 	}
 
 	va_start(ap, fmt);
+	l = vfprintf(fp, fmt, ap);
+	va_end(ap);
+
+	fclose(fp);
 
-	if (vfprintf(fp, fmt, ap) < 0) {
+	if (l < 0) {
 		HAL_WARNING(("Could not write to file: %s", filename));
-		fclose(fp);
 		return FALSE;
 	}
 
-	va_end(ap);
-	fclose(fp);
 	return TRUE;
 }
 
commit aa50b81fe08101679ed4e905f5f8b490643b2661
Author: Guillem Jover <guillem.jover at nokia.com>
Date:   Sat Feb 21 11:38:50 2009 +0100

    do not compare arrays against NULL
    
    Do not compare arrays against NULL.

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index f75d88a..0b45f82 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -218,11 +218,11 @@ hald_udev_data (GIOChannel *source, GIOCondition condition, gpointer user_data)
 		HAL_INFO (("missing ACTION"));
 		goto invalid;
 	}
-	if (hotplug_event->sysfs.sysfs_path == NULL) {
+	if (hotplug_event->sysfs.sysfs_path[0] == '\0') {
 		HAL_INFO (("missing DEVPATH"));
 		goto invalid;
 	}
-	if (hotplug_event->sysfs.subsystem == NULL) {
+	if (hotplug_event->sysfs.subsystem[0] == '\0') {
 		HAL_INFO (("missing SUSBSYSTEM"));
 		goto invalid;
 	}
@@ -236,7 +236,7 @@ hald_udev_data (GIOChannel *source, GIOCondition condition, gpointer user_data)
 		HAL_INFO (("Temporary workaround: ignoring temporary cryptsetup file"));
 		goto invalid;
 	}
-	if (hotplug_event->sysfs.device_file && (strstr (hotplug_event->sysfs.device_file, "/dm-") != NULL)) {
+	if (strstr (hotplug_event->sysfs.device_file, "/dm-") != NULL) {
 		HAL_DEBUG (("Found a dm-device (%s), mark it", hotplug_event->sysfs.device_file));
 		hotplug_event->sysfs.is_dm_device = TRUE;
 	}


More information about the hal-commit mailing list