Re: [Utopia] [patch] mount/unmount when starting/stopping



Hi,

On Tue, 2004-08-17 at 15:42 +0200, David Zeuthen wrote:
> +/** List of UDI's for volumes mounted when starting up */
> +static GSList *mount_ignore_udi_list;
> +
> +/** List of UDI's of all volumes mounted during the lifetime of the program */
> +static GSList *all_mounted_volumes;

You need to assign these to NULL.

> +               for (i=all_mounted_volumes; i != NULL; i = g_slist_next (i)) {
> +                       if (strcmp (udi, (const char *)i->data) == 0) {
> +                               g_free (i->data);
> +                               all_mounted_volumes = 
> +                                       g_slist_remove_link (
> +                                               all_mounted_volumes, i);
> +                               break;
> +                       }
> +               }

I think this will cause problems because if you remove the link that
you're on, then the next for node i will be NULL and the loop will
terminate.  Also since i isn't freed, you'll be leaking the node.  I
think you'd need to do something like:

for (i = all_mounted_volumes; i != NULL; i = next) {
	next = g_slist_next (i);

	...

	all_mounted_volumes = g_slist_delete_link (all_mounted_volumes, i);
}

Ditto for mount_ignore_udi_list.  Other than those, it looks good to me.

Joe






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