]> git.ipfire.org Git - thirdparty/mdadm.git/commit
mdadm: Fix compilation for 32-bit arch
authorBlazej Kucman <blazej.kucman@intel.com>
Wed, 15 May 2024 11:26:28 +0000 (13:26 +0200)
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Thu, 16 May 2024 09:30:06 +0000 (11:30 +0200)
commitc5879860eac64ddd7bec4ba50c9adbfebcbf1d2e
treef5f2123c563f0ccac538fb68b29dc87ef785efc9
parentd3d4b21db909ab77aa8b71b70de438d0010f364b
mdadm: Fix compilation for 32-bit arch

Casting void pointer to __u64 works for 64-bit arch but fails to compile
on 32-bit arch like i686.

Fail on i686 platform:
drive_encryption.c: In function ‘nvme_security_recv_ioctl’:
drive_encryption.c:236:25: error: cast from pointer to integer of
different size [-Werror=pointer-to-int-cast]
  236 |         nvme_cmd.addr = (__u64)response_buffer;
      |                         ^
drive_encryption.c: In function ‘nvme_identify_ioctl’:
drive_encryption.c:271:25: error: cast from pointer to integer of
different size [-Werror=pointer-to-int-cast]
  271 |         nvme_cmd.addr = (__u64)response_buffer;
      |                         ^
cc1: all warnings being treated as errors
make: *** [Makefile:211: drive_encryption.o] Error 1

This change adds cast void pointer to uintptr_t first to ensure that
proper pointer size is used for casting from pointer type. Then is safe to
cast it to __u64 because it is tracked as u_int, regardless it is 32-bit
or 64-bit arch.

Reported-by: Xiao Ni <xni@redhat.com>
Fixes: cc48406887b3 ("Add reading Opal NVMe encryption information")
Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
drive_encryption.c