Simplify logic in MB_Needed_for_Boot_Record() et al

The first two clauses say is the partition object type unallocated
inside an extended partition, or a logical partition (which only occur
inside an extended partition).  As these are the only two partition
object types which can occur inside an extended partition, this is
equivalent to saying is the partition object inside an extended
partition.  Simplify.
This commit is contained in:
Mike Fleetwood 2021-10-21 07:33:30 +01:00 committed by Curtis Gedak
parent eaaa5719f7
commit 67b07f86e6
2 changed files with 13 additions and 22 deletions

View File

@ -499,19 +499,15 @@ void Dialog_Base_Partition::Set_MinMax_Text( Sector min, Sector max )
label_minmax .set_text( str_temp ) ; label_minmax .set_text( str_temp ) ;
} }
int Dialog_Base_Partition::MB_Needed_for_Boot_Record( const Partition & partition ) int Dialog_Base_Partition::MB_Needed_for_Boot_Record( const Partition & partition )
{ {
//Determine if space is needed for the Master Boot Record or // Determine if space needs reserving for the partition table or the EBR (Extended
// the Extended Boot Record. Generally an an additional track or MEBIBYTE // Boot Record). Generally a track or MEBIBYTE is reserved. For our purposes
// is required so for our purposes reserve a MEBIBYTE in front of the partition. // reserve a MEBIBYTE at the start of the partition.
// NOTE: This logic also contained in Win_GParted::set_valid_operations // NOTE: This logic also contained in Win_GParted::set_valid_operations()
if ( ( partition .inside_extended if (partition.inside_extended ||
&& partition .type == TYPE_UNALLOCATED partition.sector_start < MEBIBYTE / partition.sector_size )
)
|| ( partition .type == TYPE_LOGICAL )
/* Beginning of disk device */
|| (partition.sector_start < (MEBIBYTE / partition.sector_size))
)
return 1 ; return 1 ;
else else
return 0 ; return 0 ;

View File

@ -1354,17 +1354,12 @@ void Win_GParted::set_valid_operations()
else else
required_size = copied_filesystem_ptn.get_byte_length(); required_size = copied_filesystem_ptn.get_byte_length();
//Determine if space is needed for the Master Boot Record or // Determine if space needs reserving for the partition table or the EBR (Extended
// the Extended Boot Record. Generally an an additional track or MEBIBYTE // Boot Record). Generally a track or MEBIBYTE is reserved. For our purposes
// is required so for our purposes reserve a MEBIBYTE in front of the partition. // reserve a MEBIBYTE at the start of the partition.
// NOTE: This logic also contained in Dialog_Base_Partition::MB_Needed_for_Boot_Record // NOTE: This logic also contained in Dialog_Base_Partition::MB_Needed_for_Boot_Record()
if ( ( selected_partition_ptr->inside_extended if (selected_partition_ptr->inside_extended ||
&& selected_partition_ptr->type == TYPE_UNALLOCATED selected_partition_ptr->sector_start < MEBIBYTE / selected_partition_ptr->sector_size )
)
|| ( selected_partition_ptr->type == TYPE_LOGICAL )
/* Beginning of disk device */
|| (selected_partition_ptr->sector_start < (MEBIBYTE / selected_partition_ptr->sector_size))
)
required_size += MEBIBYTE; required_size += MEBIBYTE;
//Determine if space is needed for the Extended Boot Record for a logical partition //Determine if space is needed for the Extended Boot Record for a logical partition