[gparted] Replace Operation class members index and index_extended with local variables (#755214)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Replace Operation class members index and index_extended with local variables (#755214)
- Date: Tue, 29 Sep 2015 18:43:34 +0000 (UTC)
commit cbfb7e51f50b36a7b190e8ade94ef0114f1fb3a8
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sun Sep 27 09:30:13 2015 +0100
Replace Operation class members index and index_extended with local variables (#755214)
These member variables store no Operation class information and were
being used as local variables. Replace with local variables.
Also indent a code block within an if clause so that the compiler can
confirm that the new local variable isn't used uninitialised. Prevents
this compiler warning:
OperationResizeMove.cc: In member function 'void
GParted::OperationResizeMove::apply_normal_to_visual(std::vector<GParted::Partition,
std::allocator<GParted::Partition> >&)':
OperationResizeMove.cc:125: warning: 'index' may be used uninitialized in this function
Bug 755214 - Refactor operation merging
include/Operation.h | 3 ---
src/Operation.cc | 6 ++++++
src/OperationDelete.cc | 3 +++
src/OperationResizeMove.cc | 31 ++++++++++++++++++-------------
4 files changed, 27 insertions(+), 16 deletions(-)
---
diff --git a/include/Operation.h b/include/Operation.h
index 7d06893..83ea8c8 100644
--- a/include/Operation.h
+++ b/include/Operation.h
@@ -65,9 +65,6 @@ protected:
void insert_unallocated( std::vector<Partition> & partitions, Sector start, Sector end, Byte_Value
sector_size, bool inside_extended );
void substitute_new( std::vector<Partition> & partitions );
void insert_new( std::vector<Partition> & partitions );
-
- int index ;
- int index_extended ;
};
} //GParted
diff --git a/src/Operation.cc b/src/Operation.cc
index 1f963a8..5b16ca6 100644
--- a/src/Operation.cc
+++ b/src/Operation.cc
@@ -110,6 +110,9 @@ void Operation::insert_unallocated( std::vector<Partition> & partitions, Sector
// it with this operation's new partition.
void Operation::substitute_new( std::vector<Partition> & partitions )
{
+ int index_extended;
+ int index;
+
if ( partition_original.inside_extended )
{
index_extended = find_index_extended( partitions );
@@ -140,6 +143,9 @@ void Operation::insert_new( std::vector<Partition> & partitions )
// on disk. Therefore they match the original partition when visually re-applying
// their operations to the disk graphic. Hence their use of,
// find_index_original().
+ int index_extended;
+ int index;
+
if ( partition_new.inside_extended )
{
index_extended = find_index_extended( partitions );
diff --git a/src/OperationDelete.cc b/src/OperationDelete.cc
index a04c5f0..8b34ec3 100644
--- a/src/OperationDelete.cc
+++ b/src/OperationDelete.cc
@@ -30,6 +30,9 @@ OperationDelete::OperationDelete( const Device & device, const Partition & parti
void OperationDelete::apply_to_visual( std::vector<Partition> & partitions )
{
+ int index_extended;
+ int index;
+
if ( partition_original .inside_extended )
{
index_extended = find_index_extended( partitions ) ;
diff --git a/src/OperationResizeMove.cc b/src/OperationResizeMove.cc
index 16982f6..de51148 100644
--- a/src/OperationResizeMove.cc
+++ b/src/OperationResizeMove.cc
@@ -33,8 +33,6 @@ OperationResizeMove::OperationResizeMove( const Device & device,
void OperationResizeMove::apply_to_visual( std::vector<Partition> & partitions )
{
- index = index_extended = -1 ;
-
if ( partition_original .type == GParted::TYPE_EXTENDED )
apply_extended_to_visual( partitions ) ;
else
@@ -123,23 +121,28 @@ void OperationResizeMove::create_description()
void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & partitions )
{
+ int index_extended;
+ int index;
+
if ( partition_original .inside_extended )
{
index_extended = find_index_extended( partitions ) ;
if ( index_extended >= 0 )
- index = find_index_original( partitions[ index_extended ] .logicals ) ;
-
- if ( index >= 0 )
{
- partitions[ index_extended ] .logicals[ index ] = partition_new ;
- remove_adjacent_unallocated( partitions[ index_extended ] .logicals, index ) ;
-
- insert_unallocated( partitions[ index_extended ] .logicals,
- partitions[ index_extended ] .sector_start,
- partitions[ index_extended ] .sector_end,
- device .sector_size,
- true ) ;
+ index = find_index_original( partitions[ index_extended ] .logicals ) ;
+
+ if ( index >= 0 )
+ {
+ partitions[index_extended].logicals[index] = partition_new;
+ remove_adjacent_unallocated( partitions[index_extended].logicals, index );
+
+ insert_unallocated( partitions[index_extended].logicals,
+ partitions[index_extended].sector_start,
+ partitions[index_extended].sector_end,
+ device.sector_size,
+ true );
+ }
}
}
else
@@ -158,6 +161,8 @@ void OperationResizeMove::apply_normal_to_visual( std::vector<Partition> & parti
void OperationResizeMove::apply_extended_to_visual( std::vector<Partition> & partitions )
{
+ int index_extended;
+
//stuff OUTSIDE extended partition
index_extended = find_index_extended( partitions ) ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]