[partition] Avoid uninitialized variable
- if the partition size is invalid, then warn about it but do not print the (uninitialized) size of the partition. - shuffle code to continue earlier, allowing the "good path" code to be out-dented.
This commit is contained in:
parent
687a795b71
commit
9910b23152
@ -172,32 +172,30 @@ PartitionLayout::execute( Device* dev,
|
|||||||
// Let's check if we have enough space for each partSize
|
// Let's check if we have enough space for each partSize
|
||||||
for ( const auto& part : qAsConst( m_partLayout ) )
|
for ( const auto& part : qAsConst( m_partLayout ) )
|
||||||
{
|
{
|
||||||
qint64 size;
|
if ( !part.partSize.isValid() )
|
||||||
// Calculate partition size
|
|
||||||
|
|
||||||
if ( part.partSize.isValid() )
|
|
||||||
{
|
{
|
||||||
// We need to ignore the percent-defined
|
cWarning() << "Partition" << part.partMountPoint << "size is invalid, skipping...";
|
||||||
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent )
|
continue;
|
||||||
{
|
}
|
||||||
size = part.partSize.toSectors( totalSize, dev->logicalSize() );
|
|
||||||
}
|
// Calculate partition size: Rely on "possibly uninitialized use"
|
||||||
else
|
// warnings to ensure that all the cases are covered below.
|
||||||
{
|
qint64 size;
|
||||||
if ( part.partMinSize.isValid() )
|
// We need to ignore the percent-defined until later
|
||||||
{
|
if ( part.partSize.unit() != CalamaresUtils::Partition::SizeUnit::Percent )
|
||||||
size = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
{
|
||||||
}
|
size = part.partSize.toSectors( totalSize, dev->logicalSize() );
|
||||||
else
|
|
||||||
{
|
|
||||||
size = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cWarning() << "Partition" << part.partMountPoint << "size (" << size << "sectors) is invalid, skipping...";
|
if ( part.partMinSize.isValid() )
|
||||||
continue;
|
{
|
||||||
|
size = part.partMinSize.toSectors( totalSize, dev->logicalSize() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partSizeMap.insert( &part, size );
|
partSizeMap.insert( &part, size );
|
||||||
|
Loading…
Reference in New Issue
Block a user