Skip to content

Commit

Permalink
Some improvements for get_freq again.
Browse files Browse the repository at this point in the history
Fix frequency not printing correctly (I wasn't using the divisor)
Add more guards.
  • Loading branch information
npyl committed Aug 9, 2018
1 parent b2d6790 commit c288aed
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/darwin.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,7 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,

static bool initialised = false;

if (!initialised)
{
if (!initialised) {
IntelEnergyLibInitialize();
initialised = true;
}
Expand All @@ -1042,11 +1041,6 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
unsigned int freq;
size_t len;

if ((p_client_buffer == nullptr) || client_buffer_size <= 0 ||
(p_format == nullptr) || divisor <= 0) {
return 0;
}

mib[0] = CTL_HW;
mib[1] = HW_CPU_FREQ;
len = sizeof(freq);
Expand All @@ -1064,7 +1058,7 @@ char get_freq(char *p_client_buffer, size_t client_buffer_size,
return 0;
}
#endif

return 1;
}

Expand Down

0 comments on commit c288aed

Please sign in to comment.