Gerhard Heift
2014-Nov-06 11:05 UTC
Re: fs/btrfs/ioctl.c:2204:29: sparse: incorrect type in argument 4 (different address spaces)
Hello, I got a warning from the kbuild test robot for an invalid address space cast, which was introduced by my patch for TREE_SEARCH_V2. Here is a patch, which should fix the warning. Regards, Gerhard 2014-11-06 10:48 GMT+01:00 kbuild test robot <fengguang.wu@intel.com>:> tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > head: 20f3963d8f48ae8309fbc777ef6787fd0a3f53c2 > commit: cc68a8a5a4330a4bb72922d0c7a7044ae13ee692 btrfs: new ioctl TREE_SEARCH_V2 > date: 5 months ago > reproduce: > # apt-get install sparse > git checkout cc68a8a5a4330a4bb72922d0c7a7044ae13ee692 > make ARCH=x86_64 allmodconfig > make C=1 CF=-D__CHECK_ENDIAN__ > > > sparse warnings: (new ones prefixed by >>) > > fs/btrfs/ioctl.c:2204:29: sparse: cast removes address space of expression >>> fs/btrfs/ioctl.c:2204:29: sparse: incorrect type in argument 4 (different address spaces) > fs/btrfs/ioctl.c:2204:29: expected char [noderef] <asn:1>*ubuf > fs/btrfs/ioctl.c:2204:29: got char *<noident> > fs/btrfs/ioctl.c:2729:27: sparse: incorrect type in assignment (different base types) > fs/btrfs/ioctl.c:2729:27: expected unsigned int [unsigned] [usertype] nodesize > fs/btrfs/ioctl.c:2729:27: got restricted __le32 [usertype] nodesize > fs/btrfs/ioctl.c:2730:29: sparse: incorrect type in assignment (different base types) > fs/btrfs/ioctl.c:2730:29: expected unsigned int [unsigned] [usertype] sectorsize > fs/btrfs/ioctl.c:2730:29: got restricted __le32 [usertype] sectorsize > fs/btrfs/ioctl.c:2731:34: sparse: incorrect type in assignment (different base types) > fs/btrfs/ioctl.c:2731:34: expected unsigned int [unsigned] [usertype] clone_alignment > fs/btrfs/ioctl.c:2731:34: got restricted __le32 [usertype] sectorsize > fs/btrfs/ioctl.c:4275:29: sparse: incorrect type in argument 1 (different address spaces) > fs/btrfs/ioctl.c:4275:29: expected void [noderef] <asn:1>*to > fs/btrfs/ioctl.c:4275:29: got void *<noident> > fs/btrfs/ioctl.c:4350:29: sparse: incorrect type in argument 1 (different address spaces) > fs/btrfs/ioctl.c:4350:29: expected void [noderef] <asn:1>*to > fs/btrfs/ioctl.c:4350:29: got void *<noident> > > vim +2204 fs/btrfs/ioctl.c > > 2188 /* copy search header and buffer size */ > 2189 uarg = (struct btrfs_ioctl_search_args_v2 __user *)argp; > 2190 if (copy_from_user(&args, uarg, sizeof(args))) > 2191 return -EFAULT; > 2192 > 2193 buf_size = args.buf_size; > 2194 > 2195 if (buf_size < sizeof(struct btrfs_ioctl_search_header)) > 2196 return -EOVERFLOW; > 2197 > 2198 /* limit result size to 16MB */ > 2199 if (buf_size > buf_limit) > 2200 buf_size = buf_limit; > 2201 > 2202 inode = file_inode(file); > 2203 ret = search_ioctl(inode, &args.key, &buf_size, >> 2204 (char *)(&uarg->buf[0])); > 2205 if (ret == 0 && copy_to_user(&uarg->key, &args.key, sizeof(args.key))) > 2206 ret = -EFAULT; > 2207 else if (ret == -EOVERFLOW && > 2208 copy_to_user(&uarg->buf_size, &buf_size, sizeof(buf_size))) > 2209 ret = -EFAULT; > 2210 > 2211 return ret; > 2212 } > > --- > 0-DAY kernel test infrastructure Open Source Technology Center > http://lists.01.org/mailman/listinfo/kbuild Intel Corporation