diff options
author | Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com> | 2024-05-24 14:04:33 +0300 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2024-06-28 07:04:57 +0300 |
commit | 25e713c6b54a899b5a8b5e09b58f4b87a5b3664b (patch) | |
tree | ba6873335e86e6d209cbe4798f598c8da802e6fb /tools/power/x86/turbostat | |
parent | 73ed3c941a76ff3348022477975c84b8d183599a (diff) | |
download | linux-25e713c6b54a899b5a8b5e09b58f4b87a5b3664b.tar.xz |
tools/power turbostat: Add ZERO_ARRAY for zero initializing builtin array
It makes it harder to shoot yourself in the foot, by using
additional __must_be_array() check.
Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'tools/power/x86/turbostat')
-rw-r--r-- | tools/power/x86/turbostat/turbostat.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 0fc6c107e371..29751b41ea0d 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -1060,6 +1060,8 @@ size_t cpu_present_setsize, cpu_effective_setsize, cpu_allowed_setsize, cpu_affi #define MAX_ADDED_PACKAGE_COUNTERS 16 #define BITMASK_SIZE 32 +#define ZERO_ARRAY(arr) (memset(arr, 0, sizeof(arr)) + __must_be_array(arr)) + /* Indexes used to map data read from perf and MSRs into global variables */ enum rapl_rci_index { RAPL_RCI_INDEX_ENERGY_PKG = 0, @@ -3733,9 +3735,9 @@ int get_cstate_counters(unsigned int cpu, struct thread_data *t, struct core_dat assert(ccstate_counter_info); assert(cpu <= ccstate_counter_info_size); - memset(perf_data, 0, sizeof(perf_data)); - memset(perf_data_core, 0, sizeof(perf_data_core)); - memset(perf_data_pkg, 0, sizeof(perf_data_pkg)); + ZERO_ARRAY(perf_data); + ZERO_ARRAY(perf_data_core); + ZERO_ARRAY(perf_data_pkg); cci = &ccstate_counter_info[cpu]; |