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
This commit is contained in:
parent
a1ab21285b
commit
cbfb7e51f5
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 ) ;
|
||||
|
|
|
@ -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 ) ;
|
||||
index = find_index_original( partitions[ index_extended ] .logicals ) ;
|
||||
|
||||
insert_unallocated( partitions[ index_extended ] .logicals,
|
||||
partitions[ index_extended ] .sector_start,
|
||||
partitions[ index_extended ] .sector_end,
|
||||
device .sector_size,
|
||||
true ) ;
|
||||
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 ) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue