1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2024-12-16 16:35:45 +00:00

Fix checking of core_num in cpu_msr_driver_open_core()

This commit is contained in:
Xorg 2016-05-18 18:42:11 +02:00
parent aaa7e155a9
commit 801d4c982a
2 changed files with 6 additions and 8 deletions

View file

@ -822,7 +822,7 @@ struct msr_driver_t* cpu_msr_driver_open(void);
/**
* @brief Similar to \ref cpu_msr_driver_open, but accept one parameter
*
* This function works on Linux only
* This function works on certain operating system (GNU/Linux, FreeBSD)
*
* @param core_num specify the core number for MSR.
* The first core number is 0.
@ -832,7 +832,7 @@ struct msr_driver_t* cpu_msr_driver_open(void);
* The error message can be obtained by calling \ref cpuid_error.
* @see cpu_error_t
*/
struct msr_driver_t* cpu_msr_driver_open_core(int core_num);
struct msr_driver_t* cpu_msr_driver_open_core(uint8_t core_num);
/**
* @brief Reads a Model-Specific Register (MSR)

View file

@ -46,12 +46,11 @@ struct msr_driver_t* cpu_msr_driver_open(void)
return cpu_msr_driver_open_core(0);
}
struct msr_driver_t* cpu_msr_driver_open_core(int core_num)
struct msr_driver_t* cpu_msr_driver_open_core(uint8_t core_num)
{
char msr[32];
struct msr_driver_t* handle;
if(core_num < 0 && cpuid_get_total_cpus() <= core_num)
{
if (core_num >= cpuid_get_total_cpus()) {
set_error(ERR_INVCNB);
return NULL;
}
@ -112,12 +111,11 @@ struct msr_driver_t* cpu_msr_driver_open(void)
return cpu_msr_driver_open_core(0);
}
struct msr_driver_t* cpu_msr_driver_open_core(int core_num)
struct msr_driver_t* cpu_msr_driver_open_core(uint8_t core_num)
{
char msr[32];
struct msr_driver_t* handle;
if(core_num < 0 && cpuid_get_total_cpus() <= core_num)
{
if (core_num >= cpuid_get_total_cpus()) {
set_error(ERR_INVCNB);
return NULL;
}