2022-04-27 16:28:08

by Sasha Levin

[permalink] [raw]
Subject: [PATCH MANUALSEL 5.15 2/7] KVM: selftests: Silence compiler warning in the kvm_page_table_test

From: Thomas Huth <[email protected]>

[ Upstream commit 266a19a0bc4fbfab4d981a47640ca98972a01865 ]

When compiling kvm_page_table_test.c, I get this compiler warning
with gcc 11.2:

kvm_page_table_test.c: In function 'pre_init_before_test':
../../../../tools/include/linux/kernel.h:44:24: warning: comparison of
distinct pointer types lacks a cast
44 | (void) (&_max1 == &_max2); \
| ^~
kvm_page_table_test.c:281:21: note: in expansion of macro 'max'
281 | alignment = max(0x100000, alignment);
| ^~~

Fix it by adjusting the type of the absolute value.

Signed-off-by: Thomas Huth <[email protected]>
Reviewed-by: Claudio Imbrenda <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
tools/testing/selftests/kvm/kvm_page_table_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
index 36407cb0ec85..f1ddfe4c4a03 100644
--- a/tools/testing/selftests/kvm/kvm_page_table_test.c
+++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
@@ -278,7 +278,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
else
guest_test_phys_mem = p->phys_offset;
#ifdef __s390x__
- alignment = max(0x100000, alignment);
+ alignment = max(0x100000UL, alignment);
#endif
guest_test_phys_mem &= ~(alignment - 1);

--
2.35.1


2022-04-27 16:53:29

by Paolo Bonzini

[permalink] [raw]
Subject: Re: [PATCH MANUALSEL 5.15 2/7] KVM: selftests: Silence compiler warning in the kvm_page_table_test

On 4/27/22 17:54, Sasha Levin wrote:
> From: Thomas Huth <[email protected]>
>
> [ Upstream commit 266a19a0bc4fbfab4d981a47640ca98972a01865 ]
>
> When compiling kvm_page_table_test.c, I get this compiler warning
> with gcc 11.2:
>
> kvm_page_table_test.c: In function 'pre_init_before_test':
> ../../../../tools/include/linux/kernel.h:44:24: warning: comparison of
> distinct pointer types lacks a cast
> 44 | (void) (&_max1 == &_max2); \
> | ^~
> kvm_page_table_test.c:281:21: note: in expansion of macro 'max'
> 281 | alignment = max(0x100000, alignment);
> | ^~~
>
> Fix it by adjusting the type of the absolute value.
>
> Signed-off-by: Thomas Huth <[email protected]>
> Reviewed-by: Claudio Imbrenda <[email protected]>
> Message-Id: <[email protected]>
> Signed-off-by: Paolo Bonzini <[email protected]>
> Signed-off-by: Sasha Levin <[email protected]>
> ---
> tools/testing/selftests/kvm/kvm_page_table_test.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/kvm_page_table_test.c b/tools/testing/selftests/kvm/kvm_page_table_test.c
> index 36407cb0ec85..f1ddfe4c4a03 100644
> --- a/tools/testing/selftests/kvm/kvm_page_table_test.c
> +++ b/tools/testing/selftests/kvm/kvm_page_table_test.c
> @@ -278,7 +278,7 @@ static struct kvm_vm *pre_init_before_test(enum vm_guest_mode mode, void *arg)
> else
> guest_test_phys_mem = p->phys_offset;
> #ifdef __s390x__
> - alignment = max(0x100000, alignment);
> + alignment = max(0x100000UL, alignment);
> #endif
> guest_test_phys_mem &= ~(alignment - 1);
>

Acked-by: Paolo Bonzini <[email protected]>