Cleanup and constantify

Cette révision appartient à :
Shubham Jangra 2019-05-23 16:35:27 +05:30
Parent a7532d4041
révision 41b3b83335
5 fichiers modifiés avec 36 ajouts et 44 suppressions

Voir le fichier

@ -69,22 +69,19 @@ int main( int argc, char **argv )
QCoreApplication app(argc, argv);
std::unique_ptr<KPMCoreInitializer> i;
if (argc != 2)
{
if (argc != 2) {
i = std::make_unique<KPMCoreInitializer>();
if (!i->isValid())
return 1;
}
else
{
} else {
i = std::make_unique<KPMCoreInitializer>( argv[1] );
if (!i->isValid())
return 1;
}
auto backend = CoreBackendManager::self()->backend();
if (!backend)
{
if (!backend) {
qWarning() << "Could not get backend.";
return 1;
}
@ -96,8 +93,8 @@ int main( int argc, char **argv )
const auto devices = operationStack->previewDevices();
qDebug() << "Found" << devices.length() << "devices.";
for (const auto pdev : devices)
{
for (const auto &pdev : devices) {
qDebug() << "Device @" << (void *)pdev;
qDebug() << " " << pdev->prettyName();

Voir le fichier

@ -26,30 +26,29 @@
#include <QDebug>
#include <QThread>
class runcmd : public QThread {
public:
void run() override
class runcmd : public QThread
{
ExternalCommand blkidCmd(QStringLiteral("blkid"), {});
// ExternalCommadHelper will refuse to run this or any other command which is not whitelisted.
// See src/util/externalcommand_whitelist.h for whitelisted commands.
blkidCmd.run();
qDebug().noquote() << blkidCmd.output();
}
public:
void run() override
{
ExternalCommand blkidCmd(QStringLiteral("blkid"), {});
// ExternalCommadHelper will refuse to run this or any other command which is not whitelisted.
// See src/util/externalcommand_whitelist.h for whitelisted commands.
blkidCmd.run();
qDebug().noquote() << blkidCmd.output();
}
};
class runcmd2 : public QThread {
public:
void run() override
class runcmd2 : public QThread
{
ExternalCommand lsblkCmd(QStringLiteral("lsblk"), { QStringLiteral("--nodeps"), QStringLiteral("--json") });
lsblkCmd.run();
qDebug().noquote() << lsblkCmd.output();
}
public:
void run() override
{
ExternalCommand lsblkCmd(QStringLiteral("lsblk"), { QStringLiteral("--nodeps"), QStringLiteral("--json") });
lsblkCmd.run();
qDebug().noquote() << lsblkCmd.output();
}
};
@ -60,8 +59,10 @@ int main( int argc, char **argv )
runcmd a;
runcmd2 b;
a.start();
a.wait();
b.start();
b.wait();

Voir le fichier

@ -28,13 +28,10 @@
int main( int argc, char** argv )
{
QCoreApplication app(argc, argv);
if ( argc != 2 )
{
if ( argc != 2 ) {
KPMCoreInitializer i;
return i.isValid() ? 0 : 1;
}
else
{
} else {
KPMCoreInitializer i( argv[1] );
return i.isValid() ? 0 : 1;
}

Voir le fichier

@ -66,30 +66,27 @@ int main( int argc, char **argv )
QCoreApplication app(argc, argv);
std::unique_ptr<KPMCoreInitializer> i;
if (argc != 2)
{
if (argc != 2) {
i = std::make_unique<KPMCoreInitializer>();
if (!i->isValid())
return 1;
}
else
{
} else {
i = std::make_unique<KPMCoreInitializer>( argv[1] );
if (!i->isValid())
return 1;
}
auto backend = CoreBackendManager::self()->backend();
if (!backend)
{
if (!backend) {
qWarning() << "Could not get backend.";
return 1;
}
const auto devices = backend->scanDevices(ScanFlag::includeLoopback);
qDebug() << "Found" << devices.length() << "devices.";
for (const auto pdev : devices)
{
for (const auto &pdev : devices) {
qDebug() << "Device @" << (void *)pdev;
qDebug() << " " << pdev->prettyName();

Voir le fichier

@ -55,7 +55,7 @@ static QString getDefaultDevicePath()
static bool testSmartStatus()
{
QString devicePath = getDefaultDevicePath();
const QString devicePath = getDefaultDevicePath();
SmartStatus smart(devicePath);
@ -85,7 +85,7 @@ static bool testSmartStatus()
static bool testSmartParser()
{
QString devicePath = getDefaultDevicePath();
const QString devicePath = getDefaultDevicePath();
SmartParser parser(devicePath);