[PATCH 3/7] maint: remove dead store code and declarations

Jim Meyering meyering at redhat.com
Tue Sep 29 19:29:00 UTC 2009


* libparted/labels/bsd.c (bsd_partition_set_flag): Remove dead store
and corresponding decl.
* libparted/arch/linux.c (init_ide): Likewise.
(_dm_maptype): Likewise.
(_mount_table_search): Likewise.
* libparted/fs/amiga/asfs.c (_asfs_probe): Likewise.
* libparted/labels/mac.c (mac_alloc_metadata): Likewise.
* libparted/labels/rdb.c (amiga_write): Likewise.
(amiga_write): Again.
* libparted/fs/amiga/apfs.c (_generic_apfs_probe): Likewise.
* libparted/fs/hfs/reloc_plus.c (hfsplus_effect_move_extent): Likewise.
* libparted/fs/hfs/reloc.c (hfs_effect_move_extent): Likewise.
* libparted/labels/dos.c (probe_partition_for_geom): Remove dead
store in "can't happen" case.
---
 libparted/arch/linux.c        |   12 +++---------
 libparted/fs/amiga/apfs.c     |    5 ++---
 libparted/fs/amiga/asfs.c     |    8 ++------
 libparted/fs/hfs/reloc.c      |    2 +-
 libparted/fs/hfs/reloc_plus.c |    2 +-
 libparted/labels/bsd.c        |    2 --
 libparted/labels/dos.c        |    1 -
 libparted/labels/mac.c        |    4 ----
 libparted/labels/rdb.c        |    7 +++----
 9 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 52c31e2..52f7d21 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -408,7 +408,6 @@ _dm_maptype (PedDevice *dev)
 {
         LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
         struct dm_task *dmt;
-        void *next;
         uint64_t start, length;
         char *target_type = NULL;
         char *params;
@@ -429,8 +428,7 @@ _dm_maptype (PedDevice *dev)
         if (!dm_task_run(dmt))
                 goto bad;

-        next = dm_get_next_target(dmt, NULL, &start, &length,
-                                  &target_type, &params);
+        dm_get_next_target(dmt, NULL, &start, &length, &target_type, &params);

         arch_specific->dmtype = strdup(target_type ? target_type : "NO-TARGET");
         if (arch_specific->dmtype == NULL)
@@ -741,7 +739,6 @@ init_ide (PedDevice* dev)
 {
         LinuxSpecific*          arch_specific = LINUX_SPECIFIC (dev);
         struct stat             dev_stat;
-        int                     dev_major;
         struct hd_driveid       hdi;
         PedExceptionOption      ex_status;
         char                    hdi_buf[41];
@@ -750,8 +747,6 @@ init_ide (PedDevice* dev)
         if (!_device_stat (dev, &dev_stat))
                 goto error;

-        dev_major = major (dev_stat.st_rdev);
-
         if (!ped_device_open (dev))
                 goto error;

@@ -2146,14 +2141,13 @@ _mount_table_search (const char* file_name, dev_t dev)
         char line[512];
         char part_name[512];
         FILE* file;
-        int junk;

         file = fopen (file_name, "r");
         if (!file)
                 return 0;
         while (fgets (line, 512, file)) {
-                junk = sscanf (line, "%s", part_name);
-                if (stat (part_name, &part_stat) == 0) {
+                if (sscanf (line, "%s", part_name) == 1
+                    && stat (part_name, &part_stat) == 0) {
                         if (part_stat.st_rdev == dev) {
                                 fclose (file);
                                 return 1;
diff --git a/libparted/fs/amiga/apfs.c b/libparted/fs/amiga/apfs.c
index 41df426..0398794 100644
--- a/libparted/fs/amiga/apfs.c
+++ b/libparted/fs/amiga/apfs.c
@@ -44,19 +44,18 @@ _generic_apfs_probe (PedGeometry* geom, uint32_t kind)
 	uint32_t *block;
 	PedSector root;
 	struct PartitionBlock * part;
-	uint32_t blocksize = 1, reserved = 2, prealloc = 0;
+	uint32_t blocksize = 1, reserved = 2;

 	PED_ASSERT (geom != NULL, return NULL);
 	PED_ASSERT (geom->dev != NULL, return NULL);

-	/* Finds the blocksize, prealloc and reserved values of the partition block */
+	/* Finds the blocksize and reserved values of the partition block */
 	if (!(part = ped_malloc (PED_SECTOR_SIZE_DEFAULT*blocksize))) {
 		ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
 			_("%s : Failed to allocate partition block\n"), __func__);
 		goto error_part;
 	}
 	if (amiga_find_part(geom, part) != NULL) {
-		prealloc = PED_BE32_TO_CPU (part->de_PreAlloc);
 		reserved = PED_BE32_TO_CPU (part->de_Reserved);
 		blocksize = PED_BE32_TO_CPU (part->de_SizeBlock)
 			* PED_BE32_TO_CPU (part->de_SectorPerBlock) / 128;
diff --git a/libparted/fs/amiga/asfs.c b/libparted/fs/amiga/asfs.c
index 7d5d2cb..0dfc27d 100644
--- a/libparted/fs/amiga/asfs.c
+++ b/libparted/fs/amiga/asfs.c
@@ -56,24 +56,20 @@ _asfs_probe (PedGeometry* geom)
 {
 	uint32_t *block;
 	struct PartitionBlock * part;
-	int blocksize = 1, reserved = 1, prealloc = 1;
+	int blocksize = 1;
         PedSector root;
         int found = 0;

 	PED_ASSERT (geom != NULL, return NULL);
 	PED_ASSERT (geom->dev != NULL, return NULL);

-	/* Finds the blocksize, prealloc and reserved values of the partition block */
+	/* Finds the blocksize of the partition block */
 	if (!(part = ped_malloc (PED_SECTOR_SIZE_DEFAULT*blocksize))) {
 		ped_exception_throw(PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
 			_("%s : Failed to allocate partition block\n"), __func__);
 		goto error_part;
 	}
 	if (amiga_find_part(geom, part) != NULL) {
-		prealloc = PED_BE32_TO_CPU (part->de_PreAlloc) == 0 ?
-			1 : PED_BE32_TO_CPU (part->de_PreAlloc);
-		reserved = PED_BE32_TO_CPU (part->de_Reserved) == 0 ?
-			1 : PED_BE32_TO_CPU (part->de_Reserved);
 		blocksize = PED_BE32_TO_CPU (part->de_SizeBlock)
 			* PED_BE32_TO_CPU (part->de_SectorPerBlock) / 128;
 	}
diff --git a/libparted/fs/hfs/reloc.c b/libparted/fs/hfs/reloc.c
index 8542678..2e7463a 100644
--- a/libparted/fs/hfs/reloc.c
+++ b/libparted/fs/hfs/reloc.c
@@ -55,7 +55,7 @@ hfs_effect_move_extent (PedFileSystem *fs, unsigned int *ptr_fblock,
 	PED_ASSERT (hfs_block != NULL, return -1);
 	PED_ASSERT (*ptr_to_fblock <= *ptr_fblock, return -1);
 	/* quiet gcc */
-	next_to_fblock = start = stop = 0;
+	start = stop = 0;

 /*
 	Try to fit the extent AT or _BEFORE_ the wanted place,
diff --git a/libparted/fs/hfs/reloc_plus.c b/libparted/fs/hfs/reloc_plus.c
index 3309c1e..69ace77 100644
--- a/libparted/fs/hfs/reloc_plus.c
+++ b/libparted/fs/hfs/reloc_plus.c
@@ -59,7 +59,7 @@ hfsplus_effect_move_extent (PedFileSystem *fs, unsigned int *ptr_fblock,
 	PED_ASSERT (hfsp_block != NULL, return -1);
 	PED_ASSERT (*ptr_to_fblock <= *ptr_fblock, return -1);
 	/* quiet GCC */
-	next_to_fblock = start = stop = 0;
+	start = stop = 0;

 /*
 	Try to fit the extent AT or _BEFORE_ the wanted place,
diff --git a/libparted/labels/bsd.c b/libparted/labels/bsd.c
index aef8e1a..54d13ee 100644
--- a/libparted/labels/bsd.c
+++ b/libparted/labels/bsd.c
@@ -476,7 +476,6 @@ bsd_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
 static int
 bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
 {
-	PedDisk*			disk;
 //	PedPartition*		walk; // since -Werror, this unused variable would break build
 	BSDPartitionData*	bsd_data;

@@ -485,7 +484,6 @@ bsd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
 	PED_ASSERT (part->disk != NULL, return 0);

 	bsd_data = part->disk_specific;
-	disk = part->disk;

 	switch (flag) {
 		case PED_PARTITION_BOOT:
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index faee34d..cc9e0e3 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -616,7 +616,6 @@ probe_partition_for_geom (const PedPartition* part, PedCHSGeometry* bios_geom)
 		head_size = ( A_ - C * cyl_size ) / H;
 	else {
 		/* should not happen because denum != 0 */
-		head_size = 0;
 		PED_ASSERT (0, return 0);
 	}

diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 15b2fd8..c8bf0d2 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -1569,14 +1569,10 @@ error:
 static int
 mac_alloc_metadata (PedDisk* disk)
 {
-	MacDiskData*		mac_disk_data;
-
 	PED_ASSERT (disk != NULL, return 0);
 	PED_ASSERT (disk->disk_specific != NULL, return 0);
 	PED_ASSERT (disk->dev != NULL, return 0);

-	mac_disk_data = disk->disk_specific;
-
 	if (!add_metadata_part (disk, 0, disk->dev->sector_size / 512 - 1))
 		return 0;

diff --git a/libparted/labels/rdb.c b/libparted/labels/rdb.c
index a873771..1d21dbd 100644
--- a/libparted/labels/rdb.c
+++ b/libparted/labels/rdb.c
@@ -651,7 +651,7 @@ amiga_write (const PedDisk* disk)
 	struct LinkedBlock *block;
 	struct PartitionBlock *partition;
 	PedPartition *part, *next_part;
-	PedSector cylblocks, first_hb, last_hb, last_used_hb;
+	PedSector cylblocks, first_hb, last_hb;
 	uint32_t * table;
 	uint32_t i;
 	uint32_t rdb_num, part_num, block_num, next_num;
@@ -681,7 +681,6 @@ amiga_write (const PedDisk* disk)
 		(PedSector) PED_BE32_TO_CPU (rdb->rdb_Sectors);
 	first_hb = (PedSector) PED_BE32_TO_CPU (rdb->rdb_RDBBlocksLo);
 	last_hb = (PedSector) PED_BE32_TO_CPU (rdb->rdb_RDBBlocksHi);
-	last_used_hb = (PedSector) PED_BE32_TO_CPU (rdb->rdb_HighRDSKBlock);

 	/* Allocate a free block table and initialize it.
 	   There must be room for at least RDB_NUM + 2 entries, since
@@ -736,8 +735,8 @@ amiga_write (const PedDisk* disk)
 		goto error_free_table;
 	}

-	block_num = next_num = part_num = _amiga_next_free_block(table, rdb_num+1,
-	                                                         IDNAME_PARTITION);
+	block_num = part_num = _amiga_next_free_block(table, rdb_num+1,
+                                                      IDNAME_PARTITION);
 	part = _amiga_next_real_partition(disk, NULL);
 	rdb->rdb_PartitionList = PED_CPU_TO_BE32(part ? part_num : LINK_END);
 	for (; part != NULL; part = next_part, block_num = next_num) {
--
1.6.5.rc2.177.ga9dd6




More information about the parted-devel mailing list