All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix an address space warning in blk-map.c
@ 2010-09-14 15:42 Namhyung Kim
  2010-09-15 11:07 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Namhyung Kim @ 2010-09-14 15:42 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel

Change type of 2nd parameter of blk_rq_aligned() into unsigned long
and remove unnecessary casting. Now we can call it with 'uaddr'
instead of 'ubuf' in __blk_rq_map_user() so that it can remove
following warnings from sparse:

 block/blk-map.c:57:31: warning: incorrect type in argument 2 (different address spaces)
 block/blk-map.c:57:31:    expected void *addr
 block/blk-map.c:57:31:    got void [noderef] <asn:1>*ubuf

However blk_rq_map_kern() needs one more local variable to handle it.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 block/blk-map.c        |    5 +++--
 include/linux/blkdev.h |    4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/block/blk-map.c b/block/blk-map.c
index c65d759..ac0f7d4 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -54,7 +54,7 @@ static int __blk_rq_map_user(struct request_queue *q, struct request *rq,
 	 * direct dma. else, set up kernel bounce buffers
 	 */
 	uaddr = (unsigned long) ubuf;
-	if (blk_rq_aligned(q, ubuf, len) && !map_data)
+	if (blk_rq_aligned(q, uaddr, len) && !map_data)
 		bio = bio_map_user(q, NULL, uaddr, len, reading, gfp_mask);
 	else
 		bio = bio_copy_user(q, map_data, uaddr, len, reading, gfp_mask);
@@ -288,6 +288,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
 		    unsigned int len, gfp_t gfp_mask)
 {
 	int reading = rq_data_dir(rq) == READ;
+	unsigned long addr = (unsigned long) kbuf;
 	int do_copy = 0;
 	struct bio *bio;
 	int ret;
@@ -297,7 +298,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
 	if (!len || !kbuf)
 		return -EINVAL;
 
-	do_copy = !blk_rq_aligned(q, kbuf, len) || object_is_on_stack(kbuf);
+	do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
 	if (do_copy)
 		bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
 	else
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 2c54906..71d7c9c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1093,11 +1093,11 @@ static inline int queue_dma_alignment(struct request_queue *q)
 	return q ? q->dma_alignment : 511;
 }
 
-static inline int blk_rq_aligned(struct request_queue *q, void *addr,
+static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
 				 unsigned int len)
 {
 	unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask;
-	return !((unsigned long)addr & alignment) && !(len & alignment);
+	return !(addr & alignment) && !(len & alignment);
 }
 
 /* assumes size > 256 */
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block: fix an address space warning in blk-map.c
  2010-09-14 15:42 [PATCH] block: fix an address space warning in blk-map.c Namhyung Kim
@ 2010-09-15 11:07 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2010-09-15 11:07 UTC (permalink / raw)
  To: Namhyung Kim; +Cc: linux-kernel

On 2010-09-14 17:42, Namhyung Kim wrote:
> Change type of 2nd parameter of blk_rq_aligned() into unsigned long
> and remove unnecessary casting. Now we can call it with 'uaddr'
> instead of 'ubuf' in __blk_rq_map_user() so that it can remove
> following warnings from sparse:
> 
>  block/blk-map.c:57:31: warning: incorrect type in argument 2 (different address spaces)
>  block/blk-map.c:57:31:    expected void *addr
>  block/blk-map.c:57:31:    got void [noderef] <asn:1>*ubuf
> 
> However blk_rq_map_kern() needs one more local variable to handle it.

Thanks, applied to for-2.6.37/core

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-09-15 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-14 15:42 [PATCH] block: fix an address space warning in blk-map.c Namhyung Kim
2010-09-15 11:07 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.