Skip to content

Commit

Permalink
lib/bitmap.c: quiet sparse noise about address space
Browse files Browse the repository at this point in the history
__bitmap_parse() and __bitmap_parselist() both take a pointer to a kernel
buffer as a parameter and then cast it to a pointer to user buffer for use
in cases when the parameter is_user indicates that the buffer is actually
located in user space.  This casting, and the casts in the callers,
results in sparse noise like the following:

	warning: incorrect type in initializer (different address spaces)
	  expected char const [noderef] <asn:1>*ubuf
	  got char const *buf
	warning: cast removes address space of expression

Since these casts are intentional, use __force to quiet the noise.

Signed-off-by: H Hartley Sweeten <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Huang Ying <[email protected]>
Cc: Andy Shevchenko <[email protected]>
Cc: Andi Kleen <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
H Hartley Sweeten authored and torvalds committed Nov 1, 2011
1 parent 4e101b0 commit b9c321f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
{
int c, old_c, totaldigits, ndigits, nchunks, nbits;
u32 chunk;
const char __user *ubuf = buf;
const char __user __force *ubuf = (const char __user __force *)buf;

bitmap_zero(maskp, nmaskbits);

Expand Down Expand Up @@ -504,7 +504,9 @@ int bitmap_parse_user(const char __user *ubuf,
{
if (!access_ok(VERIFY_READ, ubuf, ulen))
return -EFAULT;
return __bitmap_parse((const char *)ubuf, ulen, 1, maskp, nmaskbits);
return __bitmap_parse((const char __force *)ubuf,
ulen, 1, maskp, nmaskbits);

}
EXPORT_SYMBOL(bitmap_parse_user);

Expand Down Expand Up @@ -594,7 +596,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
{
unsigned a, b;
int c, old_c, totaldigits;
const char __user *ubuf = buf;
const char __user __force *ubuf = (const char __user __force *)buf;
int exp_digit, in_range;

totaldigits = c = 0;
Expand Down Expand Up @@ -694,7 +696,7 @@ int bitmap_parselist_user(const char __user *ubuf,
{
if (!access_ok(VERIFY_READ, ubuf, ulen))
return -EFAULT;
return __bitmap_parselist((const char *)ubuf,
return __bitmap_parselist((const char __force *)ubuf,
ulen, 1, maskp, nmaskbits);
}
EXPORT_SYMBOL(bitmap_parselist_user);
Expand Down

0 comments on commit b9c321f

Please sign in to comment.