Skip to contentSkip to conversation

ntb: test: fix pointer size warning

PATCH In review Brian Norris 3 participants 5 messages Mar 18, 2016 – Mar 27, 2016 NTB driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntb: test: fix pointer size warning

drivers/ntb/test/ntb_perf.c: In function ‘perf_copy’:
drivers/ntb/test/ntb_perf.c:213:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] drivers/ntb/test/ntb_perf.c:214:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

On 32-bit systems, we are casting a 32-bit pointer to a 64-bit value. This shouldn't cause functional problems, but we might as well fix the warning and allow 32-bit arithmetic for 32-bit systems.

Cc Dave Jiang <[email protected]>
Cc Jon Mason <[email protected]>
Cc Allen Hubbe <[email protected]>
---
 drivers/ntb/test/ntb_perf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ntb/test/ntb_perf.c +3 -3
index c8a37ba4b4f9..835e2686998d 100644
@@ -189,7 +189,7 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
 	dma_cookie_t cookie;
 	size_t src_off, dst_off;
 	struct perf_mw *mw = &perf->mw;
-	u64 vbase, dst_vaddr;
+	uintptr_t vbase, dst_vaddr;
 	dma_addr_t dst_phys;
 	int retries = 0;
 
@@ -210,8 +210,8 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
 	if (!is_dma_copy_aligned(device, src_off, dst_off, size))
 		return -ENODEV;
 
-	vbase = (u64)(u64 *)mw->vbase;
-	dst_vaddr = (u64)(u64 *)dst;
+	vbase = (uintptr_t)(u64 *)mw->vbase;
+	dst_vaddr = (uintptr_t)(u64 *)dst;
 	dst_phys = mw->phys_addr + (dst_vaddr - vbase);
 
 	unmap = dmaengine_get_unmap_data(device->dev, 1, GFP_NOWAIT);
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Brian Norris

drivers/ntb/test/ntb_perf.c: In function ‘perf_copy’:
drivers/ntb/test/ntb_perf.c:213:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] drivers/ntb/test/ntb_perf.c:214:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

On 32-bit systems, we are casting a 32-bit pointer to a 64-bit value. This shouldn't cause functional problems, but we might as well fix the
warning and allow 32-bit arithmetic for 32-bit systems.

Quoted 4 lines
Cc Dave Jiang <[email protected]>
Cc Jon Mason <[email protected]>
Cc Allen Hubbe <[email protected]>
Quoted 32 lines

---
 drivers/ntb/test/ntb_perf.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ntb/test/ntb_perf.c +1 -1
index c8a37ba4b4f9..835e2686998d 100644
@@ -189,7 +189,7 @@ static ssize_t perf_copy(struct pthr_ctx *pctx,
 char *dst,
  	dma_cookie_t cookie;
  	size_t src_off, dst_off;
  	struct perf_mw *mw = &perf->mw;
-	u64 vbase, dst_vaddr;
+	uintptr_t vbase, dst_vaddr;
  	dma_addr_t dst_phys;
  	int retries = 0;

drivers/ntb/test/ntb_perf.c +0 -0
@@ -210,8 +210,8 @@ static ssize_t perf_copy(struct pthr_ctx *pctx,
 char *dst,
  	if (!is_dma_copy_aligned(device, src_off, dst_off, size))
  		return -ENODEV;

drivers/ntb/test/ntb_perf.c +2 -2
-	vbase = (u64)(u64 *)mw->vbase;
-	dst_vaddr = (u64)(u64 *)dst;
+	vbase = (uintptr_t)(u64 *)mw->vbase;
+	dst_vaddr = (uintptr_t)(u64 *)dst;

  dst_phys = mw->phys_addr + (dst_vaddr - vbase);
  unmap = dmaengine_get_unmap_data(device->dev, 1, GFP_NOWAIT);

maintainer
#2 lore raw
In reply to Brian Norris
Quoted 7 lines · Brian Norris

drivers/ntb/test/ntb_perf.c: In function ‘perf_copy’:
drivers/ntb/test/ntb_perf.c:213:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] drivers/ntb/test/ntb_perf.c:214:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

On 32-bit systems, we are casting a 32-bit pointer to a 64-bit value. This shouldn't cause functional problems, but we might as well fix the warning and allow 32-bit arithmetic for 32-bit systems.

This was already addressed by a patch from Arnd Bergmann, which is queued in the ntb git tree.

Thanks,
Jon

Quoted 36 lines
Cc Dave Jiang <[email protected]>
Cc Jon Mason <[email protected]>
Cc Allen Hubbe <[email protected]>
---
 drivers/ntb/test/ntb_perf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/ntb/test/ntb_perf.c +3 -3
index c8a37ba4b4f9..835e2686998d 100644
@@ -189,7 +189,7 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
 	dma_cookie_t cookie;
 	size_t src_off, dst_off;
 	struct perf_mw *mw = &perf->mw;
-	u64 vbase, dst_vaddr;
+	uintptr_t vbase, dst_vaddr;
 	dma_addr_t dst_phys;
 	int retries = 0;
 
@@ -210,8 +210,8 @@ static ssize_t perf_copy(struct pthr_ctx *pctx, char *dst,
 	if (!is_dma_copy_aligned(device, src_off, dst_off, size))
 		return -ENODEV;
 
-	vbase = (u64)(u64 *)mw->vbase;
-	dst_vaddr = (u64)(u64 *)dst;
+	vbase = (uintptr_t)(u64 *)mw->vbase;
+	dst_vaddr = (uintptr_t)(u64 *)dst;
 	dst_phys = mw->phys_addr + (dst_vaddr - vbase);
 
 	unmap = dmaengine_get_unmap_data(device->dev, 1, GFP_NOWAIT);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#3 lore raw
Quoted 11 lines · Jon Mason
Quoted 7 lines · Brian Norris

drivers/ntb/test/ntb_perf.c: In function ‘perf_copy’:
drivers/ntb/test/ntb_perf.c:213:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] drivers/ntb/test/ntb_perf.c:214:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

On 32-bit systems, we are casting a 32-bit pointer to a 64-bit value. This shouldn't cause functional problems, but we might as well fix the warning and allow 32-bit arithmetic for 32-bit systems.

This was already addressed by a patch from Arnd Bergmann, which is queued in the ntb git tree.

Great!

Is your ntb tree in linux-next.git?

Regards,
Brian

maintainer
#4 lore raw
Quoted 10 lines · Brian Norris
Quoted 9 lines · Jon Mason
Quoted 7 lines · Brian Norris

drivers/ntb/test/ntb_perf.c: In function ‘perf_copy’:
drivers/ntb/test/ntb_perf.c:213:10: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] drivers/ntb/test/ntb_perf.c:214:14: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

On 32-bit systems, we are casting a 32-bit pointer to a 64-bit value. This shouldn't cause functional problems, but we might as well fix the warning and allow 32-bit arithmetic for 32-bit systems.

Quoted 6 lines
Quoted 2 lines

This was already addressed by a patch from Arnd Bergmann, which is queued in the ntb git tree.

Great!

Is your ntb tree in linux-next.git?

No, it is not.

Quoted 2 lines

Regards,
Brian