]> Savannah Git Hosting - gnulib.git/commitdiff
jit/cache tests: Avoid compiler warnings on OpenBSD.
authorBruno Haible <bruno@clisp.org>
Wed, 10 Jan 2024 13:22:44 +0000 (14:22 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 08:29:24 +0000 (09:29 +0100)
* tests/jit/test-cache.c (main): New variables size_of_return1,
size_of_return2.

ChangeLog
tests/jit/test-cache.c

index e31eefe3cdda3f43be31e1f3088438c09599b9c6..aa6177fbd35bdfe6fd677363e8df6cb5c9c7902e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-01-10  Bruno Haible  <bruno@clisp.org>
+
+       jit/cache tests: Avoid compiler warnings on OpenBSD.
+       * tests/jit/test-cache.c (main): New variables size_of_return1,
+       size_of_return2.
+
 2024-01-09  Bruno Haible  <bruno@clisp.org>
 
        jit/cache: Fix for ia64 CPUs.
index 0a52c9f3bd536afc01dc84ef027155c3f8cfb1fc..cabbc0ddfdeb057c8dc6e5bb830d493c3226f052 100644 (file)
@@ -210,6 +210,8 @@ main ()
 {
   void const *code_of_return1;
   void const *code_of_return2;
+  size_t size_of_return1;
+  size_t size_of_return2;
 #if defined __OpenBSD__ || defined _RET_PROTECTOR
   /* OpenBSD maps code with PROT_EXEC (as opposed to PROT_READ | PROT_EXEC).
      We need to use predetermined code for 'return1' and 'return2'.  */
@@ -220,12 +222,15 @@ main ()
      we need to use predetermined code for 'return1' and 'return2'.  */
   code_of_return1 = return1_code;
   code_of_return2 = return2_code;
+  size_of_return1 = sizeof (return1_code);
+  size_of_return2 = sizeof (return2_code);
 #else
   code_of_return1 = CODE (return1);
   code_of_return2 = CODE (return2);
-#endif
   /* We assume that the code is not longer than 64 bytes.  */
-  size_t code_size_bound = 64;
+  size_of_return1 = 64;
+  size_of_return2 = 64;
+#endif
 
   int const pagesize = getpagesize ();
   int const mapping_size = 1 * pagesize;
@@ -303,11 +308,11 @@ main ()
   int (*f) (void) = COPY_FUNCPTR (return1);
   CODE (f) = start;
 
-  memcpy (start_rw, code_of_return1, code_size_bound);
+  memcpy (start_rw, code_of_return1, size_of_return1);
   clear_cache (start, end);
   ASSERT (f () == 1);
 
-  memcpy (start_rw, code_of_return2, code_size_bound);
+  memcpy (start_rw, code_of_return2, size_of_return2);
   clear_cache (start, end);
   ASSERT (f () == 2);