[gparted] Remove some unnecessary extended partition checks from GParted_Core (#788308)



commit 326df46af2a3e0474273d610a14bdeb6fb37aa5f
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Fri Aug 19 14:44:13 2016 +0100

    Remove some unnecessary extended partition checks from GParted_Core (#788308)
    
    For example GParted_Core::read_label() is already called for empty
    partitions where .filesystem = FS_UNKNOWN.  In that case get_fs()
    returns an unsupported capability set with all capabilities set to
    FS::NONE.  The same would be true extended partitions where .filesystem
    = FS_EXTENDED too; get_fs() would return an unsupported capability set
    with all capabilities set to FS::NONE.
    
    Therefore the if not extended partition condition around the switch
    statements is not necessary in GParted_Core::read_label(), read_uuid(),
    label_filesystem() and change_uuid().  Remove.
    
    This also achieves removal of some uses of partition type enumerations
    in advance of the introduction of new partition type TYPE_UNPARTITIONED.
    
    Bug 788308 - Remove whole_device partition flag

 src/GParted_Core.cc |   76 +++++++++++++++++++++-----------------------------
 1 files changed, 32 insertions(+), 44 deletions(-)
---
diff --git a/src/GParted_Core.cc b/src/GParted_Core.cc
index bbb125e..ff3a129 100644
--- a/src/GParted_Core.cc
+++ b/src/GParted_Core.cc
@@ -1515,39 +1515,33 @@ FILESYSTEM GParted_Core::detect_filesystem( PedDevice * lp_device, PedPartition
        
 void GParted_Core::read_label( Partition & partition )
 {
-       if ( partition .type != TYPE_EXTENDED )
+       FileSystem* p_filesystem = NULL;
+       switch ( get_fs( partition.filesystem ).read_label )
        {
-               FileSystem* p_filesystem = NULL ;
-               switch( get_fs( partition .filesystem ) .read_label )
-               {
-                       case FS::EXTERNAL:
-                               p_filesystem = get_filesystem_object( partition .filesystem ) ;
-                               if ( p_filesystem )
-                                       p_filesystem ->read_label( partition ) ;
-                               break ;
+               case FS::EXTERNAL:
+                       p_filesystem = get_filesystem_object( partition.filesystem );
+                       if ( p_filesystem )
+                               p_filesystem->read_label( partition );
+                       break;
 
-                       default:
-                               break ;
-               }
+               default:
+                       break;
        }
 }
 
 void GParted_Core::read_uuid( Partition & partition )
 {
-       if ( partition .type != TYPE_EXTENDED )
+       FileSystem* p_filesystem = NULL;
+       switch ( get_fs( partition.filesystem ).read_uuid )
        {
-               FileSystem* p_filesystem = NULL ;
-               switch( get_fs( partition .filesystem ) .read_uuid )
-               {
-                       case FS::EXTERNAL:
-                               p_filesystem = get_filesystem_object( partition .filesystem ) ;
-                               if ( p_filesystem )
-                                       p_filesystem ->read_uuid( partition ) ;
-                               break ;
+               case FS::EXTERNAL:
+                       p_filesystem = get_filesystem_object( partition.filesystem );
+                       if ( p_filesystem )
+                               p_filesystem->read_uuid( partition );
+                       break;
 
-                       default:
-                               break ;
-               }
+               default:
+                       break;
        }
 }
 
@@ -2180,18 +2174,15 @@ bool GParted_Core::label_filesystem( const Partition & partition, OperationDetai
 
        bool succes = false ;
        FileSystem* p_filesystem = NULL ;
-       if ( partition .type != TYPE_EXTENDED )
+       switch ( get_fs( partition.filesystem ).write_label )
        {
-               switch( get_fs( partition .filesystem ) .write_label )
-               {
-                       case FS::EXTERNAL:
-                               succes = ( p_filesystem = get_filesystem_object( partition .filesystem ) ) &&
-                                        p_filesystem ->write_label( partition, operationdetail 
.get_last_child() ) ;
-                               break ;
+               case FS::EXTERNAL:
+                       succes =    ( p_filesystem = get_filesystem_object( partition.filesystem ) )
+                                && p_filesystem->write_label( partition, operationdetail.get_last_child() );
+                       break;
 
-                       default:
-                               break ;
-               }
+               default:
+                       break;
        }
 
        operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;
@@ -2251,18 +2242,15 @@ bool GParted_Core::change_filesystem_uuid( const Partition & partition, Operatio
 
        bool succes = false ;
        FileSystem* p_filesystem = NULL ;
-       if ( partition .type != TYPE_EXTENDED )
+       switch ( get_fs( partition.filesystem ).write_uuid )
        {
-               switch( get_fs( partition .filesystem ) .write_uuid )
-               {
-                       case FS::EXTERNAL:
-                               succes = ( p_filesystem = get_filesystem_object( partition .filesystem ) ) &&
-                                        p_filesystem ->write_uuid( partition, operationdetail 
.get_last_child() ) ;
-                               break ;
+               case FS::EXTERNAL:
+                       succes =    ( p_filesystem = get_filesystem_object( partition.filesystem ) )
+                                && p_filesystem->write_uuid( partition, operationdetail.get_last_child() );
+                       break;
 
-                       default:
-                               break;
-               }
+               default:
+                       break;
        }
 
        operationdetail .get_last_child() .set_status( succes ? STATUS_SUCCES : STATUS_ERROR ) ;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]