Convert some for loops into for ranged based loops.

This commit is contained in:
Andrius Štikonas 2016-08-11 18:57:40 +01:00
parent 40ff0861a8
commit 4de925735e
5 changed files with 16 additions and 13 deletions

View File

@ -155,8 +155,10 @@ bool fat16::updateUUID(Report& report, const QString& deviceNode) const
qint32 t = time(nullptr);
char uuid[4];
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)
uuid[i] = t & 0xff;
for (auto &u : uuid) {
u = t & 0xff;
t >>= 8;
}
ExternalCommand cmd(report, QStringLiteral("dd"), { QStringLiteral("of=") + deviceNode , QStringLiteral("bs=1"), QStringLiteral("count=4"), QStringLiteral("seek=39") });

View File

@ -51,8 +51,10 @@ bool fat32::updateUUID(Report& report, const QString& deviceNode) const
qint32 t = time(nullptr);
char uuid[4];
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)
uuid[i] = t & 0xff;
for (auto &u : uuid) {
u = t & 0xff;
t >>= 8;
}
ExternalCommand cmd(report, QStringLiteral("dd"), { QStringLiteral("of=") + deviceNode, QStringLiteral("bs=1"), QStringLiteral("count=4"), QStringLiteral("seek=67") });

View File

@ -54,7 +54,7 @@ void CreateVolumeGroupOperation::preview()
void CreateVolumeGroupOperation::undo()
{
for(const auto &pvpath : PVList()) {
for (const auto &pvpath : PVList()) {
if (LvmDevice::s_DirtyPVs.contains(pvpath)) {
LvmDevice::s_DirtyPVs.removeAll(pvpath);
}

View File

@ -107,12 +107,12 @@ ActionReply Scan::scandevice(const QVariantMap& args)
// unallocated. Libparted doesn't like it if we ask for flags for unallocated
// space.
if (pedPartition->num > 0)
for (quint32 i = 0; i < sizeof(flagmap) / sizeof(flagmap[0]); i++)
if (ped_partition_is_flag_available(pedPartition, flagmap[i].pedFlag))
for (const auto &flag : flagmap)
if (ped_partition_is_flag_available(pedPartition, flag.pedFlag))
// Workaround: libparted claims the hidden flag is available for extended partitions, but
// throws an error when we try to set or clear it. So skip this combination. Also see setFlag.
if (pedPartition->type != PED_PARTITION_EXTENDED || flagmap[i].flag != PartitionTable::FlagHidden)
flags |= flagmap[i].flag;
if (pedPartition->type != PED_PARTITION_EXTENDED || flag.flag != PartitionTable::FlagHidden)
flags |= flag.flag;
availableFlags.append(static_cast<qint32>(flags));
// --------------------------------------------------------------------------
@ -120,9 +120,9 @@ ActionReply Scan::scandevice(const QVariantMap& args)
flags = PartitionTable::FlagNone;
if (pedPartition->num > 0)
for (quint32 i = 0; i < sizeof(flagmap) / sizeof(flagmap[0]); i++)
if (ped_partition_is_flag_available(pedPartition, flagmap[i].pedFlag) && ped_partition_get_flag(pedPartition, flagmap[i].pedFlag))
flags |= flagmap[i].flag;
for (const auto &flag : flagmap)
if (ped_partition_is_flag_available(pedPartition, flag.pedFlag) && ped_partition_get_flag(pedPartition, flag.pedFlag))
flags |= flag.flag;
activeFlags.append(static_cast<qint32>(flags));
// --------------------------------------------------------------------------

View File

@ -320,7 +320,6 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
QList<Device*> LibPartedBackend::scanDevices(bool excludeReadOnly)
{
QList<Device*> result;
// FIXME: cat /sys/block/loop0/ro
// linux.git/tree/Documentation/devices.txt
QString blockDeviceMajorNumbers = QStringLiteral(
"3,22,33,34,56,57,88,89,90,91,128,129,130,131,132,133,134,135," // MFM, RLL and IDE hard disk/CD-ROM interface