1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-28 20:23:51 +00:00

only write SysTime::used if fscanf succeeds

This commit is contained in:
Graydon Hoare 2020-06-03 11:11:47 -07:00
parent 93b7b5a8e7
commit 28a29d071f
No known key found for this signature in database
GPG Key ID: 69824B014EE65219

View File

@ -47,11 +47,14 @@ void SysTime::ReadTimes()
FILE* f = fopen( "/proc/stat", "r" );
if( f )
{
fscanf( f, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64" %" PRIu64, &user, &nice, &system, &idle );
int read = fscanf( f, "cpu %" PRIu64 " %" PRIu64 " %" PRIu64" %" PRIu64, &user, &nice, &system, &idle );
fclose( f );
if (read == 4)
{
used = user + nice + system;
}
}
}
# elif defined __APPLE__