public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] s390x/snippets/c/sie-dat: Fix compiler warning with GCC 11.2
@ 2024-02-16 19:00 Thomas Huth
  2024-02-16 19:08 ` Claudio Imbrenda
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2024-02-16 19:00 UTC (permalink / raw)
  To: kvm, Janosch Frank, Claudio Imbrenda, Nico Böhr
  Cc: linux-s390, David Hildenbrand, Jan Richter

GCC 11.2.1 from RHEL 9.0 complains:

 s390x/snippets/c/sie-dat.c: In function ‘main’:
 s390x/snippets/c/sie-dat.c:51:22: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
    51 |         *invalid_ptr = 42;
       |         ~~~~~~~~~~~~~^~~~
 cc1: all warnings being treated as errors

Let's use the OPAQUE_PTR() macro here too, which we already used
in other spots to fix similar -Wstringop-overflow warnings.

Reported-by: Jan Richter <jarichte@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 s390x/snippets/c/sie-dat.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/s390x/snippets/c/sie-dat.c b/s390x/snippets/c/sie-dat.c
index ecfcb60e..9d89801d 100644
--- a/s390x/snippets/c/sie-dat.c
+++ b/s390x/snippets/c/sie-dat.c
@@ -9,6 +9,7 @@
  */
 #include <libcflat.h>
 #include <asm-generic/page.h>
+#include <asm/mem.h>
 #include "sie-dat.h"
 
 static uint8_t test_pages[GUEST_TEST_PAGE_COUNT * PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
@@ -47,7 +48,7 @@ int main(void)
 	force_exit();
 
 	/* the first unmapped address */
-	invalid_ptr = (uint8_t *)(GUEST_TOTAL_PAGE_COUNT * PAGE_SIZE);
+	invalid_ptr = OPAQUE_PTR(GUEST_TOTAL_PAGE_COUNT * PAGE_SIZE);
 	*invalid_ptr = 42;
 
 	/* indicate we've written the non-allowed page (should never get here) */
-- 
2.43.0


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

end of thread, other threads:[~2024-02-16 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-16 19:00 [kvm-unit-tests PATCH] s390x/snippets/c/sie-dat: Fix compiler warning with GCC 11.2 Thomas Huth
2024-02-16 19:08 ` Claudio Imbrenda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox