[parted-devel] libparted/disk.c: ped_unregister_disk_type

Debarshi 'Rishi' Ray debarshi.ray at gmail.com
Mon Sep 11 20:02:35 UTC 2006


It seems that the ped_unregister_disk_type function defined in
libparted/disk.c does not take into account 2 situations:
a. disk_types == NULL, ie. ped_register_disk_type was invoked lesser
number of times than ped_unregister_disk_type
b. the given PedDiskType *type does not exist in the list of
disk-types registered

I do not know whether these are trivial or non-trivial issues, but in
any case if you think it needs to be fixed, here is the output of diff
-c:

*** disk.c      2006-09-03 05:17:28.000000000 +0000
--- disk.rishi.c        2006-09-12 01:33:21.000000000 +0000
***************
*** 80,91 ****
        PedDiskType*    walk;
        PedDiskType*    last = NULL;

        PED_ASSERT (type != NULL, return);

!       for (walk = disk_types; walk != NULL; last = walk, walk = walk->next) {
                if (walk == type) break;
        }

        if (last)
                ((struct _PedDiskType*) last)->next = type->next;
        else
--- 80,93 ----
        PedDiskType*    walk;
        PedDiskType*    last = NULL;

+       PED_ASSERT (disk_types != NULL, return);
        PED_ASSERT (type != NULL, return);

!       for (walk = disk_types; walk; last = walk, walk = walk->next) {
                if (walk == type) break;
        }

+       PED_ASSERT (walk != NULL, return);
        if (last)
                ((struct _PedDiskType*) last)->next = type->next;
        else

It also does not "free" the memory hogged by the PedDiskType *type
after successful removal.

Happy hacking,
Debarshi
-- 
It matters not whether you win or lose; what matters is whether I win or lose.
                                            - Darrin Weinberg



More information about the parted-devel mailing list