[parted-devel] Undo part of the dos.c constification.

Jim Meyering jim at meyering.net
Mon Mar 5 22:48:15 CET 2007


I've just noticed that I introduced a bug.
I would have noticed sooner, but for the fact that configure
wasn't finding "check", and so the label tests weren't running.
Once ./label ran, it got a segfault in the global constructor,
trying to write to the now read-only location.

This change fixes it.

Undo part of the dos.c constification.
* libparted/disk.c: The sole parameter of ped_disk_type_register
and ped_disk_type_unregister must *not* be const.
* libparted/labels/dos.c (msdos_disk_type): Likewise for the
corresponding static struct in dos.c, since those functions modify
the struct.  This didn't show up at compile time due to casts.
* include/parted/disk.h: Update prototypes, too.
---

 include/parted/disk.h  |    4 ++--
 libparted/disk.c       |    4 ++--
 libparted/labels/dos.c |    4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/parted/disk.h b/include/parted/disk.h
index 459848e..06ecfbb 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -225,8 +225,8 @@ struct _PedDiskArchOps {
         int (*disk_commit) (PedDisk* disk);
 };
 
-extern void ped_disk_type_register (const PedDiskType* type);
-extern void ped_disk_type_unregister (const PedDiskType* type);
+extern void ped_disk_type_register (PedDiskType* type);
+extern void ped_disk_type_unregister (PedDiskType* type);
 
 /**
  * Deprecated: use ped_disk_type_register.
diff --git a/libparted/disk.c b/libparted/disk.c
index f91113d..935a0fc 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -63,7 +63,7 @@ static int _disk_raw_add (PedDisk* disk, PedPartition* part);
 static PedDiskType*	disk_types = NULL;
 
 void
-ped_disk_type_register (const PedDiskType* disk_type)
+ped_disk_type_register (PedDiskType* disk_type)
 {
 	PED_ASSERT (disk_type != NULL, return);
 	PED_ASSERT (disk_type->ops != NULL, return);
@@ -75,7 +75,7 @@ ped_disk_type_register (const PedDiskType* disk_type)
 }
 
 void
-ped_disk_type_unregister (const PedDiskType* disk_type)
+ped_disk_type_unregister (PedDiskType* disk_type)
 {
 	PedDiskType*	walk;
 	PedDiskType*	last = NULL;
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index 3582037..fda8a79 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -148,7 +148,7 @@ typedef struct {
 	OrigState*	orig;			/* used for CHS stuff */
 } DosPartitionData;
 
-static const PedDiskType msdos_disk_type;
+static PedDiskType msdos_disk_type;
 
 static int
 msdos_probe (const PedDevice *dev)
@@ -2196,7 +2196,7 @@ static PedDiskOps msdos_disk_ops = {
 				msdos_get_max_primary_partition_count
 };
 
-static const PedDiskType msdos_disk_type = {
+static PedDiskType msdos_disk_type = {
 	next:		NULL,
 	name:		"msdos",
 	ops:		&msdos_disk_ops,



More information about the parted-devel mailing list