Skip to content

Commit 835da3f

Browse files
arndbaxboe
authored andcommitted
nvme: fix 32-bit build warning
Compiling the nvme driver on 32-bit warns about a cast from a __u64 variable to a pointer: drivers/block/nvme-core.c: In function 'nvme_submit_io': drivers/block/nvme-core.c:1847:4: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] (void __user *)io.addr, length, NULL, 0); The cast here is intentional and safe, so we can shut up the gcc warning by adding an intermediate cast to 'uintptr_t'. I had previously submitted a patch to fix this problem in the nvme driver, but it was accepted on the same day that two new warnings got added. For clarification, I also change the third instance of this cast to use uintptr_t instead of unsigned long now. Signed-off-by: Arnd Bergmann <[email protected]> Fixes: d29ec82 ("nvme: submit internal commands through the block layer") Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent c5edf9c commit 835da3f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/block/nvme-core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
18041804

18051805
length = (io.nblocks + 1) << ns->lba_shift;
18061806
meta_len = (io.nblocks + 1) * ns->ms;
1807-
metadata = (void __user *)(unsigned long)io.metadata;
1807+
metadata = (void __user *)(uintptr_t)io.metadata;
18081808
write = io.opcode & 1;
18091809

18101810
if (ns->ext) {
@@ -1844,7 +1844,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio)
18441844
c.rw.metadata = cpu_to_le64(meta_dma);
18451845

18461846
status = __nvme_submit_sync_cmd(ns->queue, &c, NULL,
1847-
(void __user *)io.addr, length, NULL, 0);
1847+
(void __user *)(uintptr_t)io.addr, length, NULL, 0);
18481848
unmap:
18491849
if (meta) {
18501850
if (status == NVME_SC_SUCCESS && !write) {
@@ -1886,7 +1886,7 @@ static int nvme_user_cmd(struct nvme_dev *dev, struct nvme_ns *ns,
18861886
timeout = msecs_to_jiffies(cmd.timeout_ms);
18871887

18881888
status = __nvme_submit_sync_cmd(ns ? ns->queue : dev->admin_q, &c,
1889-
NULL, (void __user *)cmd.addr, cmd.data_len,
1889+
NULL, (void __user *)(uintptr_t)cmd.addr, cmd.data_len,
18901890
&cmd.result, timeout);
18911891
if (status >= 0) {
18921892
if (put_user(cmd.result, &ucmd->result))

0 commit comments

Comments
 (0)