Fix off by 1 sector math when looking for unallocated space

This commit is contained in:
Curtis Gedak 2010-05-27 10:59:12 -06:00
parent 87e48efe88
commit be53cf584b
2 changed files with 6 additions and 6 deletions

View File

@ -1229,9 +1229,9 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
//look for gaps in between
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
{
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) > (MEBIBYTE / sector_size) )
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) > (MEBIBYTE / sector_size) )
|| ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
&& ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) == (MEBIBYTE / sector_size)
&& ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) == (MEBIBYTE / sector_size) )
)
)
{

View File

@ -71,9 +71,9 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
//look for gaps in between
for ( unsigned int t =0 ; t < partitions .size() -1 ; t++ )
{
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) > (MEBIBYTE / sector_size) )
if ( ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) > (MEBIBYTE / sector_size) )
|| ( ( partitions[ t + 1 ] .type != TYPE_LOGICAL ) // Only show exactly 1 MiB if following partition is not logical.
&& ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end ) == (MEBIBYTE / sector_size)
&& ( ( partitions[ t + 1 ] .sector_start - partitions[ t ] .sector_end - 1 ) == (MEBIBYTE / sector_size) )
)
)
{