summaryrefslogtreecommitdiffstats
path: root/drive_encryption.c
diff options
context:
space:
mode:
authorBlazej Kucman <blazej.kucman@intel.com>2024-05-15 13:26:28 +0200
committerMariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>2024-05-16 11:30:06 +0200
commitc5879860eac64ddd7bec4ba50c9adbfebcbf1d2e (patch)
treef5f2123c563f0ccac538fb68b29dc87ef785efc9 /drive_encryption.c
parentCI: create review.yml file (diff)
downloadmdadm-c5879860eac64ddd7bec4ba50c9adbfebcbf1d2e.tar.xz
mdadm-c5879860eac64ddd7bec4ba50c9adbfebcbf1d2e.zip
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>
Diffstat (limited to 'drive_encryption.c')
-rw-r--r--drive_encryption.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drive_encryption.c b/drive_encryption.c
index 27da9621..a4ad799f 100644
--- a/drive_encryption.c
+++ b/drive_encryption.c
@@ -233,7 +233,7 @@ nvme_security_recv_ioctl(int disk_fd, __u8 sec_protocol, __u16 comm_id, void *re
nvme_cmd.cdw10 = sec_protocol << 24 | comm_id << 8;
nvme_cmd.cdw11 = buf_size;
nvme_cmd.data_len = buf_size;
- nvme_cmd.addr = (__u64)response_buffer;
+ nvme_cmd.addr = (__u64)(uintptr_t)response_buffer;
status = ioctl(disk_fd, NVME_IOCTL_ADMIN_CMD, &nvme_cmd);
if (status != 0) {
@@ -268,7 +268,7 @@ nvme_identify_ioctl(int disk_fd, void *response_buffer, size_t buf_size, const i
nvme_cmd.opcode = NVME_IDENTIFY;
nvme_cmd.cdw10 = NVME_IDENTIFY_CONTROLLER_DATA;
nvme_cmd.data_len = buf_size;
- nvme_cmd.addr = (__u64)response_buffer;
+ nvme_cmd.addr = (__u64)(uintptr_t)response_buffer;
status = ioctl(disk_fd, NVME_IOCTL_ADMIN_CMD, &nvme_cmd);
if (status != 0) {