diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc index baf14425..d30ab3cd 100644 --- a/src/GParted_Core.cc +++ b/src/GParted_Core.cc @@ -365,10 +365,10 @@ bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partitio { Sector diff = 0; - //Determine if partition size is less than a disk cylinder - bool less_than_cylinder = false; - if ( ( partition .sector_end - partition .sector_start ) < device .cylsize ) - less_than_cylinder = true; + //Determine if partition size is less than half a disk cylinder + bool less_than_half_cylinder = false; + if ( ( partition .sector_end - partition .sector_start ) < ( device .cylsize / 2 ) ) + less_than_half_cylinder = true; if ( partition.type == TYPE_LOGICAL || partition.sector_start == device .sectors @@ -393,7 +393,7 @@ bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partitio } if ( diff && ! partition .strict_start ) { - if ( diff < ( device .cylsize / 2 ) || less_than_cylinder ) + if ( diff < ( device .cylsize / 2 ) || less_than_half_cylinder ) partition .sector_start -= diff ; else partition .sector_start += (device .cylsize - diff ) ; @@ -402,7 +402,7 @@ bool GParted_Core::snap_to_cylinder( const Device & device, Partition & partitio diff = (partition .sector_end +1) % device .cylsize ; if ( diff ) { - if ( diff < ( device .cylsize / 2 ) && ! less_than_cylinder ) + if ( diff < ( device .cylsize / 2 ) && ! less_than_half_cylinder ) partition .sector_end -= diff ; else partition .sector_end += (device .cylsize - diff ) ;