diff --git a/src/backend/corebackend.h b/src/backend/corebackend.h index 4619717..0ddde2e 100644 --- a/src/backend/corebackend.h +++ b/src/backend/corebackend.h @@ -101,7 +101,7 @@ public: /** * Open a device for reading. * @param device_node The path of the device that is to be opened (e.g. /dev/sda) - * @return a pointer to a CoreBackendDevice or NULL if the open failed. If a pointer to + * @return a pointer to a CoreBackendDevice or nullptr if the open failed. If a pointer to * an instance is returned, it's the caller's responsibility to delete the * object. */ @@ -110,7 +110,7 @@ public: /** * Open a device in exclusive mode for writing. * @param device_node The path of the device that is to be opened (e.g. /dev/sda) - * @return a pointer to a CoreBackendDevice or NULL if the open failed. If a pointer to + * @return a pointer to a CoreBackendDevice or nullptr if the open failed. If a pointer to * an instance is returned, it's the caller's responsibility to delete the * object. */ @@ -118,7 +118,7 @@ public: /** * Close a CoreBackendDevice that has previously been opened. - * @param core_device Pointer to the CoreBackendDevice to be closed. Must not be NULL. + * @param core_device Pointer to the CoreBackendDevice to be closed. Must not be nullptr. * @return true if closing the CoreBackendDevice succeeded, otherwise false. * * This method does not delete the object. diff --git a/src/backend/corebackenddevice.h b/src/backend/corebackenddevice.h index 97bd035..97ba525 100644 --- a/src/backend/corebackenddevice.h +++ b/src/backend/corebackenddevice.h @@ -76,7 +76,7 @@ public: /** * Open this backend device's partition table - * @return a pointer to the CoreBackendPartitionTable for this device or NULL in case + * @return a pointer to the CoreBackendPartitionTable for this device or nullptr in case * of errors */ virtual CoreBackendPartitionTable* openPartitionTable() = 0; diff --git a/src/backend/corebackendmanager.cpp b/src/backend/corebackendmanager.cpp index 17e82b3..968ce18 100644 --- a/src/backend/corebackendmanager.cpp +++ b/src/backend/corebackendmanager.cpp @@ -28,15 +28,15 @@ #include CoreBackendManager::CoreBackendManager() : - m_Backend(NULL) + m_Backend(nullptr) { } CoreBackendManager* CoreBackendManager::self() { - static CoreBackendManager* instance = NULL; + static CoreBackendManager* instance = nullptr; - if (instance == NULL) + if (instance == nullptr) instance = new CoreBackendManager; return instance; @@ -57,8 +57,8 @@ bool CoreBackendManager::load(const QString& name) KPluginFactory* factory = loader.factory(); - if (factory != NULL) { - m_Backend = factory->create(NULL); + if (factory != nullptr) { + m_Backend = factory->create(nullptr); QString id = loader.metaData().toVariantMap().value(QStringLiteral("MetaData")) .toMap().value(QStringLiteral("KPlugin")).toMap().value(QStringLiteral("Id")).toString(); @@ -80,5 +80,5 @@ bool CoreBackendManager::load(const QString& name) void CoreBackendManager::unload() { delete m_Backend; - m_Backend = NULL; + m_Backend = nullptr; } diff --git a/src/backend/corebackendpartitiontable.h b/src/backend/corebackendpartitiontable.h index fc497bc..a0f3e6e 100644 --- a/src/backend/corebackendpartitiontable.h +++ b/src/backend/corebackendpartitiontable.h @@ -53,13 +53,13 @@ public: virtual bool commit(quint32 timeout = 10) = 0; /** - * @return pointer to the extended partition as a CoreBackendPartition or NULL if there is none + * @return pointer to the extended partition as a CoreBackendPartition or nullptr if there is none */ virtual CoreBackendPartition* getExtendedPartition() = 0; /** * @param sector sector the partition occupies - * @return the CoreBackendPartition to occupy the given sector or NULL if not found + * @return the CoreBackendPartition to occupy the given sector or nullptr if not found */ virtual CoreBackendPartition* getPartitionBySector(qint64 sector) = 0; diff --git a/src/core/copysourcedevice.cpp b/src/core/copysourcedevice.cpp index f8bc0a2..8d33057 100644 --- a/src/core/copysourcedevice.cpp +++ b/src/core/copysourcedevice.cpp @@ -35,7 +35,7 @@ CopySourceDevice::CopySourceDevice(Device& d, qint64 firstsector, qint64 lastsec m_Device(d), m_FirstSector(firstsector), m_LastSector(lastsector), - m_BackendDevice(NULL) + m_BackendDevice(nullptr) { } @@ -51,7 +51,7 @@ CopySourceDevice::~CopySourceDevice() bool CopySourceDevice::open() { m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode()); - return m_BackendDevice != NULL; + return m_BackendDevice != nullptr; } /** Returns the Device's sector size diff --git a/src/core/copytargetdevice.cpp b/src/core/copytargetdevice.cpp index 2fa1750..ec6b0f2 100644 --- a/src/core/copytargetdevice.cpp +++ b/src/core/copytargetdevice.cpp @@ -32,7 +32,7 @@ CopyTargetDevice::CopyTargetDevice(Device& d, qint64 firstsector, qint64 lastsector) : CopyTarget(), m_Device(d), - m_BackendDevice(NULL), + m_BackendDevice(nullptr), m_FirstSector(firstsector), m_LastSector(lastsector) { @@ -50,7 +50,7 @@ CopyTargetDevice::~CopyTargetDevice() bool CopyTargetDevice::open() { m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode()); - return m_BackendDevice != NULL; + return m_BackendDevice != nullptr; } /** @return the Device's sector size */ diff --git a/src/core/device.cpp b/src/core/device.cpp index e26e053..418f8f2 100644 --- a/src/core/device.cpp +++ b/src/core/device.cpp @@ -83,7 +83,7 @@ Device::Device(const QString& name, const QString& devicenode, qint32 heads, qin QObject(), m_Name(name.length() > 0 ? name : i18n("Unknown Device")), m_DeviceNode(devicenode), - m_PartitionTable(NULL), + m_PartitionTable(nullptr), m_Heads(heads), m_SectorsPerTrack(numSectors), m_Cylinders(cylinders), diff --git a/src/core/operationrunner.cpp b/src/core/operationrunner.cpp index aa2ac56..c6756cb 100644 --- a/src/core/operationrunner.cpp +++ b/src/core/operationrunner.cpp @@ -31,7 +31,7 @@ OperationRunner::OperationRunner(QObject* parent, OperationStack& ostack) : QThread(parent), m_OperationStack(ostack), - m_Report(NULL), + m_Report(nullptr), m_SuspendMutex(), m_Cancelling(false) { diff --git a/src/core/operationstack.cpp b/src/core/operationstack.cpp index 79dc179..bd5f936 100644 --- a/src/core/operationstack.cpp +++ b/src/core/operationstack.cpp @@ -93,7 +93,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed { NewOperation* newOp = dynamic_cast(currentOp); - if (newOp == NULL) + if (newOp == nullptr) return false; DeleteOperation* pushedDeleteOp = dynamic_cast(pushedOp); @@ -108,7 +108,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed Log() << i18nc("@info/plain", "Deleting a partition just created: Undoing the operation to create the partition."); delete pushedOp; - pushedOp = NULL; + pushedOp = nullptr; newOp->undo(); delete operations().takeAt(operations().indexOf(newOp)); @@ -166,7 +166,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed newOp->newPartition().fileSystem().setLabel(pushedLabelOp->newLabel()); delete pushedOp; - pushedOp = NULL; + pushedOp = nullptr; return true; } @@ -180,10 +180,10 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed newOp->newPartition().setFileSystem(FileSystemFactory::cloneWithNewType(pushedCreateFileSystemOp->newFileSystem()->type(), *oldFs)); delete oldFs; - oldFs = NULL; + oldFs = nullptr; delete pushedOp; - pushedOp = NULL; + pushedOp = nullptr; return true; } @@ -193,7 +193,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed Log() << i18nc("@info/plain", "Checking file systems is automatically done when creating them: No new operation required."); delete pushedOp; - pushedOp = NULL; + pushedOp = nullptr; return true; } @@ -226,7 +226,7 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe { CopyOperation* copyOp = dynamic_cast(currentOp); - if (copyOp == NULL) + if (copyOp == nullptr) return false; DeleteOperation* pushedDeleteOp = dynamic_cast(pushedOp); @@ -236,11 +236,11 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe if (pushedDeleteOp && ©Op->copiedPartition() == &pushedDeleteOp->deletedPartition()) { // If the copy operation didn't overwrite, but create a new partition, just remove the // copy operation, forget the delete and be done. - if (copyOp->overwrittenPartition() == NULL) { + if (copyOp->overwrittenPartition() == nullptr) { Log() << i18nc("@info/plain", "Deleting a partition just copied: Removing the copy."); delete pushedOp; - pushedOp = NULL; + pushedOp = nullptr; } else { Log() << i18nc("@info/plain", "Deleting a partition just copied over an existing partition: Removing the copy and deleting the existing partition."); @@ -277,17 +277,17 @@ bool OperationStack::mergeRestoreOperation(Operation*& currentOp, Operation*& pu { RestoreOperation* restoreOp = dynamic_cast(currentOp); - if (restoreOp == NULL) + if (restoreOp == nullptr) return false; DeleteOperation* pushedDeleteOp = dynamic_cast(pushedOp); if (pushedDeleteOp && &restoreOp->restorePartition() == &pushedDeleteOp->deletedPartition()) { - if (restoreOp->overwrittenPartition() == NULL) { + if (restoreOp->overwrittenPartition() == nullptr) { Log() << i18nc("@info/plain", "Deleting a partition just restored: Removing the restore operation."); delete pushedOp; - pushedOp = NULL; + pushedOp = nullptr; } else { Log() << i18nc("@info/plain", "Deleting a partition just restored to an existing partition: Removing the restore operation and deleting the existing partition."); @@ -316,7 +316,7 @@ bool OperationStack::mergePartFlagsOperation(Operation*& currentOp, Operation*& { SetPartFlagsOperation* partFlagsOp = dynamic_cast(currentOp); - if (partFlagsOp == NULL) + if (partFlagsOp == nullptr) return false; SetPartFlagsOperation* pushedFlagsOp = dynamic_cast(pushedOp); @@ -347,7 +347,7 @@ bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*& { SetFileSystemLabelOperation* partLabelOp = dynamic_cast(currentOp); - if (partLabelOp == NULL) + if (partLabelOp == nullptr) return false; SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast(pushedOp); @@ -382,7 +382,7 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O Log() << i18nc("@info/plain", "Creating new partition table, discarding previous operation on device."); CreatePartitionTableOperation* createPartitionTableOp = dynamic_cast(currentOp); - if (createPartitionTableOp != NULL) + if (createPartitionTableOp != nullptr) pushedCreatePartitionTableOp->setOldPartitionTable(createPartitionTableOp->oldPartitionTable()); currentOp->undo(); @@ -401,7 +401,7 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O Operation. Callers must not rely on the pushed Operation to exist after calling OperationStack::push(). - @param o Pointer to the Operation. Must not be NULL. + @param o Pointer to the Operation. Must not be nullptr. */ void OperationStack::push(Operation* o) { @@ -427,14 +427,14 @@ void OperationStack::push(Operation* o) break; } - if (o != NULL) { + if (o != nullptr) { Log() << i18nc("@info/plain", "Add operation: %1", o->description()); operations().append(o); o->preview(); o->setStatus(Operation::StatusPending); } - // emit operationsChanged even if o is NULL because it has been merged: merging might + // emit operationsChanged even if o is nullptr because it has been merged: merging might // have led to an existing operation changing. emit operationsChanged(); } @@ -473,14 +473,14 @@ void OperationStack::clearDevices() /** Finds a Device a Partition is on. @param p pointer to the Partition to find a Device for - @return the Device or NULL if none could be found + @return the Device or nullptr if none could be found */ Device* OperationStack::findDeviceForPartition(const Partition* p) { QReadLocker lockDevices(&lock()); foreach(Device * d, previewDevices()) { - if (d->partitionTable() == NULL) + if (d->partitionTable() == nullptr) continue; foreach(const Partition * part, d->partitionTable()->children()) { @@ -493,11 +493,11 @@ Device* OperationStack::findDeviceForPartition(const Partition* p) } } - return NULL; + return nullptr; } /** Adds a Device to the OperationStack - @param d pointer to the Device to add. Must not be NULL. + @param d pointer to the Device to add. Must not be nullptr. */ void OperationStack::addDevice(Device* d) { diff --git a/src/core/operationstack.h b/src/core/operationstack.h index 21d3b79..52d206b 100644 --- a/src/core/operationstack.h +++ b/src/core/operationstack.h @@ -51,7 +51,7 @@ public: typedef QList Operations; public: - OperationStack(QObject* parent = NULL); + OperationStack(QObject* parent = nullptr); ~OperationStack(); Q_SIGNALS: diff --git a/src/core/partition.cpp b/src/core/partition.cpp index 7c4d2a6..cb27e5d 100644 --- a/src/core/partition.cpp +++ b/src/core/partition.cpp @@ -33,7 +33,7 @@ #include /** Creates a new Partition object. - @param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be NULL. + @param parent the Partition's parent. May be another Partition (for logicals) or a PartitionTable. Must not be nullptr. @param device the Device this Partition is on. @param role the Partition's role(s) @param fs pointer to the Partition's FileSystem object. The Partition object will take ownership of this. @@ -340,7 +340,7 @@ bool Partition::unmount(Report& report) void Partition::deleteFileSystem() { delete m_FileSystem; - m_FileSystem = NULL; + m_FileSystem = nullptr; } void Partition::setPartitionPath(const QString& s) diff --git a/src/core/partitionnode.cpp b/src/core/partitionnode.cpp index dadf021..d0a31c6 100644 --- a/src/core/partitionnode.cpp +++ b/src/core/partitionnode.cpp @@ -24,7 +24,7 @@ /** Tries to find the predecessor for a Partition. @param p the Partition to find a predecessor for - @return pointer to the predecessor or NULL if none was found + @return pointer to the predecessor or nullptr if none was found */ Partition* PartitionNode::predecessor(Partition& p) { @@ -36,7 +36,7 @@ Partition* PartitionNode::predecessor(Partition& p) if (plist[idx] == &p) return plist[idx - 1]; - return NULL; + return nullptr; } /** @@ -52,12 +52,12 @@ const Partition* PartitionNode::predecessor(const Partition& p) const if (plist[idx] == &p) return plist[idx - 1]; - return NULL; + return nullptr; } /** Tries to find the successor for a Partition. @param p the Partition to find a successor for - @return pointer to the successor or NULL if none was found + @return pointer to the successor or nullptr if none was found */ Partition* PartitionNode::successor(Partition& p) { @@ -69,7 +69,7 @@ Partition* PartitionNode::successor(Partition& p) if (plist[idx] == &p) return plist[idx + 1]; - return NULL; + return nullptr; } /** @@ -85,16 +85,16 @@ const Partition* PartitionNode::successor(const Partition& p) const if (plist[idx] == &p) return plist[idx + 1]; - return NULL; + return nullptr; } /** Inserts a Partition into a PartitionNode's children - @param p pointer to the Partition to insert. May be NULL. + @param p pointer to the Partition to insert. May be nullptr. @return true on success */ bool PartitionNode::insert(Partition* p) { - if (p == NULL) + if (p == nullptr) return false; for (int idx = 0; idx < children().size(); idx++) { @@ -110,12 +110,12 @@ bool PartitionNode::insert(Partition* p) } /** Removes a Partition from the PartitionNode's children. - @param p pointer to the Partition to remove. May be NULL. + @param p pointer to the Partition to remove. May be nullptr. @return true on success. */ bool PartitionNode::remove(Partition* p) { - if (p == NULL) + if (p == nullptr) return false; if (children().removeOne(p)) @@ -134,7 +134,7 @@ void PartitionNode::clearChildren() /** Finds a Partition by sector. @param s the sector the Partition is at @param role the PartitionRole the Partition is supposed to have - @return pointer to the Partition found or NULL if none was found + @return pointer to the Partition found or nullptr if none was found */ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role) { @@ -148,7 +148,7 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r return p; } - return NULL; + return nullptr; } /** @@ -165,7 +165,7 @@ const Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionR return p; } - return NULL; + return nullptr; } /** Reparents a Partition to this PartitionNode diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 07b02c7..d725d8b 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -97,14 +97,14 @@ bool PartitionTable::hasExtended() const return false; } -/** @return pointer to the PartitionTable's extended Partition or NULL if none exists */ +/** @return pointer to the PartitionTable's extended Partition or nullptr if none exists */ Partition* PartitionTable::extended() const { for (int i = 0; i < children().size(); i++) if (children()[i]->roles().has(PartitionRole::Extended)) return children()[i]; - return NULL; + return nullptr; } /** Gets valid PartitionRoles for a Partition @@ -136,7 +136,7 @@ int PartitionTable::numPrimaries() const } /** Appends a Partition to this PartitionTable - @param partition pointer of the partition to append. Must not be NULL. + @param partition pointer of the partition to append. Must not be nullptr. */ void PartitionTable::append(Partition* partition) { @@ -213,7 +213,7 @@ bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& pa if (!parent.isRoot()) { Partition* extended = dynamic_cast(&parent); - if (extended == NULL) { + if (extended == nullptr) { qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode(); return false; } @@ -236,7 +236,7 @@ bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& pa @param parent the parent PartitionNode for the new Partition @param start the new Partition's start sector @param end the new Partition's end sector - @return pointer to the newly created Partition object or NULL if the Partition could not be created + @return pointer to the newly created Partition object or nullptr if the Partition could not be created */ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64 start, qint64 end) { @@ -246,7 +246,7 @@ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64 r |= PartitionRole::Logical; if (!PartitionTable::getUnallocatedRange(device, parent, start, end)) - return NULL; + return nullptr; return new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString()); } @@ -256,7 +256,7 @@ Partition* createUnallocated(const Device& device, PartitionNode& parent, qint64 */ void PartitionTable::removeUnallocated(PartitionNode* p) { - Q_ASSERT(p != NULL); + Q_ASSERT(p != nullptr); qint32 i = 0; @@ -298,7 +298,7 @@ void PartitionTable::removeUnallocated() */ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const { - Q_ASSERT(p != NULL); + Q_ASSERT(p != nullptr); qint64 lastEnd = start; @@ -317,8 +317,8 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 if (!p->isRoot()) { Partition* extended = dynamic_cast(p); - Q_ASSERT(extended != NULL); - parentEnd = (extended != NULL) ? extended->lastSector() : -1; + Q_ASSERT(extended != nullptr); + parentEnd = (extended != nullptr) ? extended->lastSector() : -1; } if (parentEnd >= firstUsable()) diff --git a/src/core/partitiontable.h b/src/core/partitiontable.h index 286f03a..9ccfe60 100644 --- a/src/core/partitiontable.h +++ b/src/core/partitiontable.h @@ -90,10 +90,10 @@ public: public: PartitionNode* parent() { - return NULL; /**< @return always NULL for PartitionTable */ + return nullptr; /**< @return always nullptr for PartitionTable */ } const PartitionNode* parent() const { - return NULL; /**< @return always NULL for PartitionTable */ + return nullptr; /**< @return always nullptr for PartitionTable */ } bool isRoot() const { diff --git a/src/core/smartstatus.cpp b/src/core/smartstatus.cpp index 016970e..fba1fae 100644 --- a/src/core/smartstatus.cpp +++ b/src/core/smartstatus.cpp @@ -46,7 +46,7 @@ SmartStatus::SmartStatus(const QString& device_path) : void SmartStatus::update() { - SkDisk* skDisk = NULL; + SkDisk* skDisk = nullptr; SkBool skSmartStatus = false; uint64_t mkelvin = 0; uint64_t skBadSectors = 0; diff --git a/src/fs/fat16.cpp b/src/fs/fat16.cpp index fe052ea..3ae0f82 100644 --- a/src/fs/fat16.cpp +++ b/src/fs/fat16.cpp @@ -148,7 +148,7 @@ bool fat16::create(Report& report, const QString& deviceNode) const bool fat16::updateUUID(Report& report, const QString& deviceNode) const { - qint32 t = time(NULL); + qint32 t = time(nullptr); char uuid[4]; for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8) diff --git a/src/fs/fat32.cpp b/src/fs/fat32.cpp index 0366289..38b855c 100644 --- a/src/fs/fat32.cpp +++ b/src/fs/fat32.cpp @@ -48,7 +48,7 @@ bool fat32::create(Report& report, const QString& deviceNode) const bool fat32::updateUUID(Report& report, const QString& deviceNode) const { - qint32 t = time(NULL); + qint32 t = time(nullptr); char uuid[4]; for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8) diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 42c7bf0..43dbba0 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -87,11 +87,11 @@ static QString readBlkIdValue(const QString& deviceNode, const QString& tag) blkid_cache cache; QString rval; - if (blkid_get_cache(&cache, NULL) == 0) { + if (blkid_get_cache(&cache, nullptr) == 0) { blkid_dev dev; - char* label = NULL; - if ((dev = blkid_get_dev(cache, deviceNode.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != NULL && + char* label = nullptr; + if ((dev = blkid_get_dev(cache, deviceNode.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != nullptr && (label = blkid_get_tag_value(cache, tag.toLocal8Bit().constData(), deviceNode.toLocal8Bit().constData()))) { rval = QString::fromUtf8(label); free(label); diff --git a/src/fs/filesystemfactory.cpp b/src/fs/filesystemfactory.cpp index 787abd5..f12d349 100644 --- a/src/fs/filesystemfactory.cpp +++ b/src/fs/filesystemfactory.cpp @@ -116,11 +116,11 @@ void FileSystemFactory::init() @param lastsector the FileSystem's last sector relative to the Device @param sectorsused the number of used sectors in the FileSystem @param label the FileSystem's label - @return pointer to the newly created FileSystem object or NULL if FileSystem could not be created + @return pointer to the newly created FileSystem object or nullptr if FileSystem could not be created */ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QString& uuid) { - FileSystem* fs = NULL; + FileSystem* fs = nullptr; switch (t) { case FileSystem::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break; @@ -151,7 +151,7 @@ FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qi default: break; } - if (fs != NULL) + if (fs != nullptr) fs->setUUID(uuid); return fs; @@ -174,7 +174,7 @@ const FileSystemFactory::FileSystems& FileSystemFactory::map() /** Clones a FileSystem from another one, but with a new type. @param newType the new FileSystem's type @param other the old FileSystem to clone - @return pointer to the newly created FileSystem or NULL in case of errors + @return pointer to the newly created FileSystem or nullptr in case of errors */ FileSystem* FileSystemFactory::cloneWithNewType(FileSystem::Type newType, const FileSystem& other) { diff --git a/src/gui/partresizerwidget.cpp b/src/gui/partresizerwidget.cpp index 8cb070e..38f5958 100644 --- a/src/gui/partresizerwidget.cpp +++ b/src/gui/partresizerwidget.cpp @@ -44,9 +44,9 @@ const qint32 PartResizerWidget::m_HandleHeight = 59; */ PartResizerWidget::PartResizerWidget(QWidget* parent) : QWidget(parent), - m_Device(NULL), - m_Partition(NULL), - m_PartWidget(NULL), + m_Device(nullptr), + m_Partition(nullptr), + m_PartWidget(nullptr), m_MinimumFirstSector(0), m_MaximumFirstSector(-1), m_MinimumLastSector(-1), @@ -55,7 +55,7 @@ PartResizerWidget::PartResizerWidget(QWidget* parent) : m_MaximumLength(-1), m_LeftHandle(this), m_RightHandle(this), - m_DraggedWidget(NULL), + m_DraggedWidget(nullptr), m_Hotspot(0), m_MoveAllowed(true), m_ReadOnly(false), @@ -187,7 +187,7 @@ void PartResizerWidget::mousePressEvent(QMouseEvent* event) if (event->button() == Qt::LeftButton) { m_DraggedWidget = static_cast(childAt(event->pos())); - if (m_DraggedWidget != NULL) { + if (m_DraggedWidget != nullptr) { if (partWidget().isAncestorOf(m_DraggedWidget)) m_DraggedWidget = &partWidget(); @@ -298,7 +298,7 @@ void PartResizerWidget::mouseMoveEvent(QMouseEvent* event) void PartResizerWidget::mouseReleaseEvent(QMouseEvent* event) { if (event->button() == Qt::LeftButton) - m_DraggedWidget = NULL; + m_DraggedWidget = nullptr; } bool PartResizerWidget::updateFirstSector(qint64 newFirstSector) @@ -444,7 +444,7 @@ void PartResizerWidget::setMoveAllowed(bool b) { m_MoveAllowed = b; - if (m_PartWidget != NULL) + if (m_PartWidget != nullptr) partWidget().setCursor(b ? Qt::SizeAllCursor : Qt::ArrowCursor); } diff --git a/src/gui/partwidget.cpp b/src/gui/partwidget.cpp index 4968117..b87688b 100644 --- a/src/gui/partwidget.cpp +++ b/src/gui/partwidget.cpp @@ -28,11 +28,11 @@ /** Creates a new PartWidget @param parent pointer to the parent widget - @param p pointer to the Partition this widget will show. must not be NULL. + @param p pointer to the Partition this widget will show. must not be nullptr. */ PartWidget::PartWidget(QWidget* parent, const Partition* p) : PartWidgetBase(parent), - m_Partition(NULL), + m_Partition(nullptr), m_Active(false) { setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); @@ -59,7 +59,7 @@ void PartWidget::updateChildren() foreach(QWidget * w, childWidgets()) { w->setVisible(false); w->deleteLater(); - w->setParent(NULL); + w->setParent(nullptr); } foreach(const Partition * child, partition()->children()) { @@ -90,7 +90,7 @@ QColor PartWidget::activeColor(const QColor& col) const void PartWidget::paintEvent(QPaintEvent*) { - if (partition() == NULL) + if (partition() == nullptr) return; const int usedPercentage = partition()->used() * 100 / partition()->capacity(); diff --git a/src/gui/partwidget.h b/src/gui/partwidget.h index 9ac1ad6..bba898b 100644 --- a/src/gui/partwidget.h +++ b/src/gui/partwidget.h @@ -44,7 +44,7 @@ class LIBKPMCORE_EXPORT PartWidget : public PartWidgetBase Q_OBJECT public: - explicit PartWidget(QWidget* parent, const Partition* p = NULL); + explicit PartWidget(QWidget* parent, const Partition* p = nullptr); public: void init(const Partition* p); diff --git a/src/jobs/createpartitiontablejob.cpp b/src/jobs/createpartitiontablejob.cpp index 14f0fcb..322aa6a 100644 --- a/src/jobs/createpartitiontablejob.cpp +++ b/src/jobs/createpartitiontablejob.cpp @@ -45,7 +45,7 @@ bool CreatePartitionTableJob::run(Report& parent) CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode()); - if (backendDevice != NULL) { + if (backendDevice != nullptr) { Q_ASSERT(device().partitionTable()); rval = backendDevice->createPartitionTable(*report, *device().partitionTable()); diff --git a/src/ops/backupoperation.cpp b/src/ops/backupoperation.cpp index d8be7bc..3e76a5d 100644 --- a/src/ops/backupoperation.cpp +++ b/src/ops/backupoperation.cpp @@ -49,12 +49,12 @@ QString BackupOperation::description() const } /** Can the given Partition be backed up? - @param p The Partition in question, may be NULL. + @param p The Partition in question, may be nullptr. @return true if @p p can be backed up. */ bool BackupOperation::canBackup(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; if (p->isMounted()) diff --git a/src/ops/checkoperation.cpp b/src/ops/checkoperation.cpp index 7010d3f..910ab63 100644 --- a/src/ops/checkoperation.cpp +++ b/src/ops/checkoperation.cpp @@ -60,12 +60,12 @@ QString CheckOperation::description() const } /** Can a Partition be checked? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if @p p can be checked. */ bool CheckOperation::canCheck(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; if (p->isMounted()) diff --git a/src/ops/copyoperation.cpp b/src/ops/copyoperation.cpp index 30df7e3..aae557b 100644 --- a/src/ops/copyoperation.cpp +++ b/src/ops/copyoperation.cpp @@ -38,9 +38,9 @@ /** Creates a new CopyOperation. @param targetdevice the Device to copy the Partition to - @param copiedpartition pointer to the new Partition object on the target Device. May not be NULL. + @param copiedpartition pointer to the new Partition object on the target Device. May not be nullptr. @param sourcedevice the Device where to copy from - @param sourcepartition pointer to the Partition to copy from. May not be NULL. + @param sourcepartition pointer to the Partition to copy from. May not be nullptr. */ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, Device& sourcedevice, Partition* sourcepartition) : Operation(), @@ -48,13 +48,13 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D m_CopiedPartition(copiedpartition), m_SourceDevice(sourcedevice), m_SourcePartition(sourcepartition), - m_OverwrittenPartition(NULL), + m_OverwrittenPartition(nullptr), m_MustDeleteOverwritten(false), - m_CheckSourceJob(NULL), - m_CreatePartitionJob(NULL), - m_CopyFSJob(NULL), - m_CheckTargetJob(NULL), - m_MaximizeJob(NULL), + m_CheckSourceJob(nullptr), + m_CreatePartitionJob(nullptr), + m_CopyFSJob(nullptr), + m_CheckTargetJob(nullptr), + m_MaximizeJob(nullptr), m_Description(updateDescription()) { Q_ASSERT(targetDevice().partitionTable()); @@ -63,7 +63,7 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D Q_ASSERT(dest); - if (dest == NULL) + if (dest == nullptr) qWarning() << "destination partition not found at sector " << copiedPartition().firstSector(); if (dest && !dest->roles().has(PartitionRole::Unallocated)) { @@ -73,7 +73,7 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D addJob(m_CheckSourceJob = new CheckFileSystemJob(sourcePartition())); - if (overwrittenPartition() == NULL) + if (overwrittenPartition() == nullptr) addJob(m_CreatePartitionJob = new CreatePartitionJob(targetDevice(), copiedPartition())); addJob(m_CopyFSJob = new CopyFileSystemJob(targetDevice(), copiedPartition(), sourceDevice(), sourcePartition())); @@ -243,7 +243,7 @@ void CopyOperation::cleanupOverwrittenPartition() { if (mustDeleteOverwritten()) { delete overwrittenPartition(); - m_OverwrittenPartition = NULL; + m_OverwrittenPartition = nullptr; } } @@ -272,12 +272,12 @@ Partition* CopyOperation::createCopy(const Partition& target, const Partition& s } /** Can a Partition be copied? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if @p p can be copied. */ bool CopyOperation::canCopy(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; if (p->isMounted()) @@ -291,13 +291,13 @@ bool CopyOperation::canCopy(const Partition* p) } /** Can a Partition be pasted on another one? - @param p the Partition to be pasted to, may be NULL - @param source the Partition to be pasted, may be NULL + @param p the Partition to be pasted to, may be nullptr + @param source the Partition to be pasted, may be nullptr @return true if @p source can be pasted on @p p */ bool CopyOperation::canPaste(const Partition* p, const Partition* source) { - if (p == NULL || source == NULL) + if (p == nullptr || source == nullptr) return false; if (p->isMounted()) diff --git a/src/ops/createpartitiontableoperation.cpp b/src/ops/createpartitiontableoperation.cpp index 2013598..4e4b942 100644 --- a/src/ops/createpartitiontableoperation.cpp +++ b/src/ops/createpartitiontableoperation.cpp @@ -87,12 +87,12 @@ bool CreatePartitionTableOperation::execute(Report& parent) } /** Can a new partition table be created on a device? - @param device pointer to the device, can be NULL + @param device pointer to the device, can be nullptr @return true if a new partition table can be created on @p device */ bool CreatePartitionTableOperation::canCreate(const Device* device) { - return device != NULL && (device->partitionTable() == NULL || !device->partitionTable()->isChildMounted()); + return device != nullptr && (device->partitionTable() == nullptr || !device->partitionTable()->isChildMounted()); } QString CreatePartitionTableOperation::description() const diff --git a/src/ops/deleteoperation.cpp b/src/ops/deleteoperation.cpp index 486c3fe..142c135 100644 --- a/src/ops/deleteoperation.cpp +++ b/src/ops/deleteoperation.cpp @@ -33,7 +33,7 @@ /** Creates a new DeleteOperation @param d the Device to delete a Partition on - @param p pointer to the Partition to delete. May not be NULL + @param p pointer to the Partition to delete. May not be nullptr */ DeleteOperation::DeleteOperation(Device& d, Partition* p, ShredAction shred) : Operation(), @@ -103,12 +103,12 @@ void DeleteOperation::checkAdjustLogicalNumbers(Partition& p, bool undo) } /** Can a Partition be deleted? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if @p p can be deleted. */ bool DeleteOperation::canDelete(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; if (p->isMounted()) diff --git a/src/ops/newoperation.cpp b/src/ops/newoperation.cpp index 2f7e0fb..2e993c6 100644 --- a/src/ops/newoperation.cpp +++ b/src/ops/newoperation.cpp @@ -38,17 +38,17 @@ /** Creates a new NewOperation. @param d the Device to create a new Partition on - @param p pointer to the new Partition to create. May not be NULL. + @param p pointer to the new Partition to create. May not be nullptr. */ NewOperation::NewOperation(Device& d, Partition* p) : Operation(), m_TargetDevice(d), m_NewPartition(p), m_CreatePartitionJob(new CreatePartitionJob(targetDevice(), newPartition())), - m_CreateFileSystemJob(NULL), - m_SetPartFlagsJob(NULL), - m_SetFileSystemLabelJob(NULL), - m_CheckFileSystemJob(NULL) + m_CreateFileSystemJob(nullptr), + m_SetPartFlagsJob(nullptr), + m_SetFileSystemLabelJob(nullptr), + m_CheckFileSystemJob(nullptr) { addJob(createPartitionJob()); @@ -109,12 +109,12 @@ QString NewOperation::description() const } /** Can a Partition be created somewhere? - @param p the Partition where a new Partition is to be created, may be NULL + @param p the Partition where a new Partition is to be created, may be nullptr @return true if a new Partition can be created in @p p */ bool NewOperation::canCreateNew(const Partition* p) { - return p != NULL && p->roles().has(PartitionRole::Unallocated); + return p != nullptr && p->roles().has(PartitionRole::Unallocated); } Partition* NewOperation::createNew(const Partition& cloneFrom, diff --git a/src/ops/resizeoperation.cpp b/src/ops/resizeoperation.cpp index feceb03..2cb4e56 100644 --- a/src/ops/resizeoperation.cpp +++ b/src/ops/resizeoperation.cpp @@ -53,14 +53,14 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6 m_NewFirstSector(newfirst), m_NewLastSector(newlast), m_CheckOriginalJob(new CheckFileSystemJob(partition())), - m_MoveExtendedJob(NULL), - m_ShrinkResizeJob(NULL), - m_ShrinkSetGeomJob(NULL), - m_MoveSetGeomJob(NULL), - m_MoveFileSystemJob(NULL), - m_GrowResizeJob(NULL), - m_GrowSetGeomJob(NULL), - m_CheckResizedJob(NULL) + m_MoveExtendedJob(nullptr), + m_ShrinkResizeJob(nullptr), + m_ShrinkSetGeomJob(nullptr), + m_MoveSetGeomJob(nullptr), + m_MoveFileSystemJob(nullptr), + m_GrowResizeJob(nullptr), + m_GrowSetGeomJob(nullptr), + m_CheckResizedJob(nullptr) { addJob(checkOriginalJob()); @@ -313,12 +313,12 @@ bool ResizeOperation::grow(Report& report) } /** Can a Partition be grown, i.e. increased in size? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if @p p can be grown. */ bool ResizeOperation::canGrow(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; // we can always grow, shrink or move a partition not yet written to disk @@ -332,12 +332,12 @@ bool ResizeOperation::canGrow(const Partition* p) } /** Can a Partition be shrunk, i.e. decreased in size? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if @p p can be shrunk. */ bool ResizeOperation::canShrink(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; // we can always grow, shrink or move a partition not yet written to disk @@ -354,12 +354,12 @@ bool ResizeOperation::canShrink(const Partition* p) } /** Can a Partition be moved? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if @p p can be moved. */ bool ResizeOperation::canMove(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; // we can always grow, shrink or move a partition not yet written to disk diff --git a/src/ops/restoreoperation.cpp b/src/ops/restoreoperation.cpp index 2bc41d4..2862908 100644 --- a/src/ops/restoreoperation.cpp +++ b/src/ops/restoreoperation.cpp @@ -42,7 +42,7 @@ /** Creates a new RestoreOperation. @param d the Device to restore the Partition to - @param p pointer to the Partition that will be restored. May not be NULL. + @param p pointer to the Partition that will be restored. May not be nullptr. @param filename name of the image file to restore from */ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filename) : @@ -50,13 +50,13 @@ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filen m_TargetDevice(d), m_RestorePartition(p), m_FileName(filename), - m_OverwrittenPartition(NULL), + m_OverwrittenPartition(nullptr), m_MustDeleteOverwritten(false), m_ImageLength(QFileInfo(filename).size() / 512), // 512 being the "sector size" of an image file. - m_CreatePartitionJob(NULL), - m_RestoreJob(NULL), - m_CheckTargetJob(NULL), - m_MaximizeJob(NULL) + m_CreatePartitionJob(nullptr), + m_RestoreJob(nullptr), + m_CheckTargetJob(nullptr), + m_MaximizeJob(nullptr) { restorePartition().setState(Partition::StateRestore); @@ -66,7 +66,7 @@ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filen Q_ASSERT(dest); - if (dest == NULL) + if (dest == nullptr) qWarning() << "destination partition not found at sector " << restorePartition().firstSector(); if (dest && !dest->roles().has(PartitionRole::Unallocated)) { @@ -178,17 +178,17 @@ void RestoreOperation::cleanupOverwrittenPartition() { if (mustDeleteOverwritten()) { delete overwrittenPartition(); - m_OverwrittenPartition = NULL; + m_OverwrittenPartition = nullptr; } } /** Can a Partition be restored to somewhere? - @param p the Partition in question, may be NULL. + @param p the Partition in question, may be nullptr. @return true if a Partition can be restored to @p p. */ bool RestoreOperation::canRestore(const Partition* p) { - if (p == NULL) + if (p == nullptr) return false; if (p->isMounted()) @@ -215,7 +215,7 @@ Partition* RestoreOperation::createRestorePartition(const Device& device, Partit QFileInfo fileInfo(filename); if (!fileInfo.exists()) - return NULL; + return nullptr; const qint64 end = start + fileInfo.size() / device.logicalSectorSize() - 1; Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString()); diff --git a/src/plugins/dummy/dummybackend.cpp b/src/plugins/dummy/dummybackend.cpp index bead279..c216343 100644 --- a/src/plugins/dummy/dummybackend.cpp +++ b/src/plugins/dummy/dummybackend.cpp @@ -72,9 +72,9 @@ CoreBackendDevice* DummyBackend::openDevice(const QString& device_node) { DummyDevice* device = new DummyDevice(device_node); - if (device == NULL || !device->open()) { + if (device == nullptr || !device->open()) { delete device; - device = NULL; + device = nullptr; } return device; @@ -84,9 +84,9 @@ CoreBackendDevice* DummyBackend::openDeviceExclusive(const QString& device_node) { DummyDevice* device = new DummyDevice(device_node); - if (device == NULL || !device->openExclusive()) { + if (device == nullptr || !device->openExclusive()) { delete device; - device = NULL; + device = nullptr; } return device; diff --git a/src/plugins/dummy/dummydevice.cpp b/src/plugins/dummy/dummydevice.cpp index d226fe3..fb52984 100644 --- a/src/plugins/dummy/dummydevice.cpp +++ b/src/plugins/dummy/dummydevice.cpp @@ -51,9 +51,9 @@ CoreBackendPartitionTable* DummyDevice::openPartitionTable() { CoreBackendPartitionTable* ptable = new DummyPartitionTable(); - if (ptable == NULL || !ptable->open()) { + if (ptable == nullptr || !ptable->open()) { delete ptable; - ptable = NULL; + ptable = nullptr; } return ptable; diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index 4433b38..d9e868b 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -299,7 +299,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD Q_ASSERT(pedDisk); Q_ASSERT(d.partitionTable()); - PedPartition* pedPartition = NULL; + PedPartition* pedPartition = nullptr; KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName); mountPoints.append(KMountPoint::possibleMountPoints(KMountPoint::NeedRealDeviceName)); @@ -335,7 +335,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD PartitionNode* parent = d.partitionTable()->findPartitionBySector(pedPartition->geom.start, PartitionRole(PartitionRole::Extended)); // None found, so it's a primary in the device's partition table. - if (parent == NULL) + if (parent == nullptr) parent = d.partitionTable(); const QString node = QString::fromUtf8(ped_partition_get_path(pedPartition)); @@ -385,9 +385,9 @@ Device* LibPartedBackend::scanDevice(const QString& device_node) { PedDevice* pedDevice = ped_device_get(device_node.toLocal8Bit().constData()); - if (pedDevice == NULL) { + if (pedDevice == nullptr) { Log(Log::warning) << xi18nc("@info/plain", "Could not access device %1", device_node); - return NULL; + return nullptr; } Log(Log::information) << i18nc("@info/plain", "Device found: %1", QString::fromUtf8(pedDevice->model)); @@ -412,7 +412,7 @@ QList LibPartedBackend::scanDevices() QList result; ped_device_probe_all(); - PedDevice* pedDevice = NULL; + PedDevice* pedDevice = nullptr; QVector path; quint32 totalDevices = 0; while (true) { @@ -438,9 +438,9 @@ CoreBackendDevice* LibPartedBackend::openDevice(const QString& device_node) { LibPartedDevice* device = new LibPartedDevice(device_node); - if (device == NULL || !device->open()) { + if (device == nullptr || !device->open()) { delete device; - device = NULL; + device = nullptr; } return device; @@ -450,9 +450,9 @@ CoreBackendDevice* LibPartedBackend::openDeviceExclusive(const QString& device_n { LibPartedDevice* device = new LibPartedDevice(device_node); - if (device == NULL || !device->openExclusive()) { + if (device == nullptr || !device->openExclusive()) { delete device; - device = NULL; + device = nullptr; } return device; @@ -464,8 +464,8 @@ bool LibPartedBackend::closeDevice(CoreBackendDevice* core_device) } /** Detects the type of a FileSystem given a PedDevice and a PedPartition - @param pedDevice pointer to the pedDevice. Must not be NULL. - @param pedPartition pointer to the pedPartition. Must not be NULL + @param pedDevice pointer to the pedDevice. Must not be nullptr. + @param pedPartition pointer to the pedPartition. Must not be nullptr @return the detected FileSystem type (FileSystem::Unknown if not detected) */ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition) @@ -473,12 +473,12 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition) FileSystem::Type rval = FileSystem::Unknown; blkid_cache cache; - char* pedPath = NULL; + char* pedPath = nullptr; - if (blkid_get_cache(&cache, NULL) == 0 && (pedPath = ped_partition_get_path(pedPartition))) { + if (blkid_get_cache(&cache, nullptr) == 0 && (pedPath = ped_partition_get_path(pedPartition))) { blkid_dev dev; - if ((dev = blkid_get_dev(cache, pedPath, BLKID_DEV_NORMAL)) != NULL) { + if ((dev = blkid_get_dev(cache, pedPath, BLKID_DEV_NORMAL)) != nullptr) { QString s = QString::fromUtf8(blkid_get_tag_value(cache, "TYPE", pedPath)); if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2; @@ -493,7 +493,7 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition) else if (s == QStringLiteral("hfs")) rval = FileSystem::Hfs; else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus; else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs; - else if (s == QStringLiteral("vfat") && pedPartition->fs_type != NULL) { + else if (s == QStringLiteral("vfat") && pedPartition->fs_type != nullptr) { // libblkid does not distinguish between fat16 and fat32, so we're still using libparted // for those if (strcmp(pedPartition->fs_type->name, "fat16") == 0) diff --git a/src/plugins/libparted/libparteddevice.cpp b/src/plugins/libparted/libparteddevice.cpp index 3fd0911..6272688 100644 --- a/src/plugins/libparted/libparteddevice.cpp +++ b/src/plugins/libparted/libparteddevice.cpp @@ -29,7 +29,7 @@ LibPartedDevice::LibPartedDevice(const QString& device_node) : CoreBackendDevice(device_node), - m_PedDevice(NULL) + m_PedDevice(nullptr) { } @@ -41,14 +41,14 @@ LibPartedDevice::~LibPartedDevice() bool LibPartedDevice::open() { - Q_ASSERT(pedDevice() == NULL); + Q_ASSERT(pedDevice() == nullptr); if (pedDevice()) return false; m_PedDevice = ped_device_get(deviceNode().toLatin1().constData()); - return m_PedDevice != NULL; + return m_PedDevice != nullptr; } bool LibPartedDevice::openExclusive() @@ -70,7 +70,7 @@ bool LibPartedDevice::close() setExclusive(false); } - m_PedDevice = NULL; + m_PedDevice = nullptr; return true; } @@ -78,9 +78,9 @@ CoreBackendPartitionTable* LibPartedDevice::openPartitionTable() { CoreBackendPartitionTable* ptable = new LibPartedPartitionTable(pedDevice()); - if (ptable == NULL || !ptable->open()) { + if (ptable == nullptr || !ptable->open()) { delete ptable; - ptable = NULL; + ptable = nullptr; } return ptable; @@ -90,21 +90,21 @@ bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& { PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLatin1().constData()); - if (pedDiskType == NULL) { + if (pedDiskType == nullptr) { report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not retrieve partition table type \"%1\" for %2.", ptable.typeName(), deviceNode()); return false; } PedDevice* dev = ped_device_get(deviceNode().toLatin1().constData()); - if (dev == NULL) { + if (dev == nullptr) { report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not open backend device %1.", deviceNode()); return false; } PedDisk* disk = ped_disk_new_fresh(dev, pedDiskType); - if (disk == NULL) { + if (disk == nullptr) { report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not create a new partition table in the backend for device %1.", deviceNode()); return false; } diff --git a/src/plugins/libparted/libpartedpartition.cpp b/src/plugins/libparted/libpartedpartition.cpp index d07b334..570e2b3 100644 --- a/src/plugins/libparted/libpartedpartition.cpp +++ b/src/plugins/libparted/libpartedpartition.cpp @@ -30,7 +30,7 @@ LibPartedPartition::LibPartedPartition(PedPartition* ped_partition) : bool LibPartedPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state) { - Q_ASSERT(pedPartition() != NULL); + Q_ASSERT(pedPartition() != nullptr); const PedPartitionFlag f = LibPartedBackend::getPedFlag(partitionManagerFlag); diff --git a/src/plugins/libparted/libpartedpartitiontable.cpp b/src/plugins/libparted/libpartedpartitiontable.cpp index a505752..aab02b4 100644 --- a/src/plugins/libparted/libpartedpartitiontable.cpp +++ b/src/plugins/libparted/libpartedpartitiontable.cpp @@ -37,13 +37,13 @@ LibPartedPartitionTable::LibPartedPartitionTable(PedDevice* device) : CoreBackendPartitionTable(), m_PedDevice(device), - m_PedDisk(NULL) + m_PedDisk(nullptr) { } LibPartedPartitionTable::~LibPartedPartitionTable() { - if (m_PedDisk != NULL) + if (m_PedDisk != nullptr) ped_disk_destroy(m_PedDisk); } @@ -51,7 +51,7 @@ bool LibPartedPartitionTable::open() { m_PedDisk = ped_disk_new(pedDevice()); - return m_PedDisk != NULL; + return m_PedDisk != nullptr; } bool LibPartedPartitionTable::commit(quint32 timeout) @@ -61,7 +61,7 @@ bool LibPartedPartitionTable::commit(quint32 timeout) bool LibPartedPartitionTable::commit(PedDisk* pd, quint32 timeout) { - if (pd == NULL) + if (pd == nullptr) return false; bool rval = ped_disk_commit_to_dev(pd); @@ -91,8 +91,8 @@ CoreBackendPartition* LibPartedPartitionTable::getExtendedPartition() { PedPartition* pedPartition = ped_disk_extended_partition(pedDisk()); - if (pedPartition == NULL) - return NULL; + if (pedPartition == nullptr) + return nullptr; return new LibPartedPartition(pedPartition); } @@ -101,8 +101,8 @@ CoreBackendPartition* LibPartedPartitionTable::getPartitionBySector(qint64 secto { PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), sector); - if (pedPartition == NULL) - return NULL; + if (pedPartition == nullptr) + return nullptr; return new LibPartedPartition(pedPartition); } @@ -146,7 +146,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition QString rval = QString(); - // According to libParted docs, PedPartitionType can be "NULL if unknown". That's obviously wrong, + // According to libParted docs, PedPartitionType can be "nullptr if unknown". That's obviously wrong, // it's a typedef for an enum. So let's use something the libparted devs will hopefully never // use... PedPartitionType pedType = static_cast(0xffffffff); @@ -163,22 +163,22 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition return QString(); } - PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? NULL : getPedFileSystemType(partition.fileSystem().type()); + PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type()); PedPartition* pedPartition = ped_partition_new(pedDisk(), pedType, pedFsType, partition.firstSector(), partition.lastSector()); - if (pedPartition == NULL) { + if (pedPartition == nullptr) { report.line() << xi18nc("@info/plain", "Failed to create new partition %1.", partition.deviceNode()); return QString(); } - PedConstraint* pedConstraint = NULL; + PedConstraint* pedConstraint = nullptr; PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition.firstSector(), partition.length()); if (pedGeometry) pedConstraint = ped_constraint_exact(pedGeometry); - if (pedConstraint == NULL) { + if (pedConstraint == nullptr) { report.line() << i18nc("@info/plain", "Failed to create a new partition: could not get geometry for constraint."); return QString(); } @@ -281,7 +281,7 @@ bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& if (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length())) { if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) { if (PedGeometry* resizedGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), newLength)) { - PedTimer* pedTimer = ped_timer_new(pedTimerHandler, NULL); + PedTimer* pedTimer = ped_timer_new(pedTimerHandler, nullptr); rval = ped_file_system_resize(pedFileSystem, resizedGeometry, pedTimer); ped_timer_destroy(pedTimer); @@ -320,15 +320,15 @@ FileSystem::Type LibPartedPartitionTable::detectFileSystemBySector(Report& repor bool LibPartedPartitionTable::setPartitionSystemType(Report& report, const Partition& partition) { - PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? NULL : getPedFileSystemType(partition.fileSystem().type()); - if (pedFsType == NULL) { + PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type()); + if (pedFsType == nullptr) { report.line() << xi18nc("@info/plain", "Could not update the system type for partition %1.", partition.deviceNode()); report.line() << xi18nc("@info/plain", "No file system defined."); return false; } PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector()); - if (pedPartition == NULL) { + if (pedPartition == nullptr) { report.line() << xi18nc("@info/plain", "Could not update the system type for partition %1.", partition.deviceNode()); report.line() << xi18nc("@info/plain", "No partition found at sector %1.", partition.firstSector()); return false; diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp index f50971f..6ffaecc 100644 --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -31,7 +31,7 @@ @param args the arguments to pass to the command */ ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args) : - m_Report(NULL), + m_Report(nullptr), m_ExitCode(-1), m_Output() { @@ -60,7 +60,7 @@ ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStri @param args the vector of the arguments to pass to the commands */ ExternalCommand::ExternalCommand(const std::vector cmd, const std::vector args) : - m_Report(NULL), + m_Report(nullptr), m_Command(cmd), m_Args(args), m_ExitCode(-1), diff --git a/src/util/externalcommand.h b/src/util/externalcommand.h index ade3b7c..758c8c8 100644 --- a/src/util/externalcommand.h +++ b/src/util/externalcommand.h @@ -83,7 +83,7 @@ public: } Report* report() { - return m_Report; /**< @return pointer to the Report or NULL */ + return m_Report; /**< @return pointer to the Report or nullptr */ } protected: diff --git a/src/util/globallog.cpp b/src/util/globallog.cpp index ed9cf53..73ac63f 100644 --- a/src/util/globallog.cpp +++ b/src/util/globallog.cpp @@ -19,9 +19,9 @@ GlobalLog* GlobalLog::instance() { - static GlobalLog* p = NULL; + static GlobalLog* p = nullptr; - if (p == NULL) + if (p == nullptr) p = new GlobalLog(); return p; diff --git a/src/util/helpers.cpp b/src/util/helpers.cpp index 1673541..e4c3a52 100644 --- a/src/util/helpers.cpp +++ b/src/util/helpers.cpp @@ -59,7 +59,7 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree) QAction* action = headerMenu.exec(tree.header()->mapToGlobal(p)); - if (action != NULL) { + if (action != nullptr) { const bool hidden = !action->isChecked(); tree.setColumnHidden(action->data().toInt(), hidden); if (!hidden) diff --git a/src/util/report.cpp b/src/util/report.cpp index 40684f7..493d53c 100644 --- a/src/util/report.cpp +++ b/src/util/report.cpp @@ -27,7 +27,7 @@ #include /** Creates a new Report instance. - @param p pointer to the parent instance. May be NULL ig this is a new root Report. + @param p pointer to the parent instance. May be nullptr ig this is a new root Report. @param cmd the command */ Report::Report(Report* p, const QString& cmd) : @@ -67,7 +67,7 @@ QString Report::toHtml() const if (parent() == root()) s += QStringLiteral("
\n"); - else if (parent() != NULL) + else if (parent() != nullptr) s += QStringLiteral("
\n"); if (!command().isEmpty()) @@ -85,7 +85,7 @@ QString Report::toHtml() const if (!status().isEmpty()) s += QStringLiteral("") + status().toHtmlEscaped() + QStringLiteral("
\n\n"); - if (parent() != NULL) + if (parent() != nullptr) s += QStringLiteral("
\n\n"); return s; @@ -138,7 +138,7 @@ Report* Report::root() { Report* rval = this; - while (rval->parent() != NULL) + while (rval->parent() != nullptr) rval = rval->parent(); return rval; @@ -151,7 +151,7 @@ const Report* Report::root() const { const Report* rval = this; - while (rval->parent() != NULL) + while (rval->parent() != nullptr) rval = rval->parent(); return rval; diff --git a/src/util/report.h b/src/util/report.h index 795ea71..e0968b9 100644 --- a/src/util/report.h +++ b/src/util/report.h @@ -57,10 +57,10 @@ public: } Report* parent() { - return m_Parent; /**< @return pointer to this Reports parent. May be NULL if this is the root Report */ + return m_Parent; /**< @return pointer to this Reports parent. May be nullptr if this is the root Report */ } const Report* parent() const { - return m_Parent; /**< @return pointer to this Reports parent. May be NULL if this is the root Report */ + return m_Parent; /**< @return pointer to this Reports parent. May be nullptr if this is the root Report */ } Report* root();