Always use nullptr instead of NULL because it is type-safe.

This commit is contained in:
Teo Mrnjavac 2015-07-22 15:48:03 +02:00
parent c4bb654916
commit de27f840bf
43 changed files with 209 additions and 209 deletions

View File

@ -101,7 +101,7 @@ public:
/** /**
* Open a device for reading. * Open a device for reading.
* @param device_node The path of the device that is to be opened (e.g. /dev/sda) * @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 * an instance is returned, it's the caller's responsibility to delete the
* object. * object.
*/ */
@ -110,7 +110,7 @@ public:
/** /**
* Open a device in exclusive mode for writing. * 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) * @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 * an instance is returned, it's the caller's responsibility to delete the
* object. * object.
*/ */
@ -118,7 +118,7 @@ public:
/** /**
* Close a CoreBackendDevice that has previously been opened. * 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. * @return true if closing the CoreBackendDevice succeeded, otherwise false.
* *
* This method does not delete the object. * This method does not delete the object.

View File

@ -76,7 +76,7 @@ public:
/** /**
* Open this backend device's partition table * 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 * of errors
*/ */
virtual CoreBackendPartitionTable* openPartitionTable() = 0; virtual CoreBackendPartitionTable* openPartitionTable() = 0;

View File

@ -28,15 +28,15 @@
#include <KServiceTypeTrader> #include <KServiceTypeTrader>
CoreBackendManager::CoreBackendManager() : CoreBackendManager::CoreBackendManager() :
m_Backend(NULL) m_Backend(nullptr)
{ {
} }
CoreBackendManager* CoreBackendManager::self() CoreBackendManager* CoreBackendManager::self()
{ {
static CoreBackendManager* instance = NULL; static CoreBackendManager* instance = nullptr;
if (instance == NULL) if (instance == nullptr)
instance = new CoreBackendManager; instance = new CoreBackendManager;
return instance; return instance;
@ -57,8 +57,8 @@ bool CoreBackendManager::load(const QString& name)
KPluginFactory* factory = loader.factory(); KPluginFactory* factory = loader.factory();
if (factory != NULL) { if (factory != nullptr) {
m_Backend = factory->create<CoreBackend>(NULL); m_Backend = factory->create<CoreBackend>(nullptr);
QString id = loader.metaData().toVariantMap().value(QStringLiteral("MetaData")) QString id = loader.metaData().toVariantMap().value(QStringLiteral("MetaData"))
.toMap().value(QStringLiteral("KPlugin")).toMap().value(QStringLiteral("Id")).toString(); .toMap().value(QStringLiteral("KPlugin")).toMap().value(QStringLiteral("Id")).toString();
@ -80,5 +80,5 @@ bool CoreBackendManager::load(const QString& name)
void CoreBackendManager::unload() void CoreBackendManager::unload()
{ {
delete m_Backend; delete m_Backend;
m_Backend = NULL; m_Backend = nullptr;
} }

View File

@ -53,13 +53,13 @@ public:
virtual bool commit(quint32 timeout = 10) = 0; 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; virtual CoreBackendPartition* getExtendedPartition() = 0;
/** /**
* @param sector sector the partition occupies * @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; virtual CoreBackendPartition* getPartitionBySector(qint64 sector) = 0;

View File

@ -35,7 +35,7 @@ CopySourceDevice::CopySourceDevice(Device& d, qint64 firstsector, qint64 lastsec
m_Device(d), m_Device(d),
m_FirstSector(firstsector), m_FirstSector(firstsector),
m_LastSector(lastsector), m_LastSector(lastsector),
m_BackendDevice(NULL) m_BackendDevice(nullptr)
{ {
} }
@ -51,7 +51,7 @@ CopySourceDevice::~CopySourceDevice()
bool CopySourceDevice::open() bool CopySourceDevice::open()
{ {
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode()); m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode());
return m_BackendDevice != NULL; return m_BackendDevice != nullptr;
} }
/** Returns the Device's sector size /** Returns the Device's sector size

View File

@ -32,7 +32,7 @@
CopyTargetDevice::CopyTargetDevice(Device& d, qint64 firstsector, qint64 lastsector) : CopyTargetDevice::CopyTargetDevice(Device& d, qint64 firstsector, qint64 lastsector) :
CopyTarget(), CopyTarget(),
m_Device(d), m_Device(d),
m_BackendDevice(NULL), m_BackendDevice(nullptr),
m_FirstSector(firstsector), m_FirstSector(firstsector),
m_LastSector(lastsector) m_LastSector(lastsector)
{ {
@ -50,7 +50,7 @@ CopyTargetDevice::~CopyTargetDevice()
bool CopyTargetDevice::open() bool CopyTargetDevice::open()
{ {
m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode()); m_BackendDevice = CoreBackendManager::self()->backend()->openDeviceExclusive(device().deviceNode());
return m_BackendDevice != NULL; return m_BackendDevice != nullptr;
} }
/** @return the Device's sector size */ /** @return the Device's sector size */

View File

@ -83,7 +83,7 @@ Device::Device(const QString& name, const QString& devicenode, qint32 heads, qin
QObject(), QObject(),
m_Name(name.length() > 0 ? name : i18n("Unknown Device")), m_Name(name.length() > 0 ? name : i18n("Unknown Device")),
m_DeviceNode(devicenode), m_DeviceNode(devicenode),
m_PartitionTable(NULL), m_PartitionTable(nullptr),
m_Heads(heads), m_Heads(heads),
m_SectorsPerTrack(numSectors), m_SectorsPerTrack(numSectors),
m_Cylinders(cylinders), m_Cylinders(cylinders),

View File

@ -31,7 +31,7 @@
OperationRunner::OperationRunner(QObject* parent, OperationStack& ostack) : OperationRunner::OperationRunner(QObject* parent, OperationStack& ostack) :
QThread(parent), QThread(parent),
m_OperationStack(ostack), m_OperationStack(ostack),
m_Report(NULL), m_Report(nullptr),
m_SuspendMutex(), m_SuspendMutex(),
m_Cancelling(false) m_Cancelling(false)
{ {

View File

@ -93,7 +93,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
{ {
NewOperation* newOp = dynamic_cast<NewOperation*>(currentOp); NewOperation* newOp = dynamic_cast<NewOperation*>(currentOp);
if (newOp == NULL) if (newOp == nullptr)
return false; return false;
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp); DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(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."); Log() << i18nc("@info/plain", "Deleting a partition just created: Undoing the operation to create the partition.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = nullptr;
newOp->undo(); newOp->undo();
delete operations().takeAt(operations().indexOf(newOp)); delete operations().takeAt(operations().indexOf(newOp));
@ -166,7 +166,7 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
newOp->newPartition().fileSystem().setLabel(pushedLabelOp->newLabel()); newOp->newPartition().fileSystem().setLabel(pushedLabelOp->newLabel());
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = nullptr;
return true; return true;
} }
@ -180,10 +180,10 @@ bool OperationStack::mergeNewOperation(Operation*& currentOp, Operation*& pushed
newOp->newPartition().setFileSystem(FileSystemFactory::cloneWithNewType(pushedCreateFileSystemOp->newFileSystem()->type(), *oldFs)); newOp->newPartition().setFileSystem(FileSystemFactory::cloneWithNewType(pushedCreateFileSystemOp->newFileSystem()->type(), *oldFs));
delete oldFs; delete oldFs;
oldFs = NULL; oldFs = nullptr;
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = nullptr;
return true; 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."); Log() << i18nc("@info/plain", "Checking file systems is automatically done when creating them: No new operation required.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = nullptr;
return true; return true;
} }
@ -226,7 +226,7 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
{ {
CopyOperation* copyOp = dynamic_cast<CopyOperation*>(currentOp); CopyOperation* copyOp = dynamic_cast<CopyOperation*>(currentOp);
if (copyOp == NULL) if (copyOp == nullptr)
return false; return false;
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp); DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
@ -236,11 +236,11 @@ bool OperationStack::mergeCopyOperation(Operation*& currentOp, Operation*& pushe
if (pushedDeleteOp && &copyOp->copiedPartition() == &pushedDeleteOp->deletedPartition()) { if (pushedDeleteOp && &copyOp->copiedPartition() == &pushedDeleteOp->deletedPartition()) {
// If the copy operation didn't overwrite, but create a new partition, just remove the // If the copy operation didn't overwrite, but create a new partition, just remove the
// copy operation, forget the delete and be done. // 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."); Log() << i18nc("@info/plain", "Deleting a partition just copied: Removing the copy.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = nullptr;
} else { } else {
Log() << i18nc("@info/plain", "Deleting a partition just copied over an existing partition: Removing the copy and deleting the existing partition."); 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<RestoreOperation*>(currentOp); RestoreOperation* restoreOp = dynamic_cast<RestoreOperation*>(currentOp);
if (restoreOp == NULL) if (restoreOp == nullptr)
return false; return false;
DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp); DeleteOperation* pushedDeleteOp = dynamic_cast<DeleteOperation*>(pushedOp);
if (pushedDeleteOp && &restoreOp->restorePartition() == &pushedDeleteOp->deletedPartition()) { 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."); Log() << i18nc("@info/plain", "Deleting a partition just restored: Removing the restore operation.");
delete pushedOp; delete pushedOp;
pushedOp = NULL; pushedOp = nullptr;
} else { } else {
Log() << i18nc("@info/plain", "Deleting a partition just restored to an existing partition: Removing the restore operation and deleting the existing partition."); 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<SetPartFlagsOperation*>(currentOp); SetPartFlagsOperation* partFlagsOp = dynamic_cast<SetPartFlagsOperation*>(currentOp);
if (partFlagsOp == NULL) if (partFlagsOp == nullptr)
return false; return false;
SetPartFlagsOperation* pushedFlagsOp = dynamic_cast<SetPartFlagsOperation*>(pushedOp); SetPartFlagsOperation* pushedFlagsOp = dynamic_cast<SetPartFlagsOperation*>(pushedOp);
@ -347,7 +347,7 @@ bool OperationStack::mergePartLabelOperation(Operation*& currentOp, Operation*&
{ {
SetFileSystemLabelOperation* partLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(currentOp); SetFileSystemLabelOperation* partLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(currentOp);
if (partLabelOp == NULL) if (partLabelOp == nullptr)
return false; return false;
SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(pushedOp); SetFileSystemLabelOperation* pushedLabelOp = dynamic_cast<SetFileSystemLabelOperation*>(pushedOp);
@ -382,7 +382,7 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O
Log() << i18nc("@info/plain", "Creating new partition table, discarding previous operation on device."); Log() << i18nc("@info/plain", "Creating new partition table, discarding previous operation on device.");
CreatePartitionTableOperation* createPartitionTableOp = dynamic_cast<CreatePartitionTableOperation*>(currentOp); CreatePartitionTableOperation* createPartitionTableOp = dynamic_cast<CreatePartitionTableOperation*>(currentOp);
if (createPartitionTableOp != NULL) if (createPartitionTableOp != nullptr)
pushedCreatePartitionTableOp->setOldPartitionTable(createPartitionTableOp->oldPartitionTable()); pushedCreatePartitionTableOp->setOldPartitionTable(createPartitionTableOp->oldPartitionTable());
currentOp->undo(); currentOp->undo();
@ -401,7 +401,7 @@ bool OperationStack::mergeCreatePartitionTableOperation(Operation*& currentOp, O
Operation. Callers <b>must not rely</b> on the pushed Operation to exist after Operation. Callers <b>must not rely</b> on the pushed Operation to exist after
calling OperationStack::push(). 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) void OperationStack::push(Operation* o)
{ {
@ -427,14 +427,14 @@ void OperationStack::push(Operation* o)
break; break;
} }
if (o != NULL) { if (o != nullptr) {
Log() << i18nc("@info/plain", "Add operation: %1", o->description()); Log() << i18nc("@info/plain", "Add operation: %1", o->description());
operations().append(o); operations().append(o);
o->preview(); o->preview();
o->setStatus(Operation::StatusPending); 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. // have led to an existing operation changing.
emit operationsChanged(); emit operationsChanged();
} }
@ -473,14 +473,14 @@ void OperationStack::clearDevices()
/** Finds a Device a Partition is on. /** Finds a Device a Partition is on.
@param p pointer to the Partition to find a Device for @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) Device* OperationStack::findDeviceForPartition(const Partition* p)
{ {
QReadLocker lockDevices(&lock()); QReadLocker lockDevices(&lock());
foreach(Device * d, previewDevices()) { foreach(Device * d, previewDevices()) {
if (d->partitionTable() == NULL) if (d->partitionTable() == nullptr)
continue; continue;
foreach(const Partition * part, d->partitionTable()->children()) { 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 /** 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) void OperationStack::addDevice(Device* d)
{ {

View File

@ -51,7 +51,7 @@ public:
typedef QList<Operation*> Operations; typedef QList<Operation*> Operations;
public: public:
OperationStack(QObject* parent = NULL); OperationStack(QObject* parent = nullptr);
~OperationStack(); ~OperationStack();
Q_SIGNALS: Q_SIGNALS:

View File

@ -33,7 +33,7 @@
#include <KIOCore/KMountPoint> #include <KIOCore/KMountPoint>
/** Creates a new Partition object. /** 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 device the Device this Partition is on.
@param role the Partition's role(s) @param role the Partition's role(s)
@param fs pointer to the Partition's FileSystem object. The Partition object will take ownership of this. @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() void Partition::deleteFileSystem()
{ {
delete m_FileSystem; delete m_FileSystem;
m_FileSystem = NULL; m_FileSystem = nullptr;
} }
void Partition::setPartitionPath(const QString& s) void Partition::setPartitionPath(const QString& s)

View File

@ -24,7 +24,7 @@
/** Tries to find the predecessor for a Partition. /** Tries to find the predecessor for a Partition.
@param p the Partition to find a predecessor for @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) Partition* PartitionNode::predecessor(Partition& p)
{ {
@ -36,7 +36,7 @@ Partition* PartitionNode::predecessor(Partition& p)
if (plist[idx] == &p) if (plist[idx] == &p)
return plist[idx - 1]; return plist[idx - 1];
return NULL; return nullptr;
} }
/** /**
@ -52,12 +52,12 @@ const Partition* PartitionNode::predecessor(const Partition& p) const
if (plist[idx] == &p) if (plist[idx] == &p)
return plist[idx - 1]; return plist[idx - 1];
return NULL; return nullptr;
} }
/** Tries to find the successor for a Partition. /** Tries to find the successor for a Partition.
@param p the Partition to find a successor for @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) Partition* PartitionNode::successor(Partition& p)
{ {
@ -69,7 +69,7 @@ Partition* PartitionNode::successor(Partition& p)
if (plist[idx] == &p) if (plist[idx] == &p)
return plist[idx + 1]; return plist[idx + 1];
return NULL; return nullptr;
} }
/** /**
@ -85,16 +85,16 @@ const Partition* PartitionNode::successor(const Partition& p) const
if (plist[idx] == &p) if (plist[idx] == &p)
return plist[idx + 1]; return plist[idx + 1];
return NULL; return nullptr;
} }
/** Inserts a Partition into a PartitionNode's children /** 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 @return true on success
*/ */
bool PartitionNode::insert(Partition* p) bool PartitionNode::insert(Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
for (int idx = 0; idx < children().size(); idx++) { 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. /** 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. @return true on success.
*/ */
bool PartitionNode::remove(Partition* p) bool PartitionNode::remove(Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
if (children().removeOne(p)) if (children().removeOne(p))
@ -134,7 +134,7 @@ void PartitionNode::clearChildren()
/** Finds a Partition by sector. /** Finds a Partition by sector.
@param s the sector the Partition is at @param s the sector the Partition is at
@param role the PartitionRole the Partition is supposed to have @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) Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& role)
{ {
@ -148,7 +148,7 @@ Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionRole& r
return p; return p;
} }
return NULL; return nullptr;
} }
/** /**
@ -165,7 +165,7 @@ const Partition* PartitionNode::findPartitionBySector(qint64 s, const PartitionR
return p; return p;
} }
return NULL; return nullptr;
} }
/** Reparents a Partition to this PartitionNode /** Reparents a Partition to this PartitionNode

View File

@ -97,14 +97,14 @@ bool PartitionTable::hasExtended() const
return false; 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 Partition* PartitionTable::extended() const
{ {
for (int i = 0; i < children().size(); i++) for (int i = 0; i < children().size(); i++)
if (children()[i]->roles().has(PartitionRole::Extended)) if (children()[i]->roles().has(PartitionRole::Extended))
return children()[i]; return children()[i];
return NULL; return nullptr;
} }
/** Gets valid PartitionRoles for a Partition /** Gets valid PartitionRoles for a Partition
@ -136,7 +136,7 @@ int PartitionTable::numPrimaries() const
} }
/** Appends a Partition to this PartitionTable /** 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) void PartitionTable::append(Partition* partition)
{ {
@ -213,7 +213,7 @@ bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& pa
if (!parent.isRoot()) { if (!parent.isRoot()) {
Partition* extended = dynamic_cast<Partition*>(&parent); Partition* extended = dynamic_cast<Partition*>(&parent);
if (extended == NULL) { if (extended == nullptr) {
qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode(); qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode();
return false; return false;
} }
@ -236,7 +236,7 @@ bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& pa
@param parent the parent PartitionNode for the new Partition @param parent the parent PartitionNode for the new Partition
@param start the new Partition's start sector @param start the new Partition's start sector
@param end the new Partition's end 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) 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; r |= PartitionRole::Logical;
if (!PartitionTable::getUnallocatedRange(device, parent, start, end)) 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()); 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) void PartitionTable::removeUnallocated(PartitionNode* p)
{ {
Q_ASSERT(p != NULL); Q_ASSERT(p != nullptr);
qint32 i = 0; qint32 i = 0;
@ -298,7 +298,7 @@ void PartitionTable::removeUnallocated()
*/ */
void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64 start) const
{ {
Q_ASSERT(p != NULL); Q_ASSERT(p != nullptr);
qint64 lastEnd = start; qint64 lastEnd = start;
@ -317,8 +317,8 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64
if (!p->isRoot()) { if (!p->isRoot()) {
Partition* extended = dynamic_cast<Partition*>(p); Partition* extended = dynamic_cast<Partition*>(p);
Q_ASSERT(extended != NULL); Q_ASSERT(extended != nullptr);
parentEnd = (extended != NULL) ? extended->lastSector() : -1; parentEnd = (extended != nullptr) ? extended->lastSector() : -1;
} }
if (parentEnd >= firstUsable()) if (parentEnd >= firstUsable())

View File

@ -90,10 +90,10 @@ public:
public: public:
PartitionNode* parent() { PartitionNode* parent() {
return NULL; /**< @return always NULL for PartitionTable */ return nullptr; /**< @return always nullptr for PartitionTable */
} }
const PartitionNode* parent() const { const PartitionNode* parent() const {
return NULL; /**< @return always NULL for PartitionTable */ return nullptr; /**< @return always nullptr for PartitionTable */
} }
bool isRoot() const { bool isRoot() const {

View File

@ -46,7 +46,7 @@ SmartStatus::SmartStatus(const QString& device_path) :
void SmartStatus::update() void SmartStatus::update()
{ {
SkDisk* skDisk = NULL; SkDisk* skDisk = nullptr;
SkBool skSmartStatus = false; SkBool skSmartStatus = false;
uint64_t mkelvin = 0; uint64_t mkelvin = 0;
uint64_t skBadSectors = 0; uint64_t skBadSectors = 0;

View File

@ -148,7 +148,7 @@ bool fat16::create(Report& report, const QString& deviceNode) const
bool fat16::updateUUID(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]; char uuid[4];
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8) for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)

View File

@ -48,7 +48,7 @@ bool fat32::create(Report& report, const QString& deviceNode) const
bool fat32::updateUUID(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]; char uuid[4];
for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8) for (quint32 i = 0; i < sizeof(uuid); i++, t >>= 8)

View File

@ -87,11 +87,11 @@ static QString readBlkIdValue(const QString& deviceNode, const QString& tag)
blkid_cache cache; blkid_cache cache;
QString rval; QString rval;
if (blkid_get_cache(&cache, NULL) == 0) { if (blkid_get_cache(&cache, nullptr) == 0) {
blkid_dev dev; blkid_dev dev;
char* label = NULL; char* label = nullptr;
if ((dev = blkid_get_dev(cache, deviceNode.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != NULL && 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()))) { (label = blkid_get_tag_value(cache, tag.toLocal8Bit().constData(), deviceNode.toLocal8Bit().constData()))) {
rval = QString::fromUtf8(label); rval = QString::fromUtf8(label);
free(label); free(label);

View File

@ -116,11 +116,11 @@ void FileSystemFactory::init()
@param lastsector the FileSystem's last sector relative to the Device @param lastsector the FileSystem's last sector relative to the Device
@param sectorsused the number of used sectors in the FileSystem @param sectorsused the number of used sectors in the FileSystem
@param label the FileSystem's label @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* 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) { switch (t) {
case FileSystem::Btrfs: fs = new FS::btrfs(firstsector, lastsector, sectorsused, label); break; 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; default: break;
} }
if (fs != NULL) if (fs != nullptr)
fs->setUUID(uuid); fs->setUUID(uuid);
return fs; return fs;
@ -174,7 +174,7 @@ const FileSystemFactory::FileSystems& FileSystemFactory::map()
/** Clones a FileSystem from another one, but with a new type. /** Clones a FileSystem from another one, but with a new type.
@param newType the new FileSystem's type @param newType the new FileSystem's type
@param other the old FileSystem to clone @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) FileSystem* FileSystemFactory::cloneWithNewType(FileSystem::Type newType, const FileSystem& other)
{ {

View File

@ -44,9 +44,9 @@ const qint32 PartResizerWidget::m_HandleHeight = 59;
*/ */
PartResizerWidget::PartResizerWidget(QWidget* parent) : PartResizerWidget::PartResizerWidget(QWidget* parent) :
QWidget(parent), QWidget(parent),
m_Device(NULL), m_Device(nullptr),
m_Partition(NULL), m_Partition(nullptr),
m_PartWidget(NULL), m_PartWidget(nullptr),
m_MinimumFirstSector(0), m_MinimumFirstSector(0),
m_MaximumFirstSector(-1), m_MaximumFirstSector(-1),
m_MinimumLastSector(-1), m_MinimumLastSector(-1),
@ -55,7 +55,7 @@ PartResizerWidget::PartResizerWidget(QWidget* parent) :
m_MaximumLength(-1), m_MaximumLength(-1),
m_LeftHandle(this), m_LeftHandle(this),
m_RightHandle(this), m_RightHandle(this),
m_DraggedWidget(NULL), m_DraggedWidget(nullptr),
m_Hotspot(0), m_Hotspot(0),
m_MoveAllowed(true), m_MoveAllowed(true),
m_ReadOnly(false), m_ReadOnly(false),
@ -187,7 +187,7 @@ void PartResizerWidget::mousePressEvent(QMouseEvent* event)
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
m_DraggedWidget = static_cast<QWidget*>(childAt(event->pos())); m_DraggedWidget = static_cast<QWidget*>(childAt(event->pos()));
if (m_DraggedWidget != NULL) { if (m_DraggedWidget != nullptr) {
if (partWidget().isAncestorOf(m_DraggedWidget)) if (partWidget().isAncestorOf(m_DraggedWidget))
m_DraggedWidget = &partWidget(); m_DraggedWidget = &partWidget();
@ -298,7 +298,7 @@ void PartResizerWidget::mouseMoveEvent(QMouseEvent* event)
void PartResizerWidget::mouseReleaseEvent(QMouseEvent* event) void PartResizerWidget::mouseReleaseEvent(QMouseEvent* event)
{ {
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
m_DraggedWidget = NULL; m_DraggedWidget = nullptr;
} }
bool PartResizerWidget::updateFirstSector(qint64 newFirstSector) bool PartResizerWidget::updateFirstSector(qint64 newFirstSector)
@ -444,7 +444,7 @@ void PartResizerWidget::setMoveAllowed(bool b)
{ {
m_MoveAllowed = b; m_MoveAllowed = b;
if (m_PartWidget != NULL) if (m_PartWidget != nullptr)
partWidget().setCursor(b ? Qt::SizeAllCursor : Qt::ArrowCursor); partWidget().setCursor(b ? Qt::SizeAllCursor : Qt::ArrowCursor);
} }

View File

@ -28,11 +28,11 @@
/** Creates a new PartWidget /** Creates a new PartWidget
@param parent pointer to the parent widget @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) : PartWidget::PartWidget(QWidget* parent, const Partition* p) :
PartWidgetBase(parent), PartWidgetBase(parent),
m_Partition(NULL), m_Partition(nullptr),
m_Active(false) m_Active(false)
{ {
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
@ -59,7 +59,7 @@ void PartWidget::updateChildren()
foreach(QWidget * w, childWidgets()) { foreach(QWidget * w, childWidgets()) {
w->setVisible(false); w->setVisible(false);
w->deleteLater(); w->deleteLater();
w->setParent(NULL); w->setParent(nullptr);
} }
foreach(const Partition * child, partition()->children()) { foreach(const Partition * child, partition()->children()) {
@ -90,7 +90,7 @@ QColor PartWidget::activeColor(const QColor& col) const
void PartWidget::paintEvent(QPaintEvent*) void PartWidget::paintEvent(QPaintEvent*)
{ {
if (partition() == NULL) if (partition() == nullptr)
return; return;
const int usedPercentage = partition()->used() * 100 / partition()->capacity(); const int usedPercentage = partition()->used() * 100 / partition()->capacity();

View File

@ -44,7 +44,7 @@ class LIBKPMCORE_EXPORT PartWidget : public PartWidgetBase
Q_OBJECT Q_OBJECT
public: public:
explicit PartWidget(QWidget* parent, const Partition* p = NULL); explicit PartWidget(QWidget* parent, const Partition* p = nullptr);
public: public:
void init(const Partition* p); void init(const Partition* p);

View File

@ -45,7 +45,7 @@ bool CreatePartitionTableJob::run(Report& parent)
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode()); CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
if (backendDevice != NULL) { if (backendDevice != nullptr) {
Q_ASSERT(device().partitionTable()); Q_ASSERT(device().partitionTable());
rval = backendDevice->createPartitionTable(*report, *device().partitionTable()); rval = backendDevice->createPartitionTable(*report, *device().partitionTable());

View File

@ -49,12 +49,12 @@ QString BackupOperation::description() const
} }
/** Can the given Partition be backed up? /** 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. @return true if @p p can be backed up.
*/ */
bool BackupOperation::canBackup(const Partition* p) bool BackupOperation::canBackup(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
if (p->isMounted()) if (p->isMounted())

View File

@ -60,12 +60,12 @@ QString CheckOperation::description() const
} }
/** Can a Partition be checked? /** 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. @return true if @p p can be checked.
*/ */
bool CheckOperation::canCheck(const Partition* p) bool CheckOperation::canCheck(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
if (p->isMounted()) if (p->isMounted())

View File

@ -38,9 +38,9 @@
/** Creates a new CopyOperation. /** Creates a new CopyOperation.
@param targetdevice the Device to copy the Partition to @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 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) : CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, Device& sourcedevice, Partition* sourcepartition) :
Operation(), Operation(),
@ -48,13 +48,13 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D
m_CopiedPartition(copiedpartition), m_CopiedPartition(copiedpartition),
m_SourceDevice(sourcedevice), m_SourceDevice(sourcedevice),
m_SourcePartition(sourcepartition), m_SourcePartition(sourcepartition),
m_OverwrittenPartition(NULL), m_OverwrittenPartition(nullptr),
m_MustDeleteOverwritten(false), m_MustDeleteOverwritten(false),
m_CheckSourceJob(NULL), m_CheckSourceJob(nullptr),
m_CreatePartitionJob(NULL), m_CreatePartitionJob(nullptr),
m_CopyFSJob(NULL), m_CopyFSJob(nullptr),
m_CheckTargetJob(NULL), m_CheckTargetJob(nullptr),
m_MaximizeJob(NULL), m_MaximizeJob(nullptr),
m_Description(updateDescription()) m_Description(updateDescription())
{ {
Q_ASSERT(targetDevice().partitionTable()); Q_ASSERT(targetDevice().partitionTable());
@ -63,7 +63,7 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D
Q_ASSERT(dest); Q_ASSERT(dest);
if (dest == NULL) if (dest == nullptr)
qWarning() << "destination partition not found at sector " << copiedPartition().firstSector(); qWarning() << "destination partition not found at sector " << copiedPartition().firstSector();
if (dest && !dest->roles().has(PartitionRole::Unallocated)) { if (dest && !dest->roles().has(PartitionRole::Unallocated)) {
@ -73,7 +73,7 @@ CopyOperation::CopyOperation(Device& targetdevice, Partition* copiedpartition, D
addJob(m_CheckSourceJob = new CheckFileSystemJob(sourcePartition())); addJob(m_CheckSourceJob = new CheckFileSystemJob(sourcePartition()));
if (overwrittenPartition() == NULL) if (overwrittenPartition() == nullptr)
addJob(m_CreatePartitionJob = new CreatePartitionJob(targetDevice(), copiedPartition())); addJob(m_CreatePartitionJob = new CreatePartitionJob(targetDevice(), copiedPartition()));
addJob(m_CopyFSJob = new CopyFileSystemJob(targetDevice(), copiedPartition(), sourceDevice(), sourcePartition())); addJob(m_CopyFSJob = new CopyFileSystemJob(targetDevice(), copiedPartition(), sourceDevice(), sourcePartition()));
@ -243,7 +243,7 @@ void CopyOperation::cleanupOverwrittenPartition()
{ {
if (mustDeleteOverwritten()) { if (mustDeleteOverwritten()) {
delete overwrittenPartition(); 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? /** 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. @return true if @p p can be copied.
*/ */
bool CopyOperation::canCopy(const Partition* p) bool CopyOperation::canCopy(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
if (p->isMounted()) if (p->isMounted())
@ -291,13 +291,13 @@ bool CopyOperation::canCopy(const Partition* p)
} }
/** Can a Partition be pasted on another one? /** Can a Partition be pasted on another one?
@param p the Partition to be pasted to, may be NULL @param p the Partition to be pasted to, may be nullptr
@param source the Partition to be pasted, may be NULL @param source the Partition to be pasted, may be nullptr
@return true if @p source can be pasted on @p p @return true if @p source can be pasted on @p p
*/ */
bool CopyOperation::canPaste(const Partition* p, const Partition* source) bool CopyOperation::canPaste(const Partition* p, const Partition* source)
{ {
if (p == NULL || source == NULL) if (p == nullptr || source == nullptr)
return false; return false;
if (p->isMounted()) if (p->isMounted())

View File

@ -87,12 +87,12 @@ bool CreatePartitionTableOperation::execute(Report& parent)
} }
/** Can a new partition table be created on a device? /** 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 @return true if a new partition table can be created on @p device
*/ */
bool CreatePartitionTableOperation::canCreate(const Device* 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 QString CreatePartitionTableOperation::description() const

View File

@ -33,7 +33,7 @@
/** Creates a new DeleteOperation /** Creates a new DeleteOperation
@param d the Device to delete a Partition on @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) : DeleteOperation::DeleteOperation(Device& d, Partition* p, ShredAction shred) :
Operation(), Operation(),
@ -103,12 +103,12 @@ void DeleteOperation::checkAdjustLogicalNumbers(Partition& p, bool undo)
} }
/** Can a Partition be deleted? /** 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. @return true if @p p can be deleted.
*/ */
bool DeleteOperation::canDelete(const Partition* p) bool DeleteOperation::canDelete(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
if (p->isMounted()) if (p->isMounted())

View File

@ -38,17 +38,17 @@
/** Creates a new NewOperation. /** Creates a new NewOperation.
@param d the Device to create a new Partition on @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) : NewOperation::NewOperation(Device& d, Partition* p) :
Operation(), Operation(),
m_TargetDevice(d), m_TargetDevice(d),
m_NewPartition(p), m_NewPartition(p),
m_CreatePartitionJob(new CreatePartitionJob(targetDevice(), newPartition())), m_CreatePartitionJob(new CreatePartitionJob(targetDevice(), newPartition())),
m_CreateFileSystemJob(NULL), m_CreateFileSystemJob(nullptr),
m_SetPartFlagsJob(NULL), m_SetPartFlagsJob(nullptr),
m_SetFileSystemLabelJob(NULL), m_SetFileSystemLabelJob(nullptr),
m_CheckFileSystemJob(NULL) m_CheckFileSystemJob(nullptr)
{ {
addJob(createPartitionJob()); addJob(createPartitionJob());
@ -109,12 +109,12 @@ QString NewOperation::description() const
} }
/** Can a Partition be created somewhere? /** 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 @return true if a new Partition can be created in @p p
*/ */
bool NewOperation::canCreateNew(const Partition* 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, Partition* NewOperation::createNew(const Partition& cloneFrom,

View File

@ -53,14 +53,14 @@ ResizeOperation::ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint6
m_NewFirstSector(newfirst), m_NewFirstSector(newfirst),
m_NewLastSector(newlast), m_NewLastSector(newlast),
m_CheckOriginalJob(new CheckFileSystemJob(partition())), m_CheckOriginalJob(new CheckFileSystemJob(partition())),
m_MoveExtendedJob(NULL), m_MoveExtendedJob(nullptr),
m_ShrinkResizeJob(NULL), m_ShrinkResizeJob(nullptr),
m_ShrinkSetGeomJob(NULL), m_ShrinkSetGeomJob(nullptr),
m_MoveSetGeomJob(NULL), m_MoveSetGeomJob(nullptr),
m_MoveFileSystemJob(NULL), m_MoveFileSystemJob(nullptr),
m_GrowResizeJob(NULL), m_GrowResizeJob(nullptr),
m_GrowSetGeomJob(NULL), m_GrowSetGeomJob(nullptr),
m_CheckResizedJob(NULL) m_CheckResizedJob(nullptr)
{ {
addJob(checkOriginalJob()); addJob(checkOriginalJob());
@ -313,12 +313,12 @@ bool ResizeOperation::grow(Report& report)
} }
/** Can a Partition be grown, i.e. increased in size? /** 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. @return true if @p p can be grown.
*/ */
bool ResizeOperation::canGrow(const Partition* p) bool ResizeOperation::canGrow(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
// we can always grow, shrink or move a partition not yet written to disk // 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? /** 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. @return true if @p p can be shrunk.
*/ */
bool ResizeOperation::canShrink(const Partition* p) bool ResizeOperation::canShrink(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
// we can always grow, shrink or move a partition not yet written to disk // 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? /** 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. @return true if @p p can be moved.
*/ */
bool ResizeOperation::canMove(const Partition* p) bool ResizeOperation::canMove(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
// we can always grow, shrink or move a partition not yet written to disk // we can always grow, shrink or move a partition not yet written to disk

View File

@ -42,7 +42,7 @@
/** Creates a new RestoreOperation. /** Creates a new RestoreOperation.
@param d the Device to restore the Partition to @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 @param filename name of the image file to restore from
*/ */
RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filename) : 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_TargetDevice(d),
m_RestorePartition(p), m_RestorePartition(p),
m_FileName(filename), m_FileName(filename),
m_OverwrittenPartition(NULL), m_OverwrittenPartition(nullptr),
m_MustDeleteOverwritten(false), m_MustDeleteOverwritten(false),
m_ImageLength(QFileInfo(filename).size() / 512), // 512 being the "sector size" of an image file. m_ImageLength(QFileInfo(filename).size() / 512), // 512 being the "sector size" of an image file.
m_CreatePartitionJob(NULL), m_CreatePartitionJob(nullptr),
m_RestoreJob(NULL), m_RestoreJob(nullptr),
m_CheckTargetJob(NULL), m_CheckTargetJob(nullptr),
m_MaximizeJob(NULL) m_MaximizeJob(nullptr)
{ {
restorePartition().setState(Partition::StateRestore); restorePartition().setState(Partition::StateRestore);
@ -66,7 +66,7 @@ RestoreOperation::RestoreOperation(Device& d, Partition* p, const QString& filen
Q_ASSERT(dest); Q_ASSERT(dest);
if (dest == NULL) if (dest == nullptr)
qWarning() << "destination partition not found at sector " << restorePartition().firstSector(); qWarning() << "destination partition not found at sector " << restorePartition().firstSector();
if (dest && !dest->roles().has(PartitionRole::Unallocated)) { if (dest && !dest->roles().has(PartitionRole::Unallocated)) {
@ -178,17 +178,17 @@ void RestoreOperation::cleanupOverwrittenPartition()
{ {
if (mustDeleteOverwritten()) { if (mustDeleteOverwritten()) {
delete overwrittenPartition(); delete overwrittenPartition();
m_OverwrittenPartition = NULL; m_OverwrittenPartition = nullptr;
} }
} }
/** Can a Partition be restored to somewhere? /** 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. @return true if a Partition can be restored to @p p.
*/ */
bool RestoreOperation::canRestore(const Partition* p) bool RestoreOperation::canRestore(const Partition* p)
{ {
if (p == NULL) if (p == nullptr)
return false; return false;
if (p->isMounted()) if (p->isMounted())
@ -215,7 +215,7 @@ Partition* RestoreOperation::createRestorePartition(const Device& device, Partit
QFileInfo fileInfo(filename); QFileInfo fileInfo(filename);
if (!fileInfo.exists()) if (!fileInfo.exists())
return NULL; return nullptr;
const qint64 end = start + fileInfo.size() / device.logicalSectorSize() - 1; 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()); Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString());

View File

@ -72,9 +72,9 @@ CoreBackendDevice* DummyBackend::openDevice(const QString& device_node)
{ {
DummyDevice* device = new DummyDevice(device_node); DummyDevice* device = new DummyDevice(device_node);
if (device == NULL || !device->open()) { if (device == nullptr || !device->open()) {
delete device; delete device;
device = NULL; device = nullptr;
} }
return device; return device;
@ -84,9 +84,9 @@ CoreBackendDevice* DummyBackend::openDeviceExclusive(const QString& device_node)
{ {
DummyDevice* device = new DummyDevice(device_node); DummyDevice* device = new DummyDevice(device_node);
if (device == NULL || !device->openExclusive()) { if (device == nullptr || !device->openExclusive()) {
delete device; delete device;
device = NULL; device = nullptr;
} }
return device; return device;

View File

@ -51,9 +51,9 @@ CoreBackendPartitionTable* DummyDevice::openPartitionTable()
{ {
CoreBackendPartitionTable* ptable = new DummyPartitionTable(); CoreBackendPartitionTable* ptable = new DummyPartitionTable();
if (ptable == NULL || !ptable->open()) { if (ptable == nullptr || !ptable->open()) {
delete ptable; delete ptable;
ptable = NULL; ptable = nullptr;
} }
return ptable; return ptable;

View File

@ -299,7 +299,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice*, Device& d, PedDisk* pedD
Q_ASSERT(pedDisk); Q_ASSERT(pedDisk);
Q_ASSERT(d.partitionTable()); Q_ASSERT(d.partitionTable());
PedPartition* pedPartition = NULL; PedPartition* pedPartition = nullptr;
KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName); KMountPoint::List mountPoints = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName);
mountPoints.append(KMountPoint::possibleMountPoints(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)); PartitionNode* parent = d.partitionTable()->findPartitionBySector(pedPartition->geom.start, PartitionRole(PartitionRole::Extended));
// None found, so it's a primary in the device's partition table. // None found, so it's a primary in the device's partition table.
if (parent == NULL) if (parent == nullptr)
parent = d.partitionTable(); parent = d.partitionTable();
const QString node = QString::fromUtf8(ped_partition_get_path(pedPartition)); 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()); 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 <filename>%1</filename>", device_node); Log(Log::warning) << xi18nc("@info/plain", "Could not access device <filename>%1</filename>", device_node);
return NULL; return nullptr;
} }
Log(Log::information) << i18nc("@info/plain", "Device found: %1", QString::fromUtf8(pedDevice->model)); Log(Log::information) << i18nc("@info/plain", "Device found: %1", QString::fromUtf8(pedDevice->model));
@ -412,7 +412,7 @@ QList<Device*> LibPartedBackend::scanDevices()
QList<Device*> result; QList<Device*> result;
ped_device_probe_all(); ped_device_probe_all();
PedDevice* pedDevice = NULL; PedDevice* pedDevice = nullptr;
QVector<QString> path; QVector<QString> path;
quint32 totalDevices = 0; quint32 totalDevices = 0;
while (true) { while (true) {
@ -438,9 +438,9 @@ CoreBackendDevice* LibPartedBackend::openDevice(const QString& device_node)
{ {
LibPartedDevice* device = new LibPartedDevice(device_node); LibPartedDevice* device = new LibPartedDevice(device_node);
if (device == NULL || !device->open()) { if (device == nullptr || !device->open()) {
delete device; delete device;
device = NULL; device = nullptr;
} }
return device; return device;
@ -450,9 +450,9 @@ CoreBackendDevice* LibPartedBackend::openDeviceExclusive(const QString& device_n
{ {
LibPartedDevice* device = new LibPartedDevice(device_node); LibPartedDevice* device = new LibPartedDevice(device_node);
if (device == NULL || !device->openExclusive()) { if (device == nullptr || !device->openExclusive()) {
delete device; delete device;
device = NULL; device = nullptr;
} }
return device; return device;
@ -464,8 +464,8 @@ bool LibPartedBackend::closeDevice(CoreBackendDevice* core_device)
} }
/** Detects the type of a FileSystem given a PedDevice and a PedPartition /** Detects the type of a FileSystem given a PedDevice and a PedPartition
@param pedDevice pointer to the pedDevice. Must not be NULL. @param pedDevice pointer to the pedDevice. Must not be nullptr.
@param pedPartition pointer to the pedPartition. Must not be NULL @param pedPartition pointer to the pedPartition. Must not be nullptr
@return the detected FileSystem type (FileSystem::Unknown if not detected) @return the detected FileSystem type (FileSystem::Unknown if not detected)
*/ */
FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition) FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
@ -473,12 +473,12 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
FileSystem::Type rval = FileSystem::Unknown; FileSystem::Type rval = FileSystem::Unknown;
blkid_cache cache; 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; 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)); QString s = QString::fromUtf8(blkid_get_tag_value(cache, "TYPE", pedPath));
if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2; 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("hfs")) rval = FileSystem::Hfs;
else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus; else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus;
else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs; 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 // libblkid does not distinguish between fat16 and fat32, so we're still using libparted
// for those // for those
if (strcmp(pedPartition->fs_type->name, "fat16") == 0) if (strcmp(pedPartition->fs_type->name, "fat16") == 0)

View File

@ -29,7 +29,7 @@
LibPartedDevice::LibPartedDevice(const QString& device_node) : LibPartedDevice::LibPartedDevice(const QString& device_node) :
CoreBackendDevice(device_node), CoreBackendDevice(device_node),
m_PedDevice(NULL) m_PedDevice(nullptr)
{ {
} }
@ -41,14 +41,14 @@ LibPartedDevice::~LibPartedDevice()
bool LibPartedDevice::open() bool LibPartedDevice::open()
{ {
Q_ASSERT(pedDevice() == NULL); Q_ASSERT(pedDevice() == nullptr);
if (pedDevice()) if (pedDevice())
return false; return false;
m_PedDevice = ped_device_get(deviceNode().toLatin1().constData()); m_PedDevice = ped_device_get(deviceNode().toLatin1().constData());
return m_PedDevice != NULL; return m_PedDevice != nullptr;
} }
bool LibPartedDevice::openExclusive() bool LibPartedDevice::openExclusive()
@ -70,7 +70,7 @@ bool LibPartedDevice::close()
setExclusive(false); setExclusive(false);
} }
m_PedDevice = NULL; m_PedDevice = nullptr;
return true; return true;
} }
@ -78,9 +78,9 @@ CoreBackendPartitionTable* LibPartedDevice::openPartitionTable()
{ {
CoreBackendPartitionTable* ptable = new LibPartedPartitionTable(pedDevice()); CoreBackendPartitionTable* ptable = new LibPartedPartitionTable(pedDevice());
if (ptable == NULL || !ptable->open()) { if (ptable == nullptr || !ptable->open()) {
delete ptable; delete ptable;
ptable = NULL; ptable = nullptr;
} }
return ptable; return ptable;
@ -90,21 +90,21 @@ bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable&
{ {
PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLatin1().constData()); 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 <filename>%2</filename>.", ptable.typeName(), deviceNode()); report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not retrieve partition table type \"%1\" for <filename>%2</filename>.", ptable.typeName(), deviceNode());
return false; return false;
} }
PedDevice* dev = ped_device_get(deviceNode().toLatin1().constData()); 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 <filename>%1</filename>.", deviceNode()); report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not open backend device <filename>%1</filename>.", deviceNode());
return false; return false;
} }
PedDisk* disk = ped_disk_new_fresh(dev, pedDiskType); 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 <filename>%1</filename>.", deviceNode()); report.line() << xi18nc("@info/plain", "Creating partition table failed: Could not create a new partition table in the backend for device <filename>%1</filename>.", deviceNode());
return false; return false;
} }

View File

@ -30,7 +30,7 @@ LibPartedPartition::LibPartedPartition(PedPartition* ped_partition) :
bool LibPartedPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state) bool LibPartedPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state)
{ {
Q_ASSERT(pedPartition() != NULL); Q_ASSERT(pedPartition() != nullptr);
const PedPartitionFlag f = LibPartedBackend::getPedFlag(partitionManagerFlag); const PedPartitionFlag f = LibPartedBackend::getPedFlag(partitionManagerFlag);

View File

@ -37,13 +37,13 @@
LibPartedPartitionTable::LibPartedPartitionTable(PedDevice* device) : LibPartedPartitionTable::LibPartedPartitionTable(PedDevice* device) :
CoreBackendPartitionTable(), CoreBackendPartitionTable(),
m_PedDevice(device), m_PedDevice(device),
m_PedDisk(NULL) m_PedDisk(nullptr)
{ {
} }
LibPartedPartitionTable::~LibPartedPartitionTable() LibPartedPartitionTable::~LibPartedPartitionTable()
{ {
if (m_PedDisk != NULL) if (m_PedDisk != nullptr)
ped_disk_destroy(m_PedDisk); ped_disk_destroy(m_PedDisk);
} }
@ -51,7 +51,7 @@ bool LibPartedPartitionTable::open()
{ {
m_PedDisk = ped_disk_new(pedDevice()); m_PedDisk = ped_disk_new(pedDevice());
return m_PedDisk != NULL; return m_PedDisk != nullptr;
} }
bool LibPartedPartitionTable::commit(quint32 timeout) bool LibPartedPartitionTable::commit(quint32 timeout)
@ -61,7 +61,7 @@ bool LibPartedPartitionTable::commit(quint32 timeout)
bool LibPartedPartitionTable::commit(PedDisk* pd, quint32 timeout) bool LibPartedPartitionTable::commit(PedDisk* pd, quint32 timeout)
{ {
if (pd == NULL) if (pd == nullptr)
return false; return false;
bool rval = ped_disk_commit_to_dev(pd); bool rval = ped_disk_commit_to_dev(pd);
@ -91,8 +91,8 @@ CoreBackendPartition* LibPartedPartitionTable::getExtendedPartition()
{ {
PedPartition* pedPartition = ped_disk_extended_partition(pedDisk()); PedPartition* pedPartition = ped_disk_extended_partition(pedDisk());
if (pedPartition == NULL) if (pedPartition == nullptr)
return NULL; return nullptr;
return new LibPartedPartition(pedPartition); return new LibPartedPartition(pedPartition);
} }
@ -101,8 +101,8 @@ CoreBackendPartition* LibPartedPartitionTable::getPartitionBySector(qint64 secto
{ {
PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), sector); PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), sector);
if (pedPartition == NULL) if (pedPartition == nullptr)
return NULL; return nullptr;
return new LibPartedPartition(pedPartition); return new LibPartedPartition(pedPartition);
} }
@ -146,7 +146,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition
QString rval = QString(); 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 // it's a typedef for an enum. So let's use something the libparted devs will hopefully never
// use... // use...
PedPartitionType pedType = static_cast<PedPartitionType>(0xffffffff); PedPartitionType pedType = static_cast<PedPartitionType>(0xffffffff);
@ -163,22 +163,22 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition
return QString(); 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()); 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 <filename>%1</filename>.", partition.deviceNode()); report.line() << xi18nc("@info/plain", "Failed to create new partition <filename>%1</filename>.", partition.deviceNode());
return QString(); return QString();
} }
PedConstraint* pedConstraint = NULL; PedConstraint* pedConstraint = nullptr;
PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition.firstSector(), partition.length()); PedGeometry* pedGeometry = ped_geometry_new(pedDevice(), partition.firstSector(), partition.length());
if (pedGeometry) if (pedGeometry)
pedConstraint = ped_constraint_exact(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."); report.line() << i18nc("@info/plain", "Failed to create a new partition: could not get geometry for constraint.");
return QString(); 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 (PedGeometry* originalGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), partition.fileSystem().length())) {
if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) { if (PedFileSystem* pedFileSystem = ped_file_system_open(originalGeometry)) {
if (PedGeometry* resizedGeometry = ped_geometry_new(pedDevice(), partition.fileSystem().firstSector(), newLength)) { 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); rval = ped_file_system_resize(pedFileSystem, resizedGeometry, pedTimer);
ped_timer_destroy(pedTimer); ped_timer_destroy(pedTimer);
@ -320,15 +320,15 @@ FileSystem::Type LibPartedPartitionTable::detectFileSystemBySector(Report& repor
bool LibPartedPartitionTable::setPartitionSystemType(Report& report, const Partition& partition) 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()); PedFileSystemType* pedFsType = (partition.roles().has(PartitionRole::Extended) || partition.fileSystem().type() == FileSystem::Unformatted) ? nullptr : getPedFileSystemType(partition.fileSystem().type());
if (pedFsType == NULL) { if (pedFsType == nullptr) {
report.line() << xi18nc("@info/plain", "Could not update the system type for partition <filename>%1</filename>.", partition.deviceNode()); report.line() << xi18nc("@info/plain", "Could not update the system type for partition <filename>%1</filename>.", partition.deviceNode());
report.line() << xi18nc("@info/plain", "No file system defined."); report.line() << xi18nc("@info/plain", "No file system defined.");
return false; return false;
} }
PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector()); 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 <filename>%1</filename>.", partition.deviceNode()); report.line() << xi18nc("@info/plain", "Could not update the system type for partition <filename>%1</filename>.", partition.deviceNode());
report.line() << xi18nc("@info/plain", "No partition found at sector %1.", partition.firstSector()); report.line() << xi18nc("@info/plain", "No partition found at sector %1.", partition.firstSector());
return false; return false;

View File

@ -31,7 +31,7 @@
@param args the arguments to pass to the command @param args the arguments to pass to the command
*/ */
ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args) : ExternalCommand::ExternalCommand(const QString& cmd, const QStringList& args) :
m_Report(NULL), m_Report(nullptr),
m_ExitCode(-1), m_ExitCode(-1),
m_Output() 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 @param args the vector of the arguments to pass to the commands
*/ */
ExternalCommand::ExternalCommand(const std::vector<QString> cmd, const std::vector<QStringList> args) : ExternalCommand::ExternalCommand(const std::vector<QString> cmd, const std::vector<QStringList> args) :
m_Report(NULL), m_Report(nullptr),
m_Command(cmd), m_Command(cmd),
m_Args(args), m_Args(args),
m_ExitCode(-1), m_ExitCode(-1),

View File

@ -83,7 +83,7 @@ public:
} }
Report* report() { Report* report() {
return m_Report; /**< @return pointer to the Report or NULL */ return m_Report; /**< @return pointer to the Report or nullptr */
} }
protected: protected:

View File

@ -19,9 +19,9 @@
GlobalLog* GlobalLog::instance() GlobalLog* GlobalLog::instance()
{ {
static GlobalLog* p = NULL; static GlobalLog* p = nullptr;
if (p == NULL) if (p == nullptr)
p = new GlobalLog(); p = new GlobalLog();
return p; return p;

View File

@ -59,7 +59,7 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree)
QAction* action = headerMenu.exec(tree.header()->mapToGlobal(p)); QAction* action = headerMenu.exec(tree.header()->mapToGlobal(p));
if (action != NULL) { if (action != nullptr) {
const bool hidden = !action->isChecked(); const bool hidden = !action->isChecked();
tree.setColumnHidden(action->data().toInt(), hidden); tree.setColumnHidden(action->data().toInt(), hidden);
if (!hidden) if (!hidden)

View File

@ -27,7 +27,7 @@
#include <unistd.h> #include <unistd.h>
/** Creates a new Report instance. /** 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 @param cmd the command
*/ */
Report::Report(Report* p, const QString& cmd) : Report::Report(Report* p, const QString& cmd) :
@ -67,7 +67,7 @@ QString Report::toHtml() const
if (parent() == root()) if (parent() == root())
s += QStringLiteral("<div>\n"); s += QStringLiteral("<div>\n");
else if (parent() != NULL) else if (parent() != nullptr)
s += QStringLiteral("<div style='margin-left:24px;margin-top:12px;margin-bottom:12px'>\n"); s += QStringLiteral("<div style='margin-left:24px;margin-top:12px;margin-bottom:12px'>\n");
if (!command().isEmpty()) if (!command().isEmpty())
@ -85,7 +85,7 @@ QString Report::toHtml() const
if (!status().isEmpty()) if (!status().isEmpty())
s += QStringLiteral("<b>") + status().toHtmlEscaped() + QStringLiteral("</b><br/>\n\n"); s += QStringLiteral("<b>") + status().toHtmlEscaped() + QStringLiteral("</b><br/>\n\n");
if (parent() != NULL) if (parent() != nullptr)
s += QStringLiteral("</div>\n\n"); s += QStringLiteral("</div>\n\n");
return s; return s;
@ -138,7 +138,7 @@ Report* Report::root()
{ {
Report* rval = this; Report* rval = this;
while (rval->parent() != NULL) while (rval->parent() != nullptr)
rval = rval->parent(); rval = rval->parent();
return rval; return rval;
@ -151,7 +151,7 @@ const Report* Report::root() const
{ {
const Report* rval = this; const Report* rval = this;
while (rval->parent() != NULL) while (rval->parent() != nullptr)
rval = rval->parent(); rval = rval->parent();
return rval; return rval;

View File

@ -57,10 +57,10 @@ public:
} }
Report* parent() { 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 { 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(); Report* root();