src/imports/devices.cpp
src/solid/devices/backends/fakehw/*
src/solid/devices/backends/fstab/*
Details
- Reviewers
dfaure apol meven - Group Reviewers
Frameworks - Commits
- R245:b9abef40855e: [Solid] Replace foreach (deprecated) with range/index for
make && ctest
Diff Detail
- Repository
- R245 Solid
- Branch
- l-foreach (branched from master)
- Lint
No Linters Available - Unit
No Unit Test Coverage - Build Status
Buildable 25846 Build 25864: arc lint + arc unit
src/solid/devices/backends/fakehw/fakecdrom.cpp | ||
---|---|---|
48 | The obviously better solution is to iterate over supported_medialist and swap the key and value of the map. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
38 | dito |
We still have a few of those in solid :
$ rg ".keys\(\)" src/tools/solid-hardware/solid-hardware.cpp 151: Q_FOREACH (const QString &key, properties.keys()) src/solid/devices/backends/udisks2/udisksdevicebackend.cpp 220: Q_FOREACH (const QString &iface, interfaces_and_properties.keys()) { src/solid/devices/backends/fstab/fstabhandling.cpp 219: QStringList devices = globalFstabCache->localData().m_mtabCache.keys(); src/solid/devices/backends/udisks2/udisksmanager.cpp 179: qCDebug(UDISKS2) << udi << "has new interfaces:" << interfaces_and_properties.keys(); 201: else if (m_deviceCache.contains(udi) && interfaces_and_properties.keys().contains(UD2_DBUS_INTERFACE_FILESYSTEM)) { src/solid/devices/backends/iokit/iokitstorageaccess.cpp 89: Q_FOREACH (const QString &property, changes.keys()) { src/solid/devices/backends/iokit/iokitopticaldrive.cpp 284: foreach (const Solid::OpticalDrive::MediumType type, d->cdTypeMap.keys()) { 289: foreach (const Solid::OpticalDrive::MediumType type, d->dvdTypeMap.keys()) { 294: foreach (const Solid::OpticalDrive::MediumType type, d->bdTypeMap.keys()) { src/solid/devices/backends/hal/halopticaldisc.cpp 34: Q_FOREACH (const Solid::OpticalDisc::ContentType type, map.keys()) { src/solid/devices/backends/fakehw/fakeopticaldisc.cpp 38: Q_FOREACH (const Solid::OpticalDisc::ContentType type, map.keys()) { src/solid/devices/backends/fakehw/fakestorageaccess.cpp 60: Q_FOREACH (const QString &property, changes.keys()) { src/solid/devices/backends/hal/halcdrom.cpp 55: Q_FOREACH (const Solid::OpticalDrive::MediumType type, map.keys()) { src/solid/devices/backends/fakehw/fakecdrom.cpp 48: Q_FOREACH (const Solid::OpticalDrive::MediumType type, map.keys()) { src/solid/devices/backends/udisks2/udisksopticaldrive.cpp 63: Q_FOREACH (const QDBusObjectPath &objPath, reply.value().keys()) { 208: Q_FOREACH (const Solid::OpticalDrive::MediumType &type, map.keys()) {
src/solid/devices/backends/fakehw/fakemanager.cpp | ||
---|---|---|
135 | I guess you can const the FakeDevice | |
147 | I guess you can const the FakeDevice |
I know. "foreach" marks the place :)
src/solid/devices/backends/fakehw/fakecdrom.cpp | ||
---|---|---|
48 | Good point. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | These four lines can be written as |
Make the code much shorter with map.value(key, defaultvalue), since the ContentType enum has a NoContent member
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | Nice. :) I think Solid::OpticalDisc::NoContent is more readable. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | You forgot to remove the old lines. Can also be applied to supportedMedia |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | /* brown paper bag */, removed the lines. I don't see a default a-la-NoContent MediumType member. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | Just use 0. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | It doesn't make the code more readable; and using QMap::constFind() while iterating is more recognizable/widely-used. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | You are contradicting yourself. You use value() for content, but for supportedMedia it is a bad idea? Also, supportedMedia |= 0 is obviously a noop, while for any named flag one has to lookup the flag value. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | I was talking about something like Solid::OpticalDrive::MediumType(0); ContentType has Solid::OpticalDisc::NoContent whereas MediumType has nothing similar. IIUC named casts are preferred over old style casts, so I suggest either we add a MediumType enumerator e.g. NotSupported = 0x00000 or use a static_cast. |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | Thats not a cast but a constructor, see QFlags documentation |
src/solid/devices/backends/fakehw/fakeopticaldisc.cpp | ||
---|---|---|
43 ↗ | (On Diff #81098) | From opticaldrive.h: AFAIU, MediumTypes is the QFlags, MediumType is the enum. So Solid::OpticalDrive::MediumType(0) is the enum not the QFlags. I'll land this and create a separate diff to add an enumerator UnknownMediumType to the MediumType enum, then use it in the for loop. |