Skip to content

Commit

Permalink
Make pointer-to-int-cast warnings non-fatal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
martinpitt committed Mar 24, 2024
1 parent e333733 commit 5ad05a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions tests/test-umockdev-vala.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5ad05a4

Please sign in to comment.