[gparted] Prevent 'index' may be used uninitialised warning in OperationDelete (#755214)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Prevent 'index' may be used uninitialised warning in OperationDelete (#755214)
- Date: Thu, 8 Oct 2015 18:51:30 +0000 (UTC)
commit 81b673ff5d5eb0b1f98405a4e14a81a42873fece
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Wed Oct 7 21:25:28 2015 +0100
Prevent 'index' may be used uninitialised warning in OperationDelete (#755214)
I missed another case of 'index' may be used uninitialised warning in
OperationDelete::apply_to_visual(). Indent a code block within an if
clause so that the compiler can confirm that the 'index' local variable
isn't used uninitialised. Prevent this compiler warning:
OperationDelete.cc: In member function 'virtual void
GParted::OperationDelete::apply_to_visual(std::vector<GParted::Partition, std::allocator<GParted::Partition>
&)':
OperationDelete.cc:34: warning: 'index' may be used uninitialized in this function
Bug 755214 - Refactor operation merging
src/OperationDelete.cc | 37 ++++++++++++++++++++-----------------
1 files changed, 20 insertions(+), 17 deletions(-)
---
diff --git a/src/OperationDelete.cc b/src/OperationDelete.cc
index 8b34ec3..20c6b75 100644
--- a/src/OperationDelete.cc
+++ b/src/OperationDelete.cc
@@ -38,26 +38,29 @@ void OperationDelete::apply_to_visual( std::vector<Partition> & partitions )
index_extended = find_index_extended( partitions ) ;
if ( index_extended >= 0 )
+ {
index = find_index_original( partitions[ index_extended ] .logicals ) ;
- if ( index >= 0 )
- {
- remove_original_and_adjacent_unallocated( partitions[ index_extended ] .logicals,
index ) ;
+ if ( index >= 0 )
+ {
+ remove_original_and_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 ) ;
-
- //if deleted partition was logical we have to decrease the partitionnumbers of the
logicals
- //with higher numbers by one (only if its a real partition)
- if ( partition_original .status != GParted::STAT_NEW )
- for ( unsigned int t = 0 ; t < partitions[ index_extended ] .logicals .size()
; t++ )
- if ( partitions[ index_extended ] .logicals[ t ] .partition_number >
- partition_original .partition_number )
- partitions[ index_extended ] .logicals[ t ] .Update_Number(
- partitions[ index_extended ] .logicals[ t ]
.partition_number -1 );
+ insert_unallocated( partitions[index_extended].logicals,
+ partitions[index_extended].sector_start,
+ partitions[index_extended].sector_end,
+ device.sector_size,
+ true );
+
+ // If deleted partition was logical we have to decrease
+ // the partition numbers of the logicals with higher
+ // numbers by one (only if its a real partition)
+ if ( partition_original.status != STAT_NEW )
+ for ( unsigned int t = 0 ; t < partitions[index_extended].logicals
.size() ; t++ )
+ if ( partitions[index_extended].logicals[t].partition_number >
+ partition_original.partition_number
)
+ partitions[index_extended].logicals[t].Update_Number(
+
partitions[index_extended].logicals[t].partition_number -1 );
+ }
}
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]