• Yanan Wang's avatar
    KVM: selftests: Fix compiling errors when initializing the static structure · 95bf69b4
    Yanan Wang authored
    Errors like below were produced from test_util.c when compiling the KVM
    selftests on my local platform.
    
    lib/test_util.c: In function 'vm_mem_backing_src_alias':
    lib/test_util.c:177:12: error: initializer element is not constant
        .flag = anon_flags,
                ^~~~~~~~~~
    lib/test_util.c:177:12: note: (near initialization for 'aliases[0].flag')
    
    The reason is that we are using non-const expressions to initialize the
    static structure, which will probably trigger a compiling error/warning
    on stricter GCC versions. Fix it by converting the two const variables
    "anon_flags" and "anon_huge_flags" into more stable macros.
    
    Fixes: b3784bc2 ("KVM: selftests: refactor vm_mem_backing_src_type flags")
    Reported-by: default avatarZenghui Yu <yuzenghui@huawei.com>
    Signed-off-by: default avatarYanan Wang <wangyanan55@huawei.com>
    Message-Id: <20210610085418.35544-1-wangyanan55@huawei.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    95bf69b4
test_util.c 6.85 KB