diff --git a/src/core/fstab.cpp b/src/core/fstab.cpp index 4cf9ee4..6bdc7f2 100644 --- a/src/core/fstab.cpp +++ b/src/core/fstab.cpp @@ -31,7 +31,7 @@ #include #include -static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QString& m_deviceNode); +static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode); static QString findBlkIdDevice(const char *token, const QString& value); struct FstabEntryPrivate @@ -44,7 +44,7 @@ struct FstabEntryPrivate int m_dumpFreq; int m_passNumber; QString m_comment; - FstabEntryType m_entryType; + FstabEntry::Type m_entryType; }; FstabEntry::FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq, int passNumber, const QString& comment) : @@ -103,7 +103,7 @@ FstabEntryList readFstabEntries( const QString& fstabPath ) } fstabFile.close(); - if (fstabEntries.back().entryType() == comment && fstabEntries.back().comment().isEmpty()) + if (fstabEntries.back().entryType() == FstabEntry::Type::comment && fstabEntries.back().comment().isEmpty()) fstabEntries.pop_back(); } @@ -156,7 +156,7 @@ const QString& FstabEntry::comment() const return d->m_comment; } -FstabEntryType FstabEntry::entryType() const +FstabEntry::Type FstabEntry::entryType() const { return d->m_entryType; } @@ -207,23 +207,23 @@ static QString findBlkIdDevice(const char *token, const QString& value) return rval; } -static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QString& m_deviceNode) +static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode) { - m_entryType = FstabEntryType::comment; + m_entryType = FstabEntry::Type::comment; if (m_fsSpec.startsWith(QStringLiteral("UUID="))) { - m_entryType = FstabEntryType::uuid; + m_entryType = FstabEntry::Type::uuid; m_deviceNode = findBlkIdDevice("UUID", QString(m_fsSpec).remove(QStringLiteral("UUID="))); } else if (m_fsSpec.startsWith(QStringLiteral("LABEL="))) { - m_entryType = FstabEntryType::label; + m_entryType = FstabEntry::Type::label; m_deviceNode = findBlkIdDevice("LABEL", QString(m_fsSpec).remove(QStringLiteral("LABEL="))); } else if (m_fsSpec.startsWith(QStringLiteral("PARTUUID="))) { - m_entryType = FstabEntryType::uuid; + m_entryType = FstabEntry::Type::uuid; m_deviceNode = findBlkIdDevice("PARTUUID", QString(m_fsSpec).remove(QStringLiteral("PARTUUID="))); } else if (m_fsSpec.startsWith(QStringLiteral("PARTLABEL="))) { - m_entryType = FstabEntryType::label; + m_entryType = FstabEntry::Type::label; m_deviceNode = findBlkIdDevice("PARTLABEL", QString(m_fsSpec).remove(QStringLiteral("PARTLABEL="))); } else if (m_fsSpec.startsWith(QStringLiteral("/"))) { - m_entryType = FstabEntryType::deviceNode; + m_entryType = FstabEntry::Type::deviceNode; m_deviceNode = m_fsSpec; } } @@ -231,7 +231,7 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QS static void writeEntry(QFile& output, const FstabEntry& entry) { QTextStream s(&output); - if (entry.entryType() == FstabEntryType::comment) { + if (entry.entryType() == FstabEntry::Type::comment) { s << entry.comment() << "\n"; return; } diff --git a/src/core/fstab.h b/src/core/fstab.h index ca3c8b6..d158813 100644 --- a/src/core/fstab.h +++ b/src/core/fstab.h @@ -27,8 +27,6 @@ struct FstabEntryPrivate; -enum FstabEntryType { deviceNode, uuid, label, partlabel, partuuid, comment }; - /** Base class for fstab handling. FstabEntry stores a single line of /etc/fstab file which can be a comment @@ -39,6 +37,8 @@ enum FstabEntryType { deviceNode, uuid, label, partlabel, partuuid, comment }; class LIBKPMCORE_EXPORT FstabEntry { public: + enum class Type { deviceNode, uuid, label, partlabel, partuuid, comment }; + FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq = 0, int passNumber = 0, const QString& comment = QString()); /** @@ -84,7 +84,7 @@ public: /** * @return the type of fstab entry, e.g. device node or UUID or comment only */ - FstabEntryType entryType() const; + Type entryType() const; /** * @param s the new value for the fs_spec field of fstab entry diff --git a/src/core/partitionalignment.cpp b/src/core/partitionalignment.cpp index e38c569..d32da6d 100644 --- a/src/core/partitionalignment.cpp +++ b/src/core/partitionalignment.cpp @@ -85,10 +85,10 @@ bool PartitionAlignment::isAligned(const Device& d, const Partition& p, bool qui bool PartitionAlignment::isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet) { if (firstDelta(d, p, newFirst) && !quiet) - Log(Log::warning) << xi18nc("@info:status", "Partition %1 is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst)); + Log(Log::Level::warning) << xi18nc("@info:status", "Partition %1 is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst)); if (lastDelta(d, p, newLast) && !quiet) - Log(Log::warning) << xi18nc("@info:status", "Partition %1 is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast)); + Log(Log::Level::warning) << xi18nc("@info:status", "Partition %1 is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast)); return firstDelta(d, p, newFirst) == 0 && lastDelta(d, p, newLast) == 0; } diff --git a/src/core/smartattribute.cpp b/src/core/smartattribute.cpp index 6e29056..f27bb07 100644 --- a/src/core/smartattribute.cpp +++ b/src/core/smartattribute.cpp @@ -35,8 +35,8 @@ SmartAttribute::SmartAttribute(const SmartAttributeParsedData& a) : m_Id(a.id()), m_Name(getAttrName(a.id())), m_Desc(getAttrDescription(a.id())), - m_FailureType(a.prefailure() ? PreFailure : OldAge), - m_UpdateType(a.online() ? Online : Offline), + m_FailureType(a.prefailure() ? FailureType::PreFailure : FailureType::OldAge), + m_UpdateType(a.online() ? UpdateType::Online : UpdateType::Offline), m_Current(a.currentValueValid() ? a.currentValue() : -1), m_Worst(a.worstValueValid() ? a.worstValue() : -1), m_Threshold(a.thresholdValid() ? a.threshold() : -1), @@ -50,19 +50,19 @@ SmartAttribute::SmartAttribute(const SmartAttributeParsedData& a) : QString SmartAttribute::assessmentToString(Assessment a) { switch (a) { - case Failing: + case Assessment::Failing: return xi18nc("@item:intable", "failing"); - case HasFailed: + case Assessment::HasFailed: return xi18nc("@item:intable", "has failed"); - case Warning: + case Assessment::Warning: return xi18nc("@item:intable", "warning"); - case Good: + case Assessment::Good: return xi18nc("@item:intable", "good"); - case NotApplicable: + case Assessment::NotApplicable: default: return xi18nc("@item:intable not applicable", "N/A"); } @@ -216,7 +216,7 @@ static QString getAttrDescription(qint32 id) static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData& a) { - SmartAttribute::Assessment rval = SmartAttribute::NotApplicable; + SmartAttribute::Assessment rval = SmartAttribute::Assessment::NotApplicable; bool failed = false; bool hasFailed = false; @@ -235,13 +235,13 @@ static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData& } if (failed) - rval = SmartAttribute::Failing; + rval = SmartAttribute::Assessment::Failing; else if (hasFailed) - rval = SmartAttribute::HasFailed; + rval = SmartAttribute::Assessment::HasFailed; else if (a.warn()) - rval = SmartAttribute::Warning; + rval = SmartAttribute::Assessment::Warning; else if (a.goodNowValid()) - rval = SmartAttribute::Good; + rval = SmartAttribute::Assessment::Good; return rval; } diff --git a/src/core/smartattribute.h b/src/core/smartattribute.h index 08687d1..2df9ae9 100644 --- a/src/core/smartattribute.h +++ b/src/core/smartattribute.h @@ -27,17 +27,17 @@ class SmartAttributeParsedData; class LIBKPMCORE_EXPORT SmartAttribute { public: - enum FailureType { + enum class FailureType { PreFailure, OldAge }; - enum UpdateType { + enum class UpdateType { Online, Offline }; - enum Assessment { + enum class Assessment { NotApplicable, Failing, HasFailed, diff --git a/src/core/smartdiskinformation.cpp b/src/core/smartdiskinformation.cpp index fc46d21..cc18c7c 100644 --- a/src/core/smartdiskinformation.cpp +++ b/src/core/smartdiskinformation.cpp @@ -34,7 +34,7 @@ SmartDiskInformation::SmartDiskInformation() : m_BadAttributeNow(false), m_BadAttributeInThePast(false), m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER), - m_Overall(SmartDiskInformation::SMART_OVERALL_BAD_STATUS) + m_Overall(SmartDiskInformation::Overall::BadStatus) { } @@ -62,36 +62,35 @@ void SmartDiskInformation::updateBadSectors() void SmartDiskInformation::updateOverall() { if (!smartStatus()) { - m_Overall = SMART_OVERALL_BAD_STATUS; + m_Overall = Overall::BadStatus; return; } quint64 sector_threshold = u64log2(size() / 512) * 1024; if (badSectors() >= sector_threshold) { - m_Overall = SMART_OVERALL_BAD_SECTOR_MANY; + m_Overall = Overall::BadSectorsMany; return; } validateBadAttributes(); if (m_BadAttributeNow) { - m_Overall = SMART_OVERALL_BAD_ATTRIBUTE_NOW; + m_Overall = Overall::BadAttributeNow; return; } if (badSectors() > 0) { - m_Overall = SMART_OVERALL_BAD_SECTOR; + m_Overall = Overall::BadSector; return; } if (m_BadAttributeInThePast) { - m_Overall = SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST; + m_Overall = Overall::BadAttributeInThePast; return; } - m_Overall = SMART_OVERALL_GOOD; - + m_Overall = Overall::Good; } /** Update the temperature value based on SMART attributes diff --git a/src/core/smartdiskinformation.h b/src/core/smartdiskinformation.h index 996c2fc..4c55f41 100644 --- a/src/core/smartdiskinformation.h +++ b/src/core/smartdiskinformation.h @@ -48,14 +48,13 @@ public: }; /** SMART overall state */ - enum SmartOverall { - SMART_OVERALL_GOOD, - SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST, - SMART_OVERALL_BAD_SECTOR, - SMART_OVERALL_BAD_ATTRIBUTE_NOW, - SMART_OVERALL_BAD_SECTOR_MANY, - SMART_OVERALL_BAD_STATUS, - _SMART_OVERALL_MAX + enum class Overall { + Good, + BadAttributeInThePast, + BadSector, + BadAttributeNow, + BadSectorsMany, + BadStatus, }; public: @@ -105,7 +104,7 @@ public: return m_SelfTestExecutionStatus; /**< @return SMART self execution status */ } - SmartOverall overall() const + Overall overall() const { return m_Overall; /**< @return SMART overall status */ } @@ -192,7 +191,7 @@ private: bool m_BadAttributeNow; bool m_BadAttributeInThePast; SmartSelfTestExecutionStatus m_SelfTestExecutionStatus; - SmartOverall m_Overall; + Overall m_Overall; QList m_Attributes; }; diff --git a/src/core/smartstatus.cpp b/src/core/smartstatus.cpp index 3c8a35a..855d99a 100644 --- a/src/core/smartstatus.cpp +++ b/src/core/smartstatus.cpp @@ -37,8 +37,8 @@ SmartStatus::SmartStatus(const QString &device_path) : m_ModelName(), m_Serial(), m_Firmware(), - m_Overall(Bad), - m_SelfTestStatus(Success), + m_Overall(Overall::Bad), + m_SelfTestStatus(SelfTestStatus::Success), m_Temp(0), m_BadSectors(0), m_PowerCycles(0), @@ -73,72 +73,72 @@ void SmartStatus::update() switch (disk->selfTestExecutionStatus()) { case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ABORTED: - setSelfTestStatus(Aborted); + setSelfTestStatus(SelfTestStatus::Aborted); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED: - setSelfTestStatus(Interrupted); + setSelfTestStatus(SelfTestStatus::Interrupted); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_FATAL: - setSelfTestStatus(Fatal); + setSelfTestStatus(SelfTestStatus::Fatal); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN: - setSelfTestStatus(ErrorUnknown); + setSelfTestStatus(SelfTestStatus::ErrorUnknown); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL: - setSelfTestStatus(ErrorEletrical); + setSelfTestStatus(SelfTestStatus::ErrorEletrical); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO: - setSelfTestStatus(ErrorServo); + setSelfTestStatus(SelfTestStatus::ErrorServo); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ: - setSelfTestStatus(ErrorRead); + setSelfTestStatus(SelfTestStatus::ErrorRead); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING: - setSelfTestStatus(ErrorHandling); + setSelfTestStatus(SelfTestStatus::ErrorHandling); break; case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS: - setSelfTestStatus(InProgress); + setSelfTestStatus(SelfTestStatus::InProgress); break; default: case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER: - setSelfTestStatus(Success); + setSelfTestStatus(SelfTestStatus::Success); break; } switch (disk->overall()) { - case SmartDiskInformation::SMART_OVERALL_GOOD: - setOverall(Good); + case SmartDiskInformation::Overall::Good: + setOverall(Overall::Good); break; - case SmartDiskInformation::SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST: - setOverall(BadPast); + case SmartDiskInformation::Overall::BadAttributeInThePast: + setOverall(Overall::BadPast); break; - case SmartDiskInformation::SMART_OVERALL_BAD_SECTOR: - setOverall(BadSectors); + case SmartDiskInformation::Overall::BadSector: + setOverall(Overall::BadSectors); break; - case SmartDiskInformation::SMART_OVERALL_BAD_ATTRIBUTE_NOW: - setOverall(BadNow); + case SmartDiskInformation::Overall::BadAttributeNow: + setOverall(Overall::BadNow); break; - case SmartDiskInformation::SMART_OVERALL_BAD_SECTOR_MANY: - setOverall(BadSectorsMany); + case SmartDiskInformation::Overall::BadSectorsMany: + setOverall(Overall::BadSectorsMany); break; default: - case SmartDiskInformation::SMART_OVERALL_BAD_STATUS: - setOverall(Bad); + case SmartDiskInformation::Overall::BadStatus: + setOverall(Overall::Bad); break; } @@ -167,34 +167,34 @@ QString SmartStatus::tempToString(quint64 mkelvin) QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s) { switch (s) { - case Aborted: + case SelfTestStatus::Aborted: return xi18nc("@item", "Aborted"); - case Interrupted: + case SelfTestStatus::Interrupted: return xi18nc("@item", "Interrupted"); - case Fatal: + case SelfTestStatus::Fatal: return xi18nc("@item", "Fatal error"); - case ErrorUnknown: + case SelfTestStatus::ErrorUnknown: return xi18nc("@item", "Unknown error"); - case ErrorEletrical: + case SelfTestStatus::ErrorEletrical: return xi18nc("@item", "Electrical error"); - case ErrorServo: + case SelfTestStatus::ErrorServo: return xi18nc("@item", "Servo error"); - case ErrorRead: + case SelfTestStatus::ErrorRead: return xi18nc("@item", "Read error"); - case ErrorHandling: + case SelfTestStatus::ErrorHandling: return xi18nc("@item", "Handling error"); - case InProgress: + case SelfTestStatus::InProgress: return xi18nc("@item", "Self test in progress"); - case Success: + case SelfTestStatus::Success: default: return xi18nc("@item", "Success"); } @@ -204,22 +204,22 @@ QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s) QString SmartStatus::overallAssessmentToString(Overall o) { switch (o) { - case Good: + case Overall::Good: return xi18nc("@item", "Healthy"); - case BadPast: + case Overall::BadPast: return xi18nc("@item", "Has been used outside of its design parameters in the past."); - case BadSectors: + case Overall::BadSectors: return xi18nc("@item", "Has some bad sectors."); - case BadNow: + case Overall::BadNow: return xi18nc("@item", "Is being used outside of its design parameters right now."); - case BadSectorsMany: + case Overall::BadSectorsMany: return xi18nc("@item", "Has many bad sectors."); - case Bad: + case Overall::Bad: default: return xi18nc("@item", "Disk failure is imminent. Backup all data!"); } diff --git a/src/core/smartstatus.h b/src/core/smartstatus.h index 88b410d..b54236d 100644 --- a/src/core/smartstatus.h +++ b/src/core/smartstatus.h @@ -31,7 +31,7 @@ struct SkDisk; class LIBKPMCORE_EXPORT SmartStatus { public: - enum Overall { + enum class Overall { Good, BadPast, BadSectors, @@ -40,7 +40,7 @@ public: Bad }; - enum SelfTestStatus { + enum class SelfTestStatus { Success, Aborted, Interrupted, diff --git a/src/fs/btrfs.cpp b/src/fs/btrfs.cpp index 864cf56..c7c1edb 100644 --- a/src/fs/btrfs.cpp +++ b/src/fs/btrfs.cpp @@ -91,12 +91,12 @@ FileSystem::SupportTool btrfs::supportToolName() const qint64 btrfs::minCapacity() const { - return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 256 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 btrfs::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } int btrfs::maxLabelLength() const diff --git a/src/fs/exfat.cpp b/src/fs/exfat.cpp index 46753e8..1971a63 100644 --- a/src/fs/exfat.cpp +++ b/src/fs/exfat.cpp @@ -84,7 +84,7 @@ FileSystem::SupportTool exfat::supportToolName() const qint64 exfat::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } int exfat::maxLabelLength() const diff --git a/src/fs/ext2.cpp b/src/fs/ext2.cpp index a2e82a4..fce9274 100644 --- a/src/fs/ext2.cpp +++ b/src/fs/ext2.cpp @@ -84,7 +84,7 @@ FileSystem::SupportTool ext2::supportToolName() const qint64 ext2::maxCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } int ext2::maxLabelLength() const diff --git a/src/fs/ext3.cpp b/src/fs/ext3.cpp index a33f236..7fa67c9 100644 --- a/src/fs/ext3.cpp +++ b/src/fs/ext3.cpp @@ -31,7 +31,7 @@ ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr qint64 ext3::maxCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } bool ext3::create(Report& report, const QString& deviceNode) diff --git a/src/fs/ext4.cpp b/src/fs/ext4.cpp index 30d38dc..0fa3811 100644 --- a/src/fs/ext4.cpp +++ b/src/fs/ext4.cpp @@ -31,7 +31,7 @@ ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr qint64 ext4::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } bool ext4::create(Report& report, const QString& deviceNode) diff --git a/src/fs/f2fs.cpp b/src/fs/f2fs.cpp index d112dac..f8c62cb 100644 --- a/src/fs/f2fs.cpp +++ b/src/fs/f2fs.cpp @@ -100,12 +100,12 @@ FileSystem::SupportTool f2fs::supportToolName() const qint64 f2fs::minCapacity() const { - return 30 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 30 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 f2fs::maxCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB); } int f2fs::maxLabelLength() const diff --git a/src/fs/fat12.cpp b/src/fs/fat12.cpp index 2bc0d5e..c059899 100644 --- a/src/fs/fat12.cpp +++ b/src/fs/fat12.cpp @@ -87,12 +87,12 @@ FileSystem::SupportTool fat12::supportToolName() const qint64 fat12::minCapacity() const { - return 1 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 1 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 fat12::maxCapacity() const { - return 255 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 255 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } int fat12::maxLabelLength() const diff --git a/src/fs/fat16.cpp b/src/fs/fat16.cpp index 1b6b3fe..2c768b0 100644 --- a/src/fs/fat16.cpp +++ b/src/fs/fat16.cpp @@ -75,12 +75,12 @@ bool fat16::supportToolFound() const qint64 fat16::minCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 fat16::maxCapacity() const { - return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::GiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::GiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } bool fat16::create(Report& report, const QString& deviceNode) diff --git a/src/fs/fat32.cpp b/src/fs/fat32.cpp index 7f6151e..4dfb2dd 100644 --- a/src/fs/fat32.cpp +++ b/src/fs/fat32.cpp @@ -32,12 +32,12 @@ fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QS qint64 fat32::minCapacity() const { - return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 fat32::maxCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } bool fat32::create(Report& report, const QString& deviceNode) diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 0919294..df6eb8c 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -376,13 +376,13 @@ bool FileSystem::updateBootSector(Report& report, const QString& deviceNode) con /** @return the minimum capacity valid for this FileSystem in bytes */ qint64 FileSystem::minCapacity() const { - return 8 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 8 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } /** @return the maximum capacity valid for this FileSystem in bytes */ qint64 FileSystem::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } /** @return the maximum label length valid for this FileSystem */ diff --git a/src/fs/hfs.cpp b/src/fs/hfs.cpp index 98a2d15..15677fc 100644 --- a/src/fs/hfs.cpp +++ b/src/fs/hfs.cpp @@ -73,7 +73,7 @@ FileSystem::SupportTool hfs::supportToolName() const qint64 hfs::maxCapacity() const { - return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); + return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB); } int hfs::maxLabelLength() const diff --git a/src/fs/hfsplus.cpp b/src/fs/hfsplus.cpp index f417ea0..6d17540 100644 --- a/src/fs/hfsplus.cpp +++ b/src/fs/hfsplus.cpp @@ -73,7 +73,7 @@ FileSystem::SupportTool hfsplus::supportToolName() const qint64 hfsplus::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } int hfsplus::maxLabelLength() const diff --git a/src/fs/hpfs.cpp b/src/fs/hpfs.cpp index aa1941e..55c41a1 100644 --- a/src/fs/hpfs.cpp +++ b/src/fs/hpfs.cpp @@ -43,6 +43,6 @@ hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr qint64 hpfs::maxCapacity() const { - return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); + return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB); } } diff --git a/src/fs/jfs.cpp b/src/fs/jfs.cpp index da260a4..cc43573 100644 --- a/src/fs/jfs.cpp +++ b/src/fs/jfs.cpp @@ -79,12 +79,12 @@ FileSystem::SupportTool jfs::supportToolName() const qint64 jfs::minCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 jfs::maxCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB); } int jfs::maxLabelLength() const diff --git a/src/fs/luks.h b/src/fs/luks.h index dfc761f..7dddba1 100644 --- a/src/fs/luks.h +++ b/src/fs/luks.h @@ -17,8 +17,7 @@ * along with this program. If not, see .* *************************************************************************/ -#if !defined(KPMCORE_LUKS_H) - +#ifndef KPMCORE_LUKS_H #define KPMCORE_LUKS_H #include "util/libpartitionmanagerexport.h" @@ -43,7 +42,7 @@ public: luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Luks); ~luks() override; - enum KeyLocation { + enum class KeyLocation { unknown, dmcrypt, keyring @@ -225,7 +224,7 @@ protected: qint64 m_PayloadSize; QString m_outerUuid; - luks::KeyLocation m_KeyLocation = unknown; + luks::KeyLocation m_KeyLocation = KeyLocation::unknown; }; } diff --git a/src/fs/luks2.cpp b/src/fs/luks2.cpp index af2ae34..107f51c 100644 --- a/src/fs/luks2.cpp +++ b/src/fs/luks2.cpp @@ -94,7 +94,7 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength) ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() }); report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition %1.", deviceNode); - if (m_KeyLocation == keyring) { + if (m_KeyLocation == KeyLocation::keyring) { if (m_passphrase.isEmpty()) return false; cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n'); @@ -110,7 +110,7 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength) { QStringLiteral("--size"), QString::number(m_PayloadSize / 512), // FIXME, LUKS2 can have different sector sizes QStringLiteral("resize"), mapperName() }); report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition %1.", deviceNode); - if (m_KeyLocation == keyring) { + if (m_KeyLocation == KeyLocation::keyring) { if (m_passphrase.isEmpty()) return false; cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n'); @@ -126,16 +126,16 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength) luks::KeyLocation luks2::keyLocation() { - m_KeyLocation = unknown; + m_KeyLocation = KeyLocation::unknown; ExternalCommand statusCmd(QStringLiteral("cryptsetup"), { QStringLiteral("status"), mapperName() }); if (statusCmd.run(-1) && statusCmd.exitCode() == 0) { QRegularExpression re(QStringLiteral("key location:\\s+(\\w+)")); QRegularExpressionMatch rem = re.match(statusCmd.output()); if (rem.hasMatch()) { if (rem.captured(1) == QStringLiteral("keyring")) - m_KeyLocation = keyring; + m_KeyLocation = KeyLocation::keyring; else if (rem.captured(1) == QStringLiteral("dm-crypt")) - m_KeyLocation = dmcrypt; + m_KeyLocation = KeyLocation::dmcrypt; } } diff --git a/src/fs/lvm2_pv.cpp b/src/fs/lvm2_pv.cpp index 62791c8..92778e6 100644 --- a/src/fs/lvm2_pv.cpp +++ b/src/fs/lvm2_pv.cpp @@ -99,7 +99,7 @@ FileSystem::SupportTool lvm2_pv::supportToolName() const qint64 lvm2_pv::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } qint64 lvm2_pv::readUsedCapacity(const QString& deviceNode) const diff --git a/src/fs/nilfs2.cpp b/src/fs/nilfs2.cpp index ffb3a69..5fd15a1 100644 --- a/src/fs/nilfs2.cpp +++ b/src/fs/nilfs2.cpp @@ -96,12 +96,12 @@ FileSystem::SupportTool nilfs2::supportToolName() const qint64 nilfs2::minCapacity() const { - return 128 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 128 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 nilfs2::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } int nilfs2::maxLabelLength() const diff --git a/src/fs/ntfs.cpp b/src/fs/ntfs.cpp index 8164f18..8386275 100644 --- a/src/fs/ntfs.cpp +++ b/src/fs/ntfs.cpp @@ -91,12 +91,12 @@ FileSystem::SupportTool ntfs::supportToolName() const qint64 ntfs::minCapacity() const { - return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 ntfs::maxCapacity() const { - return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB); + return 256 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB); } int ntfs::maxLabelLength() const diff --git a/src/fs/ocfs2.cpp b/src/fs/ocfs2.cpp index 040e5b3..1122e64 100644 --- a/src/fs/ocfs2.cpp +++ b/src/fs/ocfs2.cpp @@ -89,12 +89,12 @@ FileSystem::SupportTool ocfs2::supportToolName() const qint64 ocfs2::minCapacity() const { - return 14000 * Capacity::unitFactor(Capacity::Byte, Capacity::KiB); + return 14000 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::KiB); } qint64 ocfs2::maxCapacity() const { - return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::PiB); + return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::PiB); } qint64 ocfs2::readUsedCapacity(const QString& deviceNode) const diff --git a/src/fs/reiser4.cpp b/src/fs/reiser4.cpp index 71d1830..38e1d1e 100644 --- a/src/fs/reiser4.cpp +++ b/src/fs/reiser4.cpp @@ -75,7 +75,7 @@ qint64 reiser4::maxCapacity() const { // looks like it's actually unknown. see // http://en.wikipedia.org/wiki/Comparison_of_file_systems - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } int reiser4::maxLabelLength() const diff --git a/src/fs/reiserfs.cpp b/src/fs/reiserfs.cpp index cb78ecf..ddd3de3 100644 --- a/src/fs/reiserfs.cpp +++ b/src/fs/reiserfs.cpp @@ -85,12 +85,12 @@ FileSystem::SupportTool reiserfs::supportToolName() const qint64 reiserfs::minCapacity() const { - return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 reiserfs::maxCapacity() const { - return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } int reiserfs::maxLabelLength() const diff --git a/src/fs/xfs.cpp b/src/fs/xfs.cpp index e0b3339..25d2ef3 100644 --- a/src/fs/xfs.cpp +++ b/src/fs/xfs.cpp @@ -83,12 +83,12 @@ FileSystem::SupportTool xfs::supportToolName() const qint64 xfs::minCapacity() const { - return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 xfs::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } int xfs::maxLabelLength() const diff --git a/src/fs/zfs.cpp b/src/fs/zfs.cpp index d04de16..a3cb201 100644 --- a/src/fs/zfs.cpp +++ b/src/fs/zfs.cpp @@ -77,12 +77,12 @@ FileSystem::SupportTool zfs::supportToolName() const qint64 zfs::minCapacity() const { - return 64 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB); + return 64 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB); } qint64 zfs::maxCapacity() const { - return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); + return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB); } bool zfs::remove(Report& report, const QString& deviceNode) const diff --git a/src/jobs/resizefilesystemjob.cpp b/src/jobs/resizefilesystemjob.cpp index f27bd70..e308d90 100644 --- a/src/jobs/resizefilesystemjob.cpp +++ b/src/jobs/resizefilesystemjob.cpp @@ -88,7 +88,7 @@ bool ResizeFileSystemJob::run(Report& parent) } case FileSystem::cmdSupportFileSystem: { - const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Byte); + const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Unit::Byte); if (partition().isMounted()) rval = partition().fileSystem().resizeOnline(*report, partition().deviceNode(), partition().mountPoint(), newLengthInByte); else diff --git a/src/jobs/resizevolumegroupjob.cpp b/src/jobs/resizevolumegroupjob.cpp index ae7f37d..3dce190 100644 --- a/src/jobs/resizevolumegroupjob.cpp +++ b/src/jobs/resizevolumegroupjob.cpp @@ -43,9 +43,9 @@ bool ResizeVolumeGroupJob::run(Report& parent) for (const auto &p : partList()) { const QString deviceNode = p->roles().has(PartitionRole::Luks) ? static_cast(&p->fileSystem())->mapperName() : p->partitionPath(); - if (type() == ResizeVolumeGroupJob::Grow) + if (type() == ResizeVolumeGroupJob::Type::Grow) rval = LvmDevice::insertPV(*report, device(), deviceNode); - else if (type() == ResizeVolumeGroupJob::Shrink) + else if (type() == ResizeVolumeGroupJob::Type::Shrink) rval = LvmDevice::removePV(*report, device(), deviceNode); if (rval == false) @@ -66,10 +66,10 @@ QString ResizeVolumeGroupJob::description() const partitionList.chop(2); const qint32 count = partList().count(); - if (type() == ResizeVolumeGroupJob::Grow) { + if (type() == ResizeVolumeGroupJob::Type::Grow) { return xi18ncp("@info/plain", "Adding LVM Physical Volume %2 to %3.", "Adding LVM Physical Volumes %2 to %3.", count, partitionList, device().name()); } - if (type() == ResizeVolumeGroupJob::Shrink) { + if (type() == ResizeVolumeGroupJob::Type::Shrink) { return xi18ncp("@info/plain", "Removing LVM Physical Volume %2 from %3.", "Removing LVM Physical Volumes %2 from %3.", count, partitionList, device().name()); } return xi18nc("@info/plain", "Resizing Volume Group %1 to %2.", device().name(), partitionList); diff --git a/src/jobs/resizevolumegroupjob.h b/src/jobs/resizevolumegroupjob.h index ca5f2de..adb2a1d 100644 --- a/src/jobs/resizevolumegroupjob.h +++ b/src/jobs/resizevolumegroupjob.h @@ -31,9 +31,9 @@ class ResizeVolumeGroupJob : public Job { public: - enum Type { - Grow = 0, - Shrink = 1 + enum class Type { + Grow, + Shrink }; public: diff --git a/src/ops/deleteoperation.cpp b/src/ops/deleteoperation.cpp index 8a9bf59..b0cea05 100644 --- a/src/ops/deleteoperation.cpp +++ b/src/ops/deleteoperation.cpp @@ -45,13 +45,13 @@ DeleteOperation::DeleteOperation(Device& d, Partition* p, ShredAction shred) : m_DeletePartitionJob(new DeletePartitionJob(targetDevice(), deletedPartition())) { switch (shredAction()) { - case NoShred: + case ShredAction::NoShred: m_DeleteFileSystemJob = static_cast(new DeleteFileSystemJob(targetDevice(), deletedPartition())); break; - case ZeroShred: + case ShredAction::ZeroShred: m_DeleteFileSystemJob = static_cast(new ShredFileSystemJob(targetDevice(), deletedPartition(), false)); break; - case RandomShred: + case ShredAction::RandomShred: m_DeleteFileSystemJob = static_cast(new ShredFileSystemJob(targetDevice(), deletedPartition(), true)); } @@ -89,7 +89,7 @@ void DeleteOperation::undo() QString DeleteOperation::description() const { - if (shredAction() != NoShred) + if (shredAction() != ShredAction::NoShred) return xi18nc("@info:status", "Shred partition %1 (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name()); else return xi18nc("@info:status", "Delete partition %1 (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name()); diff --git a/src/ops/deleteoperation.h b/src/ops/deleteoperation.h index 0796840..682abd2 100644 --- a/src/ops/deleteoperation.h +++ b/src/ops/deleteoperation.h @@ -43,18 +43,18 @@ class LIBKPMCORE_EXPORT DeleteOperation : public Operation Q_DISABLE_COPY(DeleteOperation) public: - enum ShredAction { - NoShred = 0, + enum class ShredAction { + NoShred, ZeroShred, RandomShred }; - DeleteOperation(Device& d, Partition* p, ShredAction shred = NoShred); + DeleteOperation(Device& d, Partition* p, ShredAction shred = ShredAction::NoShred); ~DeleteOperation(); public: QString iconName() const override { - return shredAction() == NoShred ? + return shredAction() == ShredAction::NoShred ? QStringLiteral("edit-delete") : QStringLiteral("edit-delete-shred"); } diff --git a/src/ops/resizevolumegroupoperation.cpp b/src/ops/resizevolumegroupoperation.cpp index d253746..6996899 100644 --- a/src/ops/resizevolumegroupoperation.cpp +++ b/src/ops/resizevolumegroupoperation.cpp @@ -89,12 +89,12 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QVect // *DO NOTHING* } else { if (!toInsertList.isEmpty()) { - m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Grow); + m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Type::Grow); addJob(growVolumeGroupJob()); } if (!toRemoveList.isEmpty()) { m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(d, toRemoveList); - m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Shrink); + m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Type::Shrink); addJob(movePhysicalVolumeJob()); addJob(shrinkvolumegroupjob()); } diff --git a/src/plugins/sfdisk/sfdiskbackend.cpp b/src/plugins/sfdisk/sfdiskbackend.cpp index 0858a75..5d9648d 100644 --- a/src/plugins/sfdisk/sfdiskbackend.cpp +++ b/src/plugins/sfdisk/sfdiskbackend.cpp @@ -135,7 +135,7 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode) modelName = modelName.left(modelName.length() - 1); qint64 deviceSize = sizeCommand.output().trimmed().toLongLong(); - Log(Log::information) << xi18nc("@info:status", "Device found: %1", modelName); + Log(Log::Level::information) << xi18nc("@info:status", "Device found: %1", modelName); int logicalSectorSize = sizeCommand2.output().trimmed().toLongLong(); DiskDevice* d = new DiskDevice(modelName, deviceNode, 255, 63, deviceSize / logicalSectorSize / 255 / 63, logicalSectorSize); diff --git a/src/util/capacity.cpp b/src/util/capacity.cpp index 9e8d6fa..8edde69 100644 --- a/src/util/capacity.cpp +++ b/src/util/capacity.cpp @@ -44,9 +44,9 @@ Capacity::Capacity(const Partition& p, Type t) : m_Size(-1) { switch (t) { - case Used: m_Size = p.used(); break; - case Available: m_Size = p.available(); break; - case Total: m_Size = p.capacity(); + case Type::Used: m_Size = p.used(); break; + case Type::Available: m_Size = p.available(); break; + case Type::Total: m_Size = p.capacity(); } } @@ -64,7 +64,7 @@ Capacity::Capacity(const Device& d) : */ qint64 Capacity::toInt(Unit u) const { - return static_cast(m_Size / unitFactor(Byte, u)); + return static_cast(m_Size / unitFactor(Unit::Byte, u)); } /** Returns the Capacity as double converted to the given Unit. @@ -73,7 +73,7 @@ qint64 Capacity::toInt(Unit u) const */ double Capacity::toDouble(Unit u) const { - return static_cast(m_Size) / unitFactor(Byte, u); + return static_cast(m_Size) / unitFactor(Unit::Byte, u); } /** Returns a factor to convert between two Units. @@ -86,14 +86,14 @@ qint64 Capacity::unitFactor(Unit from, Unit to) Q_ASSERT(from <= to); if (from > to) { - qWarning() << "from: " << from << ", to: " << to; + qWarning() << "from: " << static_cast(from) << ", to: " << static_cast(to); return 1; } qint64 result = 1; - qint32 a = from; - qint32 b = to; + qint32 a = static_cast(from); + qint32 b = static_cast(to); while (b-- > a) result *= 1024; @@ -122,7 +122,7 @@ QString Capacity::unitName(Unit u, qint64 val) if (static_cast(u) >= sizeof(unitNames) / sizeof(unitNames[0])) return xi18nc("@item:intext unit", "(unknown unit)"); - return unitNames[u]; + return unitNames[static_cast(u)]; } /** Determine if the capacity is valid. diff --git a/src/util/capacity.h b/src/util/capacity.h index 023bcfd..bd11bca 100644 --- a/src/util/capacity.h +++ b/src/util/capacity.h @@ -36,16 +36,16 @@ class LIBKPMCORE_EXPORT Capacity { public: /** Units we can deal with */ - enum Unit { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB }; + enum class Unit : uint { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB }; /** Type of capacity to print */ - enum Type { Used, Available, Total }; + enum class Type { Used, Available, Total }; /** Flags for printing */ enum Flag { NoFlags = 0, AppendUnit = 1, AppendBytes = 2 }; Q_DECLARE_FLAGS(Flags, Flag) public: explicit Capacity(qint64 size); - explicit Capacity(const Partition& p, Type t = Total); + explicit Capacity(const Partition& p, Type t = Type::Total); Capacity(const Device& d); public: diff --git a/src/util/globallog.h b/src/util/globallog.h index 26eef60..3c1bdaf 100644 --- a/src/util/globallog.h +++ b/src/util/globallog.h @@ -28,15 +28,15 @@ class LIBKPMCORE_EXPORT Log { public: - enum Level { - debug = 0, - information = 1, - warning = 2, - error = 3 + enum class Level { + debug, + information, + warning, + error, }; public: - Log(Level lev = information) : ref(1), level(lev) {} + Log(Level lev = Level::information) : ref(1), level(lev) {} ~Log(); Log(const Log& other) : ref(other.ref + 1), level(other.level) {} diff --git a/test/testsmart.cpp b/test/testsmart.cpp index ad8c098..2236af7 100644 --- a/test/testsmart.cpp +++ b/test/testsmart.cpp @@ -74,7 +74,7 @@ static bool testSmartStatus() if (smart.serial() == QString()) return false; - if (smart.selfTestStatus()) + if (smart.selfTestStatus() != SmartStatus::SelfTestStatus::Success) return false; if (!smart.isValid())