[partition] Massage coding style

- some long-missing (unrelated to recent PR) braces
- remove some redundant comments
This commit is contained in:
Adriaan de Groot 2022-05-24 12:57:10 +02:00
parent 6de880c95d
commit fd53c090f4

View File

@ -34,11 +34,15 @@ Partition*
findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint )
{ {
for ( auto device : devices ) for ( auto device : devices )
{
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
if ( PartitionInfo::mountPoint( *it ) == mountPoint ) if ( PartitionInfo::mountPoint( *it ) == mountPoint )
{ {
return *it; return *it;
} }
}
}
return nullptr; return nullptr;
} }
@ -171,7 +175,6 @@ testPassphrase( FS::luks* fs, const QString& deviceNode, const QString& passphra
SavePassphraseValue SavePassphraseValue
savePassphrase( Partition* partition, const QString& passphrase ) savePassphrase( Partition* partition, const QString& passphrase )
{ {
const QString deviceNode = partition->partitionPath();
if ( passphrase.isEmpty() ) if ( passphrase.isEmpty() )
{ {
@ -183,8 +186,8 @@ savePassphrase( Partition* partition, const QString& passphrase )
return SavePassphraseValue::NotLuksPartition; return SavePassphraseValue::NotLuksPartition;
} }
// Cast partition fs to luks fs
FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() ); FS::luks* luksFs = dynamic_cast< FS::luks* >( &partition->fileSystem() );
const QString deviceNode = partition->partitionPath();
// Test the given passphrase // Test the given passphrase
if ( !testPassphrase( luksFs, deviceNode, passphrase ) ) if ( !testPassphrase( luksFs, deviceNode, passphrase ) )
@ -207,7 +210,6 @@ savePassphrase( Partition* partition, const QString& passphrase )
ExternalCommand openCmd( QStringLiteral( "cryptsetup" ), ExternalCommand openCmd( QStringLiteral( "cryptsetup" ),
{ QStringLiteral( "open" ), deviceNode, luksFs->suggestedMapperName( deviceNode ) } ); { QStringLiteral( "open" ), deviceNode, luksFs->suggestedMapperName( deviceNode ) } );
if ( !( openCmd.write( passphrase.toLocal8Bit() + '\n' ) && openCmd.start( -1 ) && openCmd.exitCode() == 0 ) ) if ( !( openCmd.write( passphrase.toLocal8Bit() + '\n' ) && openCmd.start( -1 ) && openCmd.exitCode() == 0 ) )
{ {
cWarning() << Logger::SubEntry << openCmd.exitCode() << ": cryptsetup command failed"; cWarning() << Logger::SubEntry << openCmd.exitCode() << ": cryptsetup command failed";
@ -216,9 +218,7 @@ savePassphrase( Partition* partition, const QString& passphrase )
// Save the existing passphrase // Save the existing passphrase
luksFs->setPassphrase( passphrase ); luksFs->setPassphrase( passphrase );
luksFs->scan( deviceNode ); luksFs->scan( deviceNode );
if ( luksFs->mapperName().isEmpty() ) if ( luksFs->mapperName().isEmpty() )
{ {
return SavePassphraseValue::NoMapperNode; return SavePassphraseValue::NoMapperNode;
@ -226,7 +226,6 @@ savePassphrase( Partition* partition, const QString& passphrase )
luksFs->loadInnerFileSystem( luksFs->mapperName() ); luksFs->loadInnerFileSystem( luksFs->mapperName() );
luksFs->setCryptOpen( luksFs->innerFS() != nullptr ); luksFs->setCryptOpen( luksFs->innerFS() != nullptr );
if ( !luksFs->isCryptOpen() ) if ( !luksFs->isCryptOpen() )
{ {
return SavePassphraseValue::DeviceNotDecrypted; return SavePassphraseValue::DeviceNotDecrypted;