]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: selftests: Fix compiling errors when initializing the static structure
authorYanan Wang <wangyanan55@huawei.com>
Thu, 10 Jun 2021 08:54:18 +0000 (16:54 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 10 Jun 2021 11:46:10 +0000 (07:46 -0400)
commit8cfa2afff7851cdecb66ccf26c67c14b60e59c60
tree3f9a10c4f225384f9c6e1b1aa7b965728cb5fa89
parent9bcb299c4142b86bb58dc68dab25a6d7e21b038d
KVM: selftests: Fix compiling errors when initializing the static structure

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: 6c7173eb9aa8d ("KVM: selftests: refactor vm_mem_backing_src_type flags")
Reported-by: Zenghui Yu <yuzenghui@huawei.com>
Signed-off-by: Yanan Wang <wangyanan55@huawei.com>
Message-Id: <20210610085418.35544-1-wangyanan55@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/lib/test_util.c