From 5ad05a44dcb541b84c8cf45ea135d4886da6b99f Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 24 Mar 2024 10:35:49 +0100 Subject: [PATCH] Make pointer-to-int-cast warnings non-fatal Latest gcc on Debian unstable i386 starts to fail with > tests/test-umockdev-vala.vala:714:19: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] > xfer[0].tx_buf = (uint64) tx_buf; It's right -- this *is* an evil and wrong cast, but unfortunately Linux defines the struct precisely as that -- `u64`, on all platforms. As we can't selectively `#pragma` these away, disable the fatal warning globally. --- meson.build | 2 ++ tests/test-umockdev-vala.vala | 1 + 2 files changed, 3 insertions(+) diff --git a/meson.build b/meson.build index 8e3b287..8411749 100644 --- a/meson.build +++ b/meson.build @@ -41,6 +41,8 @@ add_project_arguments( cc.get_supported_arguments( # Vala doesn't have `const void*`, or a way to selectively #pragma these in the code '-Wno-error=discarded-qualifiers', + # spi_ioc_transfer.[rx]x_buf are pointers, but declared u64 everywhere; Vala can't selectively #pragma these + '-Wno-error=pointer-to-int-cast', # mostly const dropping and dropped "volatile" in fully autogenerated code; # upstream Vala does not support fixing this warning '-Wno-error=incompatible-pointer-types', diff --git a/tests/test-umockdev-vala.vala b/tests/test-umockdev-vala.vala index c68cefa..524c777 100644 --- a/tests/test-umockdev-vala.vala +++ b/tests/test-umockdev-vala.vala @@ -710,6 +710,7 @@ t_spidev_ioctl () tx_buf[1] = 0xff; Posix.memset (xfer, 0, sizeof (Ioctl.spi_ioc_transfer) * 2); + /* these casts are evil, bad, and wrong -- but that's how Linux defines them, even 32 bit platforms have u64 */ xfer[0].tx_buf = (uint64) tx_buf; xfer[0].len = 2; xfer[1].rx_buf = (uint64) rx_buf;