* [PATCH] btrfs/ioctl.c: quiet sparse warnings
@ 2011-09-23 18:07 H Hartley Sweeten
2011-09-23 18:15 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: H Hartley Sweeten @ 2011-09-23 18:07 UTC (permalink / raw)
To: Linux Kernel; +Cc: linux-btrfs, chris.mason
Quiet the following sparse warnings:
warning: cast removes address space of expression
warning: incorrect type in assignment (different address spaces)
expected struct btrfs_ioctl_space_info [noderef] <asn:1>*user_dest
got struct btrfs_ioctl_space_info *<noident>
warning: symbol 'btrfs_ioctl_space_info' was not declared. Should it be static?
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Chris Mason <chris.mason@oracle.com>
---
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 970977a..a001af4 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2599,7 +2599,7 @@ static void get_block_group_info(struct list_head *groups_list,
}
}
-long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
+static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
{
struct btrfs_ioctl_space_args space_args;
struct btrfs_ioctl_space_info space;
@@ -2705,7 +2705,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
up_read(&info->groups_sem);
}
- user_dest = (struct btrfs_ioctl_space_info *)
+ user_dest = (struct btrfs_ioctl_space_info __user *)
(arg + sizeof(struct btrfs_ioctl_space_args));
if (copy_to_user(user_dest, dest_orig, alloc_size))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs/ioctl.c: quiet sparse warnings
2011-09-23 18:07 [PATCH] btrfs/ioctl.c: quiet sparse warnings H Hartley Sweeten
@ 2011-09-23 18:15 ` Joe Perches
2011-09-23 19:02 ` H Hartley Sweeten
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2011-09-23 18:15 UTC (permalink / raw)
To: H Hartley Sweeten; +Cc: Linux Kernel, linux-btrfs, chris.mason
On Fri, 2011-09-23 at 11:07 -0700, H Hartley Sweeten wrote:
> Quiet the following sparse warnings:
[]
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
[]
> @@ -2705,7 +2705,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
> up_read(&info->groups_sem);
> }
>
> - user_dest = (struct btrfs_ioctl_space_info *)
> + user_dest = (struct btrfs_ioctl_space_info __user *)
> (arg + sizeof(struct btrfs_ioctl_space_args));
user_dest = arg;
user_dest++;
?
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] btrfs/ioctl.c: quiet sparse warnings
2011-09-23 18:15 ` Joe Perches
@ 2011-09-23 19:02 ` H Hartley Sweeten
0 siblings, 0 replies; 3+ messages in thread
From: H Hartley Sweeten @ 2011-09-23 19:02 UTC (permalink / raw)
To: Joe Perches; +Cc: Linux Kernel, linux-btrfs, chris.mason
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2750 bytes --]
On Friday, September 23, 2011 11:16 AM, Joe Perches wrote:
> On Fri, 2011-09-23 at 11:07 -0700, H Hartley Sweeten wrote:
>> Quiet the following sparse warnings:
> []
>> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> []
>> @@ -2705,7 +2705,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
>> up_read(&info->groups_sem);
>> }
>>
>> - user_dest = (struct btrfs_ioctl_space_info *)
>> + user_dest = (struct btrfs_ioctl_space_info __user *)
>> (arg + sizeof(struct btrfs_ioctl_space_args));
>
> user_dest = arg;
> user_dest++;
>
> ?
That produces a new sparse warning:
fs/btrfs/ioctl.c: In function âbtrfs_ioctl_space_infoâ:
fs/btrfs/ioctl.c:2708: warning: âuser_destâ may be used uninitialized in this function
I guess user_dest could be set at the start of the function. This would
also remove the cast of arg in the first copy_from_user.
Something like this:
------
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 970977a..9e7e5dc 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2599,13 +2599,13 @@ static void get_block_group_info(struct list_head *groups_list,
}
}
-long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
+static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
{
struct btrfs_ioctl_space_args space_args;
struct btrfs_ioctl_space_info space;
struct btrfs_ioctl_space_info *dest;
struct btrfs_ioctl_space_info *dest_orig;
- struct btrfs_ioctl_space_info __user *user_dest;
+ struct btrfs_ioctl_space_info __user *user_dest = arg;
struct btrfs_space_info *info;
u64 types[] = {BTRFS_BLOCK_GROUP_DATA,
BTRFS_BLOCK_GROUP_SYSTEM,
@@ -2617,9 +2617,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
u64 slot_count = 0;
int i, c;
- if (copy_from_user(&space_args,
- (struct btrfs_ioctl_space_args __user *)arg,
- sizeof(space_args)))
+ if (copy_from_user(&space_args, user_dest, sizeof(space_args)))
return -EFAULT;
for (i = 0; i < num_types; i++) {
@@ -2705,8 +2703,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
up_read(&info->groups_sem);
}
- user_dest = (struct btrfs_ioctl_space_info *)
- (arg + sizeof(struct btrfs_ioctl_space_args));
+ user_dest++;
if (copy_to_user(user_dest, dest_orig, alloc_size))
ret = -EFAULT;
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-09-23 19:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-23 18:07 [PATCH] btrfs/ioctl.c: quiet sparse warnings H Hartley Sweeten
2011-09-23 18:15 ` Joe Perches
2011-09-23 19:02 ` H Hartley Sweeten
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®