[partition] reduce warnings with unsafe-option
- Move variables closer to where they are needed - Do the winnowing / selection always, but in unsafe mode return the un-winnowed list of devices - Massage build documentation a little
This commit is contained in:
parent
7a26143fbc
commit
4912de5893
@ -8,8 +8,9 @@
|
|||||||
# want to allow unsafe partitioning choices (e.g. doing things to the
|
# want to allow unsafe partitioning choices (e.g. doing things to the
|
||||||
# current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off
|
# current disk). Set DEBUG_PARTITION_UNSAFE to allow that (it turns off
|
||||||
# some filtering of devices). If you **do** allow unsafe partitioning,
|
# some filtering of devices). If you **do** allow unsafe partitioning,
|
||||||
# it will error out unless you **also** switch **off** DEBUG_PARTITION_LAME,
|
# it will error out at runtime unless you **also** switch **off**
|
||||||
# at which point you are welcome to shoot yourself in the foot.
|
# DEBUG_PARTITION_LAME, at which point you are welcome to shoot
|
||||||
|
# yourself in the foot.
|
||||||
option( DEBUG_PARTITION_UNSAFE "Allow unsafe partitioning choices." OFF )
|
option( DEBUG_PARTITION_UNSAFE "Allow unsafe partitioning choices." OFF )
|
||||||
option( DEBUG_PARTITION_LAME "Unsafe partitioning will error out on exec." ON )
|
option( DEBUG_PARTITION_LAME "Unsafe partitioning will error out on exec." ON )
|
||||||
|
|
||||||
|
@ -118,8 +118,6 @@ erase( DeviceList& l, DeviceList::iterator& it )
|
|||||||
QList< Device* >
|
QList< Device* >
|
||||||
getDevices( DeviceType which )
|
getDevices( DeviceType which )
|
||||||
{
|
{
|
||||||
bool writableOnly = ( which == DeviceType::WritableOnly );
|
|
||||||
|
|
||||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||||
#if defined( WITH_KPMCORE4API )
|
#if defined( WITH_KPMCORE4API )
|
||||||
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
|
DeviceList devices = backend->scanDevices( /* not includeReadOnly, not includeLoopback */ ScanFlag( 0 ) );
|
||||||
@ -129,14 +127,18 @@ getDevices( DeviceType which )
|
|||||||
|
|
||||||
#ifdef DEBUG_PARTITION_UNSAFE
|
#ifdef DEBUG_PARTITION_UNSAFE
|
||||||
cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates.";
|
cWarning() << "Allowing unsafe partitioning choices." << devices.count() << "candidates.";
|
||||||
|
DeviceList unsafeDevices = devices;
|
||||||
#ifdef DEBUG_PARTITION_LAME
|
#ifdef DEBUG_PARTITION_LAME
|
||||||
cDebug() << Logger::SubEntry << "it has been lamed, and will fail.";
|
cDebug() << Logger::SubEntry << "it has been lamed, and will fail.";
|
||||||
#endif
|
#endif
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
cDebug() << "Removing unsuitable devices:" << devices.count() << "candidates.";
|
cDebug() << "Removing unsuitable devices:" << devices.count() << "candidates.";
|
||||||
|
|
||||||
|
bool writableOnly = ( which == DeviceType::WritableOnly );
|
||||||
// Remove the device which contains / from the list
|
// Remove the device which contains / from the list
|
||||||
for ( DeviceList::iterator it = devices.begin(); it != devices.end(); )
|
for ( DeviceList::iterator it = devices.begin(); it != devices.end(); )
|
||||||
|
{
|
||||||
if ( !( *it ) )
|
if ( !( *it ) )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::SubEntry << "Skipping nullptr device";
|
cDebug() << Logger::SubEntry << "Skipping nullptr device";
|
||||||
@ -166,9 +168,13 @@ getDevices( DeviceType which )
|
|||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
cDebug() << Logger::SubEntry << "there are" << devices.count() << "devices left.";
|
||||||
|
#ifdef DEBUG_PARTITION_UNSAFE
|
||||||
|
return unsafeDevices;
|
||||||
|
#else
|
||||||
return devices;
|
return devices;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace PartUtils
|
} // namespace PartUtils
|
||||||
|
Loading…
Reference in New Issue
Block a user