[gparted] Fix off by 1 sector math when looking for unallocated space
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Fix off by 1 sector math when looking for unallocated space
- Date: Thu, 27 May 2010 17:10:27 +0000 (UTC)
commit be53cf584b97ae3331d1d211b1c71b740c6aba32
Author: Curtis Gedak <gedakc gmail com>
Date: Thu May 27 10:59:12 2010 -0600
Fix off by 1 sector math when looking for unallocated space
src/GParted_Core.cc | 8 ++++----
src/Operation.cc | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index 7b175dc..8faf62e 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1229,10 +1229,10 @@ 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) )
+ )
)
{
partition_temp .sector_start = partitions[ t ] .sector_end +1 ;
@@ -1243,7 +1243,7 @@ void GParted_Core::insert_unallocated( const Glib::ustring & device_path,
}
//last partition end <---> end
- if ( (end - partitions .back() .sector_end ) >= (MEBIBYTE / sector_size) )
+ if ( (end - partitions .back() .sector_end) >= (MEBIBYTE / sector_size) )
{
partition_temp .sector_start = partitions .back() .sector_end +1 ;
partition_temp .sector_end = end ;
diff --git a/src/Operation.cc b/src/Operation.cc
index afd4467..89170db 100644
--- a/src/Operation.cc
+++ b/src/Operation.cc
@@ -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) )
)
)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]