diff --git a/libcpuid/libcpuid.h b/libcpuid/libcpuid.h index ebff735..163e4b8 100644 --- a/libcpuid/libcpuid.h +++ b/libcpuid/libcpuid.h @@ -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) diff --git a/libcpuid/rdmsr.c b/libcpuid/rdmsr.c index d6d6678..e663a25 100644 --- a/libcpuid/rdmsr.c +++ b/libcpuid/rdmsr.c @@ -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; }