Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

init: disable sparse checking of the mount.o source files

The init/mount.o source files produce a number of sparse warnings of the
type:

warning: incorrect type in argument 1 (different address spaces)
expected char [noderef] <asn:1>*dev_name
got char *name

This is due to the syscalls expecting some of the arguments to be user
pointers but they are being passed as kernel pointers. This is harmless
but adds a lot of noise to a sparse build.

To limit the noise just disable the sparse checking in the relevant source
files, but still display a warning so that the user knows this has been
done.

Since the sparse checking has been disabled we can also remove the __user
__force casts that are scattered thru the source.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

H Hartley Sweeten and committed by
Linus Torvalds
c67e5382 243f3803

+57 -8
+12 -2
init/do_mounts.c
··· 1 + /* 2 + * Many of the syscalls used in this file expect some of the arguments 3 + * to be __user pointers not __kernel pointers. To limit the sparse 4 + * noise, turn off sparse checking for this file. 5 + */ 6 + #ifdef __CHECKER__ 7 + #undef __CHECKER__ 8 + #warning "Sparse checking disabled for this file" 9 + #endif 10 + 1 11 #include <linux/module.h> 2 12 #include <linux/sched.h> 3 13 #include <linux/ctype.h> ··· 340 330 if (err) 341 331 return err; 342 332 343 - sys_chdir((const char __user __force *)"/root"); 333 + sys_chdir("/root"); 344 334 s = current->fs->pwd.dentry->d_sb; 345 335 ROOT_DEV = s->s_dev; 346 336 printk(KERN_INFO ··· 566 556 out: 567 557 devtmpfs_mount("dev"); 568 558 sys_mount(".", "/", NULL, MS_MOVE, NULL); 569 - sys_chroot((const char __user __force *)"."); 559 + sys_chroot("."); 570 560 }
+10
init/do_mounts_initrd.c
··· 1 + /* 2 + * Many of the syscalls used in this file expect some of the arguments 3 + * to be __user pointers not __kernel pointers. To limit the sparse 4 + * noise, turn off sparse checking for this file. 5 + */ 6 + #ifdef __CHECKER__ 7 + #undef __CHECKER__ 8 + #warning "Sparse checking disabled for this file" 9 + #endif 10 + 1 11 #include <linux/unistd.h> 2 12 #include <linux/kernel.h> 3 13 #include <linux/fs.h>
+11 -1
init/do_mounts_md.c
··· 1 + /* 2 + * Many of the syscalls used in this file expect some of the arguments 3 + * to be __user pointers not __kernel pointers. To limit the sparse 4 + * noise, turn off sparse checking for this file. 5 + */ 6 + #ifdef __CHECKER__ 7 + #undef __CHECKER__ 8 + #warning "Sparse checking disabled for this file" 9 + #endif 10 + 1 11 #include <linux/delay.h> 2 12 #include <linux/raid/md_u.h> 3 13 #include <linux/raid/md_p.h> ··· 293 283 294 284 wait_for_device_probe(); 295 285 296 - fd = sys_open((const char __user __force *) "/dev/md0", 0, 0); 286 + fd = sys_open("/dev/md0", 0, 0); 297 287 if (fd >= 0) { 298 288 sys_ioctl(fd, RAID_AUTORUN, raid_autopart); 299 289 sys_close(fd);
+11 -2
init/do_mounts_rd.c
··· 1 + /* 2 + * Many of the syscalls used in this file expect some of the arguments 3 + * to be __user pointers not __kernel pointers. To limit the sparse 4 + * noise, turn off sparse checking for this file. 5 + */ 6 + #ifdef __CHECKER__ 7 + #undef __CHECKER__ 8 + #warning "Sparse checking disabled for this file" 9 + #endif 1 10 2 11 #include <linux/kernel.h> 3 12 #include <linux/fs.h> ··· 190 181 char rotator[4] = { '|' , '/' , '-' , '\\' }; 191 182 #endif 192 183 193 - out_fd = sys_open((const char __user __force *) "/dev/ram", O_RDWR, 0); 184 + out_fd = sys_open("/dev/ram", O_RDWR, 0); 194 185 if (out_fd < 0) 195 186 goto out; 196 187 ··· 289 280 sys_close(out_fd); 290 281 out: 291 282 kfree(buf); 292 - sys_unlink((const char __user __force *) "/dev/ram"); 283 + sys_unlink("/dev/ram"); 293 284 return res; 294 285 } 295 286
+13 -3
init/initramfs.c
··· 1 + /* 2 + * Many of the syscalls used in this file expect some of the arguments 3 + * to be __user pointers not __kernel pointers. To limit the sparse 4 + * noise, turn off sparse checking for this file. 5 + */ 6 + #ifdef __CHECKER__ 7 + #undef __CHECKER__ 8 + #warning "Sparse checking disabled for this file" 9 + #endif 10 + 1 11 #include <linux/init.h> 2 12 #include <linux/fs.h> 3 13 #include <linux/slab.h> ··· 84 74 } 85 75 } 86 76 87 - static long __init do_utime(char __user *filename, time_t mtime) 77 + static long __init do_utime(char *filename, time_t mtime) 88 78 { 89 79 struct timespec t[2]; 90 80 ··· 539 529 struct linux_dirent64 *dirp; 540 530 int num; 541 531 542 - fd = sys_open((const char __user __force *) "/", O_RDONLY, 0); 532 + fd = sys_open("/", O_RDONLY, 0); 543 533 WARN_ON(fd < 0); 544 534 if (fd < 0) 545 535 return; ··· 599 589 } 600 590 printk(KERN_INFO "rootfs image is not initramfs (%s)" 601 591 "; looks like an initrd\n", err); 602 - fd = sys_open((const char __user __force *) "/initrd.image", 592 + fd = sys_open("/initrd.image", 603 593 O_WRONLY|O_CREAT, 0700); 604 594 if (fd >= 0) { 605 595 sys_write(fd, (char *)initrd_start,