Skip to content

Commit 4e7931f

Browse files
committed
Simplify code by using guard clauses
1 parent f107ae1 commit 4e7931f

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/Partitioning.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,19 @@ bool Partitioning::createAndFormatPartitions(BlockDeviceType * blockDevice, std:
8282
bool Partitioning::partitionDrive(BlockDeviceType * blockDevice, std::vector<Partition> partitions){
8383
blockDevice -> init();
8484

85-
if(isPartitionSchemeValid(blockDevice, partitions)){
86-
if(eraseMBRSector(blockDevice)){
87-
if(createAndFormatPartitions(blockDevice, partitions)){
88-
return true;
89-
} else {
90-
return false;
91-
}
92-
} else {
93-
return false;
94-
}
95-
} else {
85+
if(!isPartitionSchemeValid(blockDevice, partitions)){
9686
return false;
9787
}
88+
89+
if(!eraseMBRSector(blockDevice)){
90+
return false;
91+
}
92+
93+
if(!createAndFormatPartitions(blockDevice, partitions)){
94+
return false;
95+
}
96+
97+
return true;
9898
}
9999

100100
std::vector<Partition> Partitioning::readPartitions(BlockDeviceType * blockDevice){

0 commit comments

Comments
 (0)