• Fenghua Yu's avatar
    selftests/resctrl: Fix compilation issues for global variables · 8236c51d
    Fenghua Yu authored
    Reinette reported following compilation issue on Fedora 32, gcc version
    10.1.1
    
    /usr/bin/ld: cqm_test.o:<src_dir>/cqm_test.c:22: multiple definition of
    `cache_size'; cat_test.o:<src_dir>/cat_test.c:23: first defined here
    
    The same issue is reported for long_mask, cbm_mask, count_of_bits etc
    variables as well. Compiler isn't happy because these variables are
    defined globally in two .c files namely cqm_test.c and cat_test.c and
    the compiler during compilation finds that the variable is already
    defined (multiple definition error).
    
    Taking a closer look at the usage of these variables reveals that these
    variables are used only locally in functions such as cqm_resctrl_val()
    (defined in cqm_test.c) and cat_perf_miss_val() (defined in cat_test.c).
    These variables are not shared between those functions. So, there is no
    need for these variables to be global. Hence, fix this issue by making
    them static variables.
    Reported-by: default avatarReinette Chatre <reinette.chatre@intel.com>
    Tested-by: default avatarBabu Moger <babu.moger@amd.com>
    Signed-off-by: default avatarFenghua Yu <fenghua.yu@intel.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    8236c51d
resctrl.h 3.43 KB