History

NVMe: fix type warning on 32-bit

A recent change to the ioctl handling caused a new harmless warning in the NVMe driver on all 32-bit machines: drivers/block/nvme-core.c: In function 'nvme_submit_io': drivers/block/nvme-core.c:1794:29: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] In order to shup up that warning, this introduces a new temporary variable that uses a double cast to extract the pointer from an __u64 structure member.

Arnd Bergmann committed 11 years ago

Commit fec558b1 parent aad653a1 file · +6 −4Browse files

Unified · Split

drivers/block/nvme-core.c+6−4
@@ -1750,6 +1750,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) · 1749 unmodified lines
17501750 struct nvme_iod *iod;
17511751 dma_addr_t meta_dma = 0;
17521752 void *meta = NULL;
1753+ void __user *metadata;
17531754
17541755 if (copy_from_user(&io, uio, sizeof(io)))
17551756 return -EFAULT;
@@ -1763,6 +1764,8 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) · 7 unmodified lines
17631764 meta_len = 0;
17641765 }
17651766
1767+ metadata = (void __user *)(unsigned long)io.metadata;
1768+
17661769 write = io.opcode & 1;
17671770
17681771 switch (io.opcode) {
@@ -1786,13 +1789,13 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) · 17 unmodified lines
17861789 if (meta_len) {
17871790 meta = dma_alloc_coherent(&dev->pci_dev->dev, meta_len,
17881791 &meta_dma, GFP_KERNEL);
1792+
17891793 if (!meta) {
17901794 status = -ENOMEM;
17911795 goto unmap;
17921796 }
17931797 if (write) {
1794− if (copy_from_user(meta, (void __user *)io.metadata,
1795− meta_len)) {
1798+ if (copy_from_user(meta, metadata, meta_len)) {
17961799 status = -EFAULT;
17971800 goto unmap;
17981801 }
@@ -1819,8 +1822,7 @@ static int nvme_submit_io(struct nvme_ns *ns, struct nvme_user_io __user *uio) · 20 unmodified lines
18191822 nvme_free_iod(dev, iod);
18201823 if (meta) {
18211824 if (status == NVME_SC_SUCCESS && !write) {
1822− if (copy_to_user((void __user *)io.metadata, meta,
1823− meta_len))
1825+ if (copy_to_user(metadata, meta, meta_len))
18241826 status = -EFAULT;
18251827 }
18261828 dma_free_coherent(&dev->pci_dev->dev, meta_len, meta, meta_dma);