linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: selftests: Silence compiler warning in the kvm_page_table_test
@ 2022-04-14 10:30 Thomas Huth
  2022-04-14 11:22 ` Claudio Imbrenda
  2022-04-20 11:11 ` Paolo Bonzini
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Huth @ 2022-04-14 10:30 UTC (permalink / raw)
  To: kvm, Paolo Bonzini, Christian Borntraeger, Janosch Frank,
	Claudio Imbrenda
  Cc: Shuah Khan, linux-kselftest, linux-kernel, David Hildenbrand

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 <thuth@redhat.com>
---
 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 ba1fdc3dcf4a..2c4a7563a4f8 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 = align_down(guest_test_phys_mem, alignment);
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: selftests: Silence compiler warning in the kvm_page_table_test
  2022-04-14 10:30 [PATCH] KVM: selftests: Silence compiler warning in the kvm_page_table_test Thomas Huth
@ 2022-04-14 11:22 ` Claudio Imbrenda
  2022-04-20 11:11 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Claudio Imbrenda @ 2022-04-14 11:22 UTC (permalink / raw)
  To: Thomas Huth
  Cc: kvm, Paolo Bonzini, Christian Borntraeger, Janosch Frank,
	Shuah Khan, linux-kselftest, linux-kernel, David Hildenbrand

On Thu, 14 Apr 2022 12:30:31 +0200
Thomas Huth <thuth@redhat.com> wrote:

> 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 <thuth@redhat.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  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 ba1fdc3dcf4a..2c4a7563a4f8 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 = align_down(guest_test_phys_mem, alignment);
>  


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: selftests: Silence compiler warning in the kvm_page_table_test
  2022-04-14 10:30 [PATCH] KVM: selftests: Silence compiler warning in the kvm_page_table_test Thomas Huth
  2022-04-14 11:22 ` Claudio Imbrenda
@ 2022-04-20 11:11 ` Paolo Bonzini
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2022-04-20 11:11 UTC (permalink / raw)
  To: Thomas Huth
  Cc: kvm, Christian Borntraeger, Janosch Frank, Claudio Imbrenda,
	Shuah Khan, linux-kselftest, linux-kernel, David Hildenbrand

Queued, thanks.

Paolo



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-20 11:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-14 10:30 [PATCH] KVM: selftests: Silence compiler warning in the kvm_page_table_test Thomas Huth
2022-04-14 11:22 ` Claudio Imbrenda
2022-04-20 11:11 ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).