Commit 1dea0ea8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Clean up, const'ify

parent 78b5e05c
......@@ -57,14 +57,14 @@ SensorAgent::~SensorAgent()
void SensorAgent::sendRequest( const QString &req, SensorClient *client, int id )
{
SensorRequest *sensorreq = nullptr;
for(int i =0; i < mInputFIFO.size(); ++i) {
for(int i =0, total = mInputFIFO.size(); i < total; ++i) {
sensorreq = mInputFIFO.at(i);
if(id == sensorreq->id() && client == sensorreq->client() && req == sensorreq->request()) {
executeCommand();
return; //don't bother to resend the same request if we already have it in our queue to send
}
}
for(int i =0; i < mProcessingFIFO.size(); ++i) {
for(int i =0, total = mProcessingFIFO.size(); i < total; ++i) {
sensorreq = mProcessingFIFO.at(i);
if(id == sensorreq->id() && client == sensorreq->client() && req == sensorreq->request())
return; //don't bother to resend the same request if we have already sent the request to client and just waiting for an answer
......@@ -224,10 +224,10 @@ void SensorAgent::executeCommand()
void SensorAgent::disconnectClient( SensorClient *client )
{
for (int i = 0; i < mInputFIFO.size(); ++i)
for (int i = 0, total = mInputFIFO.size(); i < total; ++i)
if ( mInputFIFO[i]->client() == client )
mInputFIFO[i]->setClient(nullptr);
for (int i = 0; i < mProcessingFIFO.size(); ++i)
for (int i = 0, total = mProcessingFIFO.size(); i < total; ++i)
if ( mProcessingFIFO[i]->client() == client )
mProcessingFIFO[i]->setClient( nullptr );
......
......@@ -412,12 +412,12 @@ QString SensorManager::translateSensorType( const QString &type ) const
QString SensorManager::translateSensor( const QString &sensor ) const
{
QString token, out;
QString out;
int start = 0, end = 0;
for ( ; ; ) {
end = sensor.indexOf( '/', start );
end = sensor.indexOf( QLatin1Char('/'), start );
if ( end > 0 )
out += translateSensorPath( sensor.mid( start, end - start ) ) + '/';
out += translateSensorPath( sensor.mid( start, end - start ) ) + QLatin1Char('/');
else {
out += translateSensorPath( sensor.right( sensor.length() - start ) );
break;
......@@ -434,8 +434,7 @@ void SensorManager::readProperties( const KConfigGroup& cfg )
mCommandList = cfg.readEntry( "CommandList",QStringList() );
}
void
SensorManager::saveProperties( KConfigGroup &cfg )
void SensorManager::saveProperties( KConfigGroup &cfg )
{
cfg.writeEntry( "HostList", mHostList );
cfg.writeEntry( "CommandList", mCommandList );
......
......@@ -27,7 +27,6 @@
#include <klocalizedstring.h>
#include "processcore/processcore_debug.h"
//#include "SensorClient.h"
#include "SensorManager.h"
#include "SensorShellAgent.h"
......@@ -96,12 +95,12 @@ void SensorShellAgent::msgRcvd( )
void SensorShellAgent::errMsgRcvd( )
{
QByteArray buffer = mDaemon->readAllStandardOutput();
const QByteArray buffer = mDaemon->readAllStandardOutput();
// Because we read the error buffer in chunks, we may not have a proper utf8 string.
// We should never get input over stderr anyway, so no need to worry too much about it.
// But if this is extended, we will need to handle this better
QString buf = QString::fromUtf8( buffer );
const QString buf = QString::fromUtf8( buffer );
qCDebug(LIBKSYSGUARD) << "SensorShellAgent: Warning, received text over stderr!"
<< endl << buf << endl;
......
......@@ -92,7 +92,7 @@ ActionReply KSysGuardProcessListHelper::changeioscheduler(QVariantMap parameters
int ioScheduler = qvariant_cast<int>(parameters.value(QStringLiteral("ioScheduler")));
int ioSchedulerPriority = qvariant_cast<int>(parameters.value(QStringLiteral("ioSchedulerPriority")));
bool success = true;
int numProcesses = parameters.value(QStringLiteral("pidcount")).toInt();
const int numProcesses = parameters.value(QStringLiteral("pidcount")).toInt();
for (int i = 0; i < numProcesses; ++i) {
qlonglong pid = GET_PID(i);
success = processes.setIoNiceness(pid, ioScheduler, ioSchedulerPriority) && success;
......@@ -112,7 +112,7 @@ ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameter
int cpuSchedulerPriority = qvariant_cast<int>(parameters.value(QStringLiteral("cpuSchedulerPriority")));
bool success = true;
int numProcesses = parameters.value(QStringLiteral("pidcount")).toInt();
const int numProcesses = parameters.value(QStringLiteral("pidcount")).toInt();
for (int i = 0; i < numProcesses; ++i) {
qlonglong pid = GET_PID(i);
success = processes.setScheduler(pid, cpuScheduler, cpuSchedulerPriority) && success;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment