Commit b7bde8e4 authored by David Redondo's avatar David Redondo 🏎
Browse files

Don't use massive sscanf

parent dcdde187
......@@ -166,9 +166,15 @@ void LinuxCpuPluginPrivate::update()
} else {
unsigned long long user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice;
std::sscanf(, "%*s %llu %llu %llu %llu %llu %llu %llu %llu%llu %llu",
&user, &nice, &system, &idle, &iowait, &irq, &softirq, &steal, &guest, &guest_nice);
auto values = line.split(' ');
unsigned long long user = values[1].toULongLong();
unsigned long long nice = values[2].toULongLong();
unsigned long long system = values[3].toULongLong();
unsigned long long idle = values[4].toULongLong();
unsigned long long iowait = values[5].toULongLong();
unsigned long long irq = values[6].toULongLong();
unsigned long long softirq = values[7].toULongLong();
unsigned long long steal = values[8].toULongLong();
cpu->update(system + irq + softirq, user + nice , iowait + steal, idle);
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