Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
KSysGuard
Commits
b7bde8e4
Commit
b7bde8e4
authored
Sep 24, 2020
by
David Redondo
🏎
Browse files
Don't use massive sscanf
parent
dcdde187
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/global/cpu/linuxcpu.cpp
View file @
b7bde8e4
...
...
@@ -166,9 +166,15 @@ void LinuxCpuPluginPrivate::update()
}
else
{
continue
;
}
unsigned
long
long
user
,
nice
,
system
,
idle
,
iowait
,
irq
,
softirq
,
steal
,
guest
,
guest_nice
;
std
::
sscanf
(
line
.
data
(),
"%*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
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment